Sunday, June 25, 2017

Hasura Internship - x.x The Break

From May 13 to May 28 saw a lot many things happening.

  • The company where I worked decided to let me and my team go. So now I'm left with the slow and agonizing task of dusting off my resume and that old Q.A book.
  • First things first, I decided to remake my resume. Done.
  • After countless days of running around we scored a place. Unfortunately the boys and gals at the new place played with the bleeding edge when it came to their stack. And we were dinosaurs. So I had to pause what I was doing till then and get a hang for ES6, MongoDB and Angular
  • I notified the Operations Head at the internship about the delay and he was more than understanding in this regard.
  • In order to get a grip of things I wanted to do a project with the things I was learning. So I decided to do the Internship App on this new stack, save for using angular(still too alien).
  • A video on the pre-alpha can be found on youtube. The source will be pushed on to github, when it's ready.
Currently I'm rushing to get back on track. The date is 26 June today, and I'm hoping to finish this puppy by 29 June.

Hasura Internship - 2.3 The pain of local development

The Hasura platform is awesome. The whole purpose of the internship was to get us to build stuff using Hasura APIs and what not. I gently grazed over the hasura docs, and for me personally it feels like there's no more fun left in coding out what I want. I may not be the greatest programmer, but I do take fun and joy in building the stuff I want, the way I want. It's one of the reasons why I stare at the screen all day. Ranting aside, lets setup the Hasura platform on our local machine.

Lets do this

The local dev setup relies on setting up pre-configured virtual machines which are controlled by a tool called kubernetes.
  1. Enable Hardware virtualization if we have a UEFI machine 
  2. Install virtualbox : sudo apt install virtualbox
  3. Get kubectl (linux link) and move it to /usr/local/bin or our preferred location.
  4. Clone the local-dev repo. The repo changed quite a lot when I had set it up (it's now just one README now).
  5. Read the README in the url mentioned above.  After executing a line that goes kubectl create -f platform-init.yaml , a ~2GB download will start. Be patient till it finishes.
  6. If we have anything running on port 80 (ie local apache or nginx), stop the service before launching the local instance of hasura platform. A netstat -nptl wil show all tcp and udp ports in use, in our linux system.
  7. Free atleast 4GB of RAM to have a smooth experience with the platform.
  8. Its a pain to always type in 2 or 3 commands to get something up and running. So make scripts to get things rolling
$ cat ~/bin/hasura_start.sh

#!/bin/bash

echo "starting minikube ... "
minikube start --kubernetes-version v1.6.3
echo "minikube running :)"

GW_IP=`minikube ip`

sudo ssh -N -o UserKnownHostsFile=/dev/null -L 80:$GW_IP:80 -L 2022:$GW_IP:2022 docker@$GW_IP

Run the above script to start hasura and the below one to stop it.

$ cat ~/bin/hasura_stop.sh

#!/bin/bash

minikube stop


Log Date : May 10 - 20

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