My First Hackathon

I attended a Hackathon in Anna University. It is a 12 hours workshop which is from 8pm to 8am. They said that the domain will be given at on spot. But at the time of hackathon, they ask to choose any domain which ever we want. So we planned to create a project on Anti-crime system,

We spent almost an hour to select a domain which is not quite easy. Then we started the project at 11pm. Many participants slept but myself and my teammate planned to work continuously.

Finally we finished the project and we explained about the problem statement and functions of the project to the co-ordinater. But unfortunately, we didn’t selected for the second round.

Address Book – Project

After I completed python as per the suggestion of Mr.T.Shrinivasan anna, then anna told to do a small project on address book, which has many user’s information. Then it should have functions like search, edit and delete. Then it the resulting output should be stored in the pdf format or csv format. For these days, I have been working on it and I completed just now. Check out my project at https://github.com/Chandru-RV/Address-Book.

Git basic commands

As I completed that how to use github and what is the use of it, Its time to learn the commands of it.

1. First command is to check the version of the git. The command is git –version. This will show the current version of the git which is installed.

2. The next is git init. This will make the local directory to a repository.

3. git add. this will add the file to the staging area, but not to the local repository.

4. To add to the local repository, git commit is used. Normally each commit should be given with the message for the better understanding. This is done by -m “Message”.

5. git status, this command will show on what branch we are working on and displays if any files present in the staging are but not commited to the local repository.

6. git config, It is used to config our username and the email in which we can set global or local. git config –global user.name “Chandru”, git config –global user.email “r.v.chandru.13@gmail.com”

7. git branch, this command is used to display all the branches which are created and also used to create a new branch. To create a new branch git branch new_branch_name

8. git checkout branchname, this command is used to change from the current branch.

9. git merge branchname, this will merge the master branch and the branch which is given in the arguement.

10. git branch -d branchname, this command will delete the branch.

11. git remote add origin git@github.com:Chandru-RV/Chandru.git, this is used to add the remote repository.

12. git clone “SSH link”, this command is used to create a clone of the repository which is found in that link.

13. git pull origin master. In case in change made in the github repository, to reflect in our local repository, this command is used.

14. git push origin master. If we want to add changes or to add a new file to the github account, this command is used. We can push the changes to it only if we add and commit to the local repository and then push it.

15. git log. This command is to store the records of the author, who commited a file.

16. If we commited a change to existing file which is already commited and if you want to move back to the previously commited file and delete the recently commited file, git revert command is used. To start with this, first type git log –oneline. This will return alphanumeric value with a label last commit. Then copy the value and type git revert “alphanumeric_value”. After this, the recently made changes will be gone.

17. If you again want the previously commited changes, git revert HEAD command is used.

Gym

Today, myself and two of my friends had to join a gym. But many fun with us that we wont able to go to the gym. I too thought that we won’t able to attend, but One guy in our gang didn’t lose the hope. Finally we joined the Giri gym which is located near our locality. At the end of the day, I felt so tired and I wish to continue this gym atleast throughout this year.

At studies part, Next I am going to learn about git and github. So when I was searching where to learn, I saw a course in udemy which is absolutely free. So my aim is to complete this course within this week.

2020

Till yesterday, I thought that the first day of the new year 2020 will be so poor because many of my friends had a work at their home and none of them are interested to come out of their home. So the last day of 2019 went little bit dull.

At last one of my friend invited to stay with him the whole night. So 5 people went to his home at stayed there itself. We had a lot of fun over there and we finally slept at 1:15.

Then we woke up at 4 and planned to visit a beach. So we to Beautiful beach which is in ECR. That beach was so awesome and we returned home at 9. I somehow started this year in a best way and I hope this year will be awesome to me.

Python – Completed

Finally, I just completed the python language as per the chapters in pymbooks. But there is a lot to learn in python.

I had learnt c,c++,java. But after learning python, I always choose python for writing any program. This is because, when I write a 10 lines program in java, I can finish the same within 5 lines in python. I thought python will be hard as it is used in all field like gaming, web development and many. But when I started to learn it, I felt so easy and I also felt convenient to write program in python.

Python Flask

Flask is a web framework. Usually the flask allows to create a web application like blog, website and so on. Flask is a part of the micro framework.

Template

If we create a web application with few pages, it will be easy to maintain. But incase of large website, it is not so easy to handle. So we can use template engine which is used for creating the application and also easy to update and maintain it.

“Hello World” application

First of all, we can create a structure of the project.

$mkdir -p hello/{template,static}

Thus the two folder static and templates are created. Template folders contains the templates and the static folder will contains the javascript, css, html which is required for the development of the web application. Change the directory and put the following code inside the file.

import flask

APP = flask.Flask(__name__)

@APP.route(‘/’)

def index():

return flask.render_template(‘index.html’)

if __name__ == ‘__main__’:

APP.debug=True

APP.run()

Now we can create the template file (temp.html) and place it in the template module.

<!DOCTYPE html>

<html>

<head>

<title> Website </title>

</head>

<body>

<h1> Hello World </h2>

</body>

</html>

When we run this program, the output will shown in the default browser.

Using arguements in flask

Create a program which will fetch the name from the current user. After fetching, the name is returned to the template file where the name of the current user is displayed.

@APP.route(‘/hello/<name>/’)

def hello(name):

return flask.render_template(‘hello.html’, name=name)

Then we want to add the html file according to this argument.

<!DOCTYPE html>

<html>

<head>

<title> Website </title>

</head>

<body>

Hello {{name}}

</body>

</html>

The output will be “Hello Chandru”.

Links

To create link in the template, flask uses url_for(). This will add the link of the next page or any other page.

<a href=”{{ url_for(‘temp’) }}”><button>Home</button></a>

Building Command Line Application with Click

Virtualenv is recommended to creste command line application with “click”. To start with this, lets create a program disp.py which displays some messages.

def cli():

print(“Hello World”)

Next we are creating a setup.py because this will help us to use the python module.

from setuptools import setup

setup(

name=”Display”,

version=’0.1′,

py_modules=[‘hello’],

install_requires=[‘Click’,],

entry_points=”’ [console_scripts] Display=disp:cli ”’,

)

We have mentioned the starting point of the tool in the entry_points. We can install the virtualenv which makes it easier and activate it.

$python3 -m pip install –editable

$Display

Hello world

–help will show the options of the setup file.

Instead of using the standard print function, we can use echo which is available in the click module.

click.echo(“Hello world”)

Boolean flags

In case if a option is provided, then it will print the extra message else it will do some other task. In python, we will call the flag as verbose

import click

@click.command()

@click.option(‘–verbose’, is_flag=True, help=”the message in the verbose will be displayed”)

def cli(verbose):

if(verbose):

click.echo(“Verbose message”)

Similarly we can use multiple options for the verbose method.

Password Confirmation

There is a super fast way for the password confirmation which can be used. This method is imported from the Click module. If the password is right, it displays the content else it displays the error message.

@click.password_option()

Arguement

These arguements are must be provided that is,there is no default value. The arguements are Strings by default.

@click.arguement( ‘name’)

Still sick

Recently, I published a post regarding the fever. I thought, okay I was fine. But still, I can feel fever. Every time I feel the itching sensation in my throat. Continuous cough, soar throat made me felt worst.

And so, I was staying my house without going anywhere else. But today, Myself and my gang had planned to go out and have some food. We where searching a new restaurant. Finally we found a burger shop. I was not sure about the name of the restaurant. The burger was really awesome. And finally we returned home at 9 P.M. After some boring days, I felt happy at the end of this day.

Project Structure in Python

This blog will explain the structure of the project and how to upload the software.

Let’s see an example by creating a module Myadd. In this we create a python program which contains a definition to add two numbers.

Lets create a directory Myadd where the name is same as module.

“Myadd”

void add(a,b):

sum = a+b

print(“The sum is %d” % sum)

We also added __init__.py and README.rst file in the module.

$ ls

Myadd README.rst

In My Myadd directory, we can find the __init.py__ file.

License

We have to add a license to our project, so that it will not republished by anyone again. Usually the projects are licensed under MIT.

Installing Setuptools

Let’s install, setup tools using virtualenv, and also we can install the wheel.

$ pip install setuptools wheel

Then we want to create setup.py which is used for installing the software.

from setuptools import find_package, setup

find_package is used to find and load the external setting into the program.

Python Package Indexing

It is the repository of the software in the python programming language. The pip command in which we normally use to install the software fetches the packages from the PyPI.

Uploading the Project

The project has to be uploaded to the server (test.pypi.org).For this twine command is used. Before that we want to install twine.

$ pip install twine

$ twine upload –repository-url https://test.pypi.org/legacy/ dist/*

Then it will ask for the username and password. After completing, the project will be uploaded to the test server.