Wednesday, June 14, 2017

Hasura Internship - 2.2 The wonders of git

Git is a magnificent version control tool. What does that mean? 😅

Let's do a tiny insignificant project to get the basics out of the way.

Start a project

$ mkdir ~/Projects/chicken_soup
$ cd ~/Projects/chicken_soup
$ touch recipe.txt

This project will contain only a text file, having a silly recipe for chicken soup 😎
With this, we have a base project structure in place.

Asking git to track this project

$ git init

When we do this, we see that there is a .git folder magically appearing on our project folder. This is where git stores all relevant information to file changes in our project. If we have not configured git, now is the best time.

$ git config --global user.name "superman"
$ git config --global user.email "kalel@kryptonmail.com"

Let's write something to our recipe file.

$ echo "1. Get a chicken gutted." > recipe.txt

We want git to know that recipe.txt is a file it should track within our project. So we do

$ git add recipe.txt # or git add . 
# the alternative will keep track of all files in the folder

Our first commit

$ git commit -m "My first commit"

This tells git that we want to update our additions and git should consider this as a check point. Each commit will be a separate checkpoint in our project. The -m is simply a way to pass a message along with our commit, so that we can understand the commit logs later.

$ git log

Will show us that our change has indeed been tracked. That's it 😉

Let's do that again

$ echo "2. Apply masala over it." >> recipe.txt
$ git add recipe.txt
$ git commit -m "applying masala"

Now if we do a git log, we can see 2 entries. Do note the weird number strings, like 2edfr5t0fd649d774ca3fb77614bde9a62axsd9 in my case. Also check the order in which they appear. The one at the top, is our latest commit.

Yikes, I screwed up. Abort

If I want to reset the file to the first commit, we can do that

$ git reset --hard bd959d6a0fd649d774ca3fb77614bde9a61f64f9   

Now if we look at the contents of recipe.txt, we see just the one line. Of course this isn't earth shattering. Try adding a few files and add content to these files. This is where git shows its magic.

Onto the internet

Github is a service on top of git that takes our projects and gives it an online presence. After we register for a github account, we can add our chicken soup project to it.

The following is our projects URL after we go through the initial stages of adding a new project to our github account.

https://github.com/superman/chicken-soup.git

From our project folder in our machine, do

$ git remote add origin https://github.com/superman/chicken-soup.git
$ git push -u origin master

This will set our projects repo url and push our code to github. If we go to  https://github.com/superman/chicken-soup in a browser, we can see our project. 

Let's add some more changes

$ echo "100. Eat chicken soup." >> recipe.txt
$ git add recipe.txt
$ git commit -m "Final step added"

We push these changes to github

$ git push -u origin master

So, later we're on our friend's machine and we want to show what we made. Assuming that our friend has git installed, a

$ git clone https://github.com/superman/chicken-soup.git

will download the entire project to the friends machine.

Conclusion

This was just a rudimentary intro. An awesome book on git can be found here



Tuesday, June 13, 2017

Hasura Internship - 2.1 Setup dev environment

The following are the things I need to get some work done on making the app.

Node JS

I'm running my dev environment on Ubuntu, to install node on it, execute the following commands on the terminal

$ curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
$ sudo apt-get install -y nodejs

The node js website has detailed info for installing node on the Operating System of choice for the user.

Git

Git is our version control program. It's basically a program that keeps track of changes to files in our project. 

If I screw up on a perfectly working project and I want to revert the project to a stage before the screw-up, I can do that with git.

$ sudo apt-get install git

That would install git onto my ubuntu machine. A quickstart on git can be found here. To get our feet really wet, there's a book called Pro-Git.

Sublime Text

This is my preferred text editor for code. Even though my inner vim-genin is cursing me for this choice, time is of the essence in the internship. 

$ wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -

 The above would make our system trust packages from sublimeHQ.

$ echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list

This line adds the stable repo url for sublime text.

$ sudo apt-get update
$ sudo apt-get install sublime-text

Finally update the repo cache and install sublime text.

The Shell

Over the years, I've grown quite fond of a shell called zsh. Its immense completion system is really a priced feature for me. Luckily, there is a community maintained project called oh-my-zsh that gives me a good modularized zsh configuration that I can extend with plugins

$ sudo apt-get install zsh
$ sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"


Log Date : May 1-10

Hasura Internship - 1.2 Prototyping

Requirements

The entire app should have a max of 3 pages.
  • Must have a provision to add a new family, add a new member to the family and finally make edits.
  • Member images and family image can be added and edited.

Prototype (TL;DR)

The three pages are  
  1. search - the search display mock up.
  2. one - detailed view of a member's family.
  3. add - to add a new family and then members to it.  
A pdf document of all the prototypes of all three pages can be found here. Credits to proto.io for the awesome tools to make the prototype.

A live view of the pages are hosted temporarily on my personal site.

The pages use bootstrap, just because I can't do responsive design.

The project can be tracked on its github page.

Log Date : May 1-10 

Monday, June 12, 2017

Hasura Internship - 1.1 App Idea

By the end of January, something amazing happened. I enrolled in an online mooc called IMAD from the folks at Hasura and IIT-M. And by the grace of the force, I was able to clear it and make a small webapp in the process. As part of this, Hasura selected a few students(almost 400 of us), for an internship, where we would have to make an app using the hasura platform

The Internship

The following are the guide lines

  • Strictly use the Hasura platform.
  • The app should contain only three screens, excluding the login page.
  • NodeJS and Python are favored, but are not the only languages for back-end coding. 
  • The app building should take less than 7 weeks, with the 8th week being left for getting feedback and improvements.
  • The interns should blog about their progress somewhere (hence this blog post).

App Idea

I am not a very religious person, but I do occasionally go to my chruch. And when I do, I always meet someone, who I have no idea about. There is a directory for our chruch members, but that book is 250 pages thick and weighs a ton. So, there has been a talk whether we can take that info and make it online (Carrying a 24 inch smartphone is considered normal).

So, it's settled, I'll build an online searchable directory for my parish. 
I'll have to do some mad research if I wanna squeeze everything down to three pages.

We'll see how it goes.

Log Date : May 1-10