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


Friday, April 29, 2016

Installing mariadb in ubuntu 14.04 and setting up a 2 node galera cluster

Getting ready



Let's update our apt cache with the mariadb apt repo, so that we can get the latest and greatest version.
Add the following two lines to /etc/apt/sources.list


deb http://mirror.jmu.edu/pub/mariadb/repo/10.1/ubuntu trusty main
deb-src http://mirror.jmu.edu/pub/mariadb/repo/10.1/ubuntu trusty main


Now perform an update of the repo cache in our system

sudo apt-get update

And then install mariadb with galera and rsync

sudo apt-get install mariadb-server galera-3 rsync

Installation is done.


Configuring mariadb with galera


I'm going to use 2 nodes here, 192.168.1.4 (master_node) and 192.168.1.5 (slave node). 

In our master_node I'm going to create a file called  cluster.cnf  in   /etc/mysql/conf.d  (Very important that the file name ends with  .cnf )  and put in the following contents.

[galera]
wsrep_on=ON
wsrep_provider=/usr/lib/libgalera_smm.so
wsrep_cluster_name="cluster_test"
wsrep_cluster_address="gcomm://192.168.1.4,192.168.1.5"
wsrep_node_name="master_node" 

wsrep_node_address=192.168.1.4  
wsrep_provider_options="pc.weight=3" #tells this server is very important
binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
innodb_doublewrite=1



In our slave_node I'm going to create the same file, in the same location  and put in the following contents.

[galera]
wsrep_on=ON
wsrep_provider=/usr/lib/libgalera_smm.so
wsrep_cluster_name="cluster_test" # same name as in primary server
wsrep_cluster_address="gcomm://192.168.1.4,192.168.1.5"
wsrep-node-address=192.168.1.5
wsrep_node_name="slave_node"
binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
innodb_doublewrite=1
wsrep_sst_method=rsync
wsrep_sst_receive_address=192.168.1.5


We're done configuring. Now in the master_node (primary server) run 

sudo service mysql stop
sudo service mysql start --wsrep-new-cluster


Check if we have successfully started a node in our cluster by running this from our terminal shell

mysql -u root -p -e 'SELECT VARIABLE_VALUE as "cluster size" FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME="wsrep_cluster_size"'

It should return 1. If so, we're good.

We next bring up our slave_node (secondary server). Run these from our second node 

sudo service mysql stop
sudo service mysql start # only use --wsrep-new-cluster in primary server


That's it !. Create a database from any one of the nodes and it'll be reflected on the other.


One more thing


Copy the file /etc/mysql/debian.cnf from the primary server into the secondary server (replace the one it has).

Fin

Saturday, November 22, 2014

Solarized dwm + debian

This article is a small post-it to get the desktop of my dreams installed on my machine :)

1. Installing and configuring dwm

Installing dwm from the debian repos is easy but, inorder to customize it we need to compile it from source. First, I install the dependencies

sudo apt-get install libc6 libx11-6 libxinerama1 make gcc suckless-tools xfonts-terminus

dwm by default uses the terminus font and I like it too. Now for the fun part

sudo aptitude build-dep dwm

Now we make a directory to put the source code in, and play around :P

mkdir ~/build
cd ~/build/
apt-get source dwm
cd dwm-6./

Next we edit the config.def.h in the directory and save it as config.h

cp config.def.h config.h
vim config.h

I'm only interested in changing the colors and the font used for the time being so in the config.h file I change ::

static const char font[]            = "-*-terminus-medium-r-*-*-16-*-*-*-*-*-*-*";
static const char normbordercolor[] = "#cccccc";
static const char normbgcolor[]     = "#cccccc";
static const char normfgcolor[]     = "#000000";
static const char selbordercolor[]  = "#0066ff";
static const char selbgcolor[]      = "#0066ff";
static const char selfgcolor[]      = "#ffffff";

to this ::

static const char font[]            ="-artwiz-snap-normal-*-*-*-*-*-*-*-*-*-*-*";
static const char normbordercolor[] = "#073642";
static const char normbgcolor[]     = "#002B36";
static const char normfgcolor[]     = "#839496";
static const char selbordercolor[]  = "#586E75";
static const char selbgcolor[]      = "#073642";
static const char selfgcolor[]      = "#839496";

Use xfontsel to see what all fonts we can use. I use the snap font from artwiz package. If you use another terminal emulator change the *termcmd[] command to this ::

static const char *termcmd[]  = { "urxvtc", NULL };

I have the urxvt daemon running in the background when I launch dwm, so the urxvtc.

After this is done, save and exit. From the directory issue 

sudo make clean install

That's it. Now Launch dwm form your $HOME/.xinitrc . If you dont have one follow me

cd
vim .xinitrc

It's content should be something like

exec dwm

Give it executable permissions with chmod +x .xinitrc and we're all set with dwm part. 

For the time being my dwm setup is this ::

busy

To get the date and battery status on the dwm statusbar before the exec dwm line in .xinitrc add 

while xsetroot -name "Batt:$(acpi | awk '{ print $4 }' | tr -d ',')  $(date +%R)"

Save the file and we're done.

Friday, October 3, 2014

Stepping into freeBSD

Intro

FreeBSD unlike Linux is a pure UNIX OS(I really don't see the difference, that's just me). Any how this writing is to specify the stuff I did to get FreeBSD up and running on my Dell Inspiron 630m. 

The machine has a centrino processor and has only 512 MB of RAM, so my choice of software has to be lightweight and specific. For these reasons compiling from ports seem to be the best option. Using the handbook, I was able to get i386 version of FreeBSD(usb image) installed on the machine.  Inorder to make a bootable usb stick with windows I used this.

Basic stuff 

User Management:


I had setup a normal user account during the initial setup. On my fresh install the first thing I do is to add my user to the wheel group. If I have to issue an "su" I need to be in the wheel group. I do that with 

pw groupmod operator -m user_name

And we are done. If we didn't create a user at the initial setup then issue the following

pw user add -n user_name -c "Full_user_name" -g wheel -m -h 0

Btw, I dont need to mention this, but the above need to be executed as root.

Lets setup the system:


I did mention that I need the system to be light on resources, so Im going to compile using ports. By doing so, I get to disable options of software that I'm not going to use. Enough chit chat, lets start.

1.Getting ports


As root

portsnap fetch extract update

I watched an entire movie while this was completing. Based on ones machine, this can take a while. But totally worth the effort.

Now I'll install a port management tool called portmaster. I do that like this

cd /usr/ports/ports-mgmt/portmaster/ && make install clean

When that completes we need to configure it a bit. So I take a sample config file provided with the port and use that. I do that like so

cp /usr/local/etc/portmaster.rc.sample /usr/local/etc/portmaster.rc

ee /usr/local/etc/portmaster.rc


ee is freebsd's default text editor. Add the following into it

# Always delete stale distfiles without prompting (-d)

ALWAYS_SCRUB_DISTFILES=dopt

# Be verbose (-v)

PM_VERBOSE=vopt

# Install packages for build-only dependencies (--packages-build)

PM_PACKAGES_BUILD=pmp_build

# Delete build-only dependencies when finished (--delete-build-only)

PM_DEL_BUILD_ONLY=pm_dbo

#Suppress the build confirmation message (--no-confirm)

PM_NO_CONFIRM=pm_no_confirm


Save and exit out from ee. Now we'll use portmaster to compile our ports.

Below are some commands I find useful.

update all ports:

   portmaster -a
   force:
      portmaster -af
  
search for updates and list all installed ports by category:
     
   portmaster -L
   portmaster -L | grep "New version available:"
     
clean stale distfiles:

   portmaster --clean-distfiles
   with out promt:
      portmaster --clean-distfiles-all
  
uninstall the port and it's dependencies:
  
   portmaster -e target_port

rebuild the specified port, and all ports that depend on it:
  
   portmaster -r target_port

2. Setting up X


portmaster x11-servers/xorg-server

portmaster x11-drivers/xorg-drivers

portmaster x11/xinit

portmaster x11/xauth

portmaster x11-fonts/xorg-fonts

portmaster x11-fonts/webfonts

 The above will install a minimal Xorg server and a couple of drivers for keyboard and mouse. Disable hal in each installation of a port. Now we configure X

Xorg -configure

cp /root/xorg.conf.new /etc/X11/xorg.conf

To configure mouse

echo "moused_port=\"/dev/psm0\"" >> /etc/rc.conf

echo "moused_enable=\"YES\"" >> /etc/rc.conf


3.Window Manager


I love #! linux and openbox, So i'll use openbox on this machine.


portmaster x11-wm/openbox

mkdir ~/.config

mkdir ~/.config/openbox

cp /usr/local/etc/xdg/openbox/menu.xml ~/.config/openbox/menu.xml

cp /usr/local/etc/xdg/openbox/rc.xml ~/.config/openbox/rc.xml

touch ~/.config/openbox/autostart.sh && chmod +x ~/.config/openbox/autostart.sh

echo "#!/bin/sh" >> ~/.config/openbox/autostart.sh

echo "exec openbox-session" >> ~/.xinitrc

I need a panel so,

portmaster deskutils/pypanel

I'll want it to autostart with openbox so,

echo "(sleep 2 && pypanel) &" >> ~/.config/openbox/autostart.sh

4.Automounting USB drives


portmaster sysutils/automount

Add automounter_enable="YES" to /etc/rc.conf and we are set.

With that my freeBSD box is setup. More writings will follow. Thank you to taz from the forums. I just took his guide and replicated it here.

~aktsbot

Thursday, September 4, 2014

Getting started with OpenBSD


After a long time being a linux user, I decided to try BSD. And because the transition was hard, I'll post the stuff (what I did) here for future ref.

Sunday, June 15, 2014

A fresh start

Why the change ?

I'm not a much of a great blogger, but I do wanna make myself turn back and see what all I have done in the past. From now on, there will be regular updates to the blog. I have been rusting for a while. Time to dust off and move on. Lot of personal crap bogged me down, but i'm now ready to kick butt.

First move

I've decided to jump from GNU\Linux to freeBSD, mainly because of curiosity as I wanted to try something different. Things can go bork, but hey that's the fun part. This is the thing that motivated me: https://forums.freebsd.org/viewtopic.php?f=39&t=35308&start=125#p261869

Second move

Learning something new. I know a couple of languages but not any to the point where I can design anything I want. So, starting today I'm visiting my roots to C and fall in love with code.

Last thing

My PC (eleanor) met a tragic end when a thunder storm took out her mother board. So repairs and other things are to follow.

~Live long and prosper.

Friday, December 20, 2013

Lightweight debian desktop

Why am I doing this, when there are already like a billion articles on the internet on how to do this?, Its because I can :D. In this article I'll do a debian net-install and over that I'll add my desktop.

1. Getting the install media
                                    Go to the "Official netinst images for the stable release" section of the debian downloads page and download the net-install CD-image. I chose torrent, and at the time of writing the stable version I've downloaded is debian-7.2.0-i386-netinst.iso . My laptop is old, but it has a usb port... and since its evil not to use a usb port I'll make a bootable usb stick for my installation.

Download unetbootin and launch it. Choose "Disk Image" and then browse for our debian iso. Ahem!! did you plug in your thumb drive :D . Dont change any of the other settings, now click on OK. Wait for it to finish and now you have a bootable usb drive.

2. Doing the install
                                  Boot the PC or laptop from the  usb stick. On the first screen Press Enter on "Install". And now we'll be presented with the debian installer. Choose your keyboard layout. (the internet connection should be up). The next screen you’re likely to see is choosing a hostname. Chances are, you can make up whatever you want. Now it’s time to pick a local mirror. After choosing your country, you’ll be asked which mirror to use.Username and password?? You'll be prompted to give a root user password, leave it blank, press Enter each time. Then the normal user we are to create will be automatically given sudo privilleges. Next comes a partitioning screen, I'll go ahead and use the entire disk. Now on the screen where we are to choose our software see to it that only "Standard system utilities" is only checked. Also if you're doing this on a laptop like i am check "Laptop" box also. Now sit back and enjoy the screen if red and blue progress bars. Now choose where to install grub. Choose MBR, which is the safest choice. And thats it, we have our debian net-install on our machines drive.


Screenshots

Of late, I've been playing with a debian net-install. I wanted to do a desktop with minimum footprint. This is what I came up with.

new deb

Window manager is jwm, fonts are terminus and snap.

Saturday, October 19, 2013

Personal Update

It has been way too long since I put something up here!!. I started to blog because of him, he said "if you learn something from the net give it back", righteous words aren't they? Anyway, due to the recent turn of events, I had never got the chance to fill in all of the stuff that I encountered till now. So I'm going to retrace from 2011(when the blog became static). And since no one but me will look into my shit, this would act as a personal reminder and check box of what I have done with my time. Also, I find no use for phaceb00k :( , so here I am on my blog.

Things that happened in 2011-2013.

1. On May 23,2011 a new chapter unfolded. Not that it was my 18th birthday, but that was the day when my 12th C.B.S.E results came. My parents had such high hopes(usual)  that I heard the bells ringing for me when I announced my result to them. Any way ashamed of what I achieved(yes, achieved!!), I tried to get away from it all. A runaway perhaps was what I intended. The atmosphere at home was a "Silence of the lambs"-cliche. After a lot of thinking and banging my head against my room's wall, I decided to take upon my dad's offer to go for engineering.

Note:   Every kid in my great nation grows up hearing two words "Engineer" and "Doctor". I never looked beyond those options(I was lazy and stupid!). I took bio-math in my XI and XII, so that I can eventually cut up people(being the right hand of god and all that.). This was (yes was!) my prime interest. But for anything in life "if you don't succeed at first, then you'll never get a chance  again" and medicine study ain't cheap. After I wrote my entrance exams, a stupid flyer(I realized fate is a biyatch!!) for a college hit my face. I never thought of the consequences of me putting that in my pocket will be. On my judgement night(the result announcement) my dad looked through my stuff to see if his seed had turned a junkie(only kidding,dad!), and behold was the flyer that said "Welcome to HELL!!". My old man  saw a chance for me to get back on my feat, and since I killed their dreams I had no say in his choice. On the next day ie.. the 24th we visited the campus. (on a side note: I never wrote the engineering entrance, my head was in my ass!!) and on the 28th we sealed my fate(took a seat for Computer Science and Engineering).

2. I took a room at their hostel and then on a new chapter begins. I didn't know what to do at the time, what ever I did I didn't want to repeat the things that happened, so blind folded I began gobbling  everything that was taught to me during the first year of the course. The only thing I truly appreciated was Mrs. Ann Romalt's lectures on "C is all that you'll need!!", she taught me what coding was and my code bug was because of her, thank you madam :D. Before that all i did was look at other peoples work and change it for my own(scripts only), this was because the primary operating system I used at home was GNU\Linux.(Laugh, a would-be doctor who likes to play with computers!! ). Anyways, when second year came up, my expectations were a bit high now that I have looked up what I have chosen for my poison(C.S.E was the cheapest and no capitation, that's why I chose it!!, at the time there was no reason to understand what the course was about.). I wanted to replace the emptiness of me not being able to take up medicine with me a "coding machine". More than anything I wanted to code and to "code great". But paper after paper I found nothing that would help me with this. Again, thinking that it'd turn out for the best I gobbled up the papers(bad tasting medicine)and steered my way to 3rd year. Now, I'm confused it's that time I prepared my C.V for getting a collar job, and I have nothing to add for my skill-set rather than an obsession for playing with Linux. I wanted atleast one programming language, so I decided f**k the system. I got out looked into stuff like python and javascript(far more easier and better languages for me atleast). For two months I laboured on day and night, but frequent exams at the college (I know it's not a reason) my endeavors were cut short. The uni exams are just a month away and I have nothing to write on paper. So there was no choice, I paused "My choice of learning" for the uni stuff. I borked and now i'm choking. i have no idea about any of the papers and I can't seem to gobble like I used to. Scary shit!! what happens next??

3. The single best thing that happened to me was that my brother Roshy M John gave my my first love kausalya. She's a dell inspiron 630m, a beautiful machine. He said to me "It brought me good fortune and made me who I'm now!" and he wanted that for me(domo arigato!). Windows xp was the choice since everything I had for work at college was on that platform, but I didn't want to leave my dope behind, So I dual-booted her with  #! Linux and Xp. But, soon found out that everything I did on windows could be replicated on linux(and i'm not talking of wine, good god these things pull in a lot of memory and my kausu is a gentle creature). So from #! i learned how to do a net-install of debian and for when I needed to click I fire up my dwm session on my debian-ised kausalya. Under 40 mb memory usage !!! compared to 150mb usage in xp(in idle), getting the driver's installed for wireless and all was a hassle but I enjoyed every minute of the trouble, now i'm happy :D

4. I'm a bit scared now, but the voices( my blockhead of a grandmother!!) tell me that it's going to be alright. Scared because my exam results are my way to redemption, and if I fail at that there won't be another chance to say to my parents that I'm sorry for the XII. So, I'm hitting the books again to climb that ladder.

P.S To those who think I'm falling behind because of some girl, "KISS MY ASS!!". God that felt good :D

~akts.

Thursday, July 5, 2012

First post after entering college.

On july 14th 2011, a brand new chapter unfolded, that was the first day of college for me (technically, it was a bridge course). I'm now a second year C.S.E student and have entered classes on 4th july 2012. I'm just writing this post since it had been a long time since i posted anything here.

I'm doing my B.E degree at Udaya School of Engineering.  It has been a blast- the first year experience. But, all the same the second year seems a lot harder, since it will be the first year where we enter into the computer engineering studies.

This blog will be filled with reminders and other stuff (not completely boring... I hope :) ) for the next 3 years.

Also this year I wish to bring a laptop to help me study (hmmmmm!!! ). Mine will be a Dell Inspiron 630m.
I'm planning to put in a dual-boot config of Windows xp and Crunchbang linux. Well, that depends on the need of the hour issue, but all the same, the laptop will be my one-way ticket to completing college life. Well more news will follow.

Oh!! by the way I forgot to mention that I'm writing this from the college computer. This day (6-7-2012) was our first netlab.

~akts