Optimising Git workflow with Git Aliases

29 April 2014
Git aliases is a good way to save few keystrokes and improve your productivity. So, in this post I will show you how to improve your productivity with git aliases.

Optimising Git workflow with Git Aliases

To customize git commands, you need to edit .gitconfig file located in your home directory(valid for *nix system, not sure about windows). So, without further ado let's get started.

Open .gitconfig file with your favorite text editor.

subl ~/.gitconfig

Now inside this file add the following lines

    st = status
    aa = add -A
    cl = clone
    ci = commit
    df = diff
    br = branch
    co = checkout
    cob = checkout -b

Now you can use these aliases to save few keystrokes. For example you can use "git co feature_branch" instead of "git checkout feature_branch" to switch  to feature_branch, "git st" instead of "git status" to determine the current status of your working directory.

Now let's customize  one of  the most used git command i.e 'git log'.

lo = log

but this default log command is boring, so let's improve it.

lol = log --oneline

Much more use concise, but I'm not happy with formatting, so let's customize it even further.

lola = log --pretty=oneline --decorate --abbrev-commit -all

Looks good, but let's improve it even further with --graph option.

lola = --graph --pretty=oneline --decorate --abbrev-commit-all

git log ailas lola

Cool! You can even customize it even further with colors and more information like auther name, email, time etc.  Use this guide to customize it even further.

It would be nice to set an alias to list all the alias, so let's do it. Add following line in your .gitconfig file.

la = "!git config -l | grep alias | cut -c 7-"

Now running "git la" will list all of your git aliases. That's it. Are you using git aliases to improve your productivity? If so, then let me know what's your favorite git alias.

Reference: https://git.wiki.kernel.org/index.php/Aliases
Read more ...

Basic Skills Every Good Programmer Should Have

15 March 2014
A first year CS student asked for career advice, even though I'm a terrible person to ask this question I have some advice for every aspiring Computer Science student and programmers in general.

Intended audience: Aspiring Computer Science students and New programmers.

So, without further ado, let's make a list:
1. Learn to Type Properly: As basic as it seems, it's quite common to see people typing inefficiently. As a programmer, you will be typing as much as you can throughout your career and it would be impossible to improve your productivity if you don't know how to type properly.

2. Learn to Read: If you are not a good reader, then you probably won't be a good programmer either. How to be a good reader? Read as much as you can. Read blog posts, read comments, read new and interesting books about the topic of your choice(as a programmer you should choose Programming books). Prefer Ruby? find a recommended list of Good Ruby and Ruby on Rails Books.

3. Learn to Write: As a programmer, you are required to interact with other programmers, customers, higher authorities etc. and more often than not you will be communicating with them over email, so writing is one of the must have skills. How to improve your writing skills? Leave a comment or two on your favorite blog post, start participating in relevant discussions, and finally start blogging.

4. Learn to Learn: I know it sound silly, but it's not. Learning is the most important skill every programmer should have. You should learn how to learn interesting technologies quickly and efficiently. Be a good learner.

5. Learn to Think: This is the hardest skill you'll ever acquire. It's not easy to learn how to think because no one will tell how to think you just have to learn it by yourself. Learning "how to think" can be hard and time consuming, but don't get frustrated by it, in time you'll get better. Progress is more important than anything.

6. Learn how to use Google and other search engines: This is the most important skill for programmers. Googling is probably as important as learning debugging and understanding error messages.

7. Learn when to use Google, when to ask for help, and when to stop programming: Errors are inevitable and you as a programmer should know when to to Google, when to ask for help and when to stop programming.

8. Learn how to stop Procrastinating: Procrastination is a normal habit among programmers and don't get frustrated when you find yourself procrastinating for no reasons. We all procrastinate, learning when to stop procrastinating is another skill every programmer should have.

9. Learn to Read & Understand Error Messages: Whenever you get an error message, try to understand what these error messages are trying to say. Error messages aren't there to scare you, but to help you, and you should be able to understand these messages and act accordingly.

10. Learn how to get Help: You are supposed to get stuck, if you are not, then you probably are not working hard. Getting help is another important skill that every programmer should have. How to get help effectively? Ask good questions, twist your question and make it more general, Use Google and StackOverflow, hangout on IRC etc.

Have fun improving yourself and always remember this.

one does not simply become a programmer overnight

PS: Because I'm a fan of short and concise blog post I'll elaborate each point in a separate blog post.
Read more ...

Recommended Books for Ruby and Rails Developers

27 February 2014

I was planning to write this post for a long, long time, but procrastination won't let me. I finally wrote this post. What's the point of writing this post? Well, lots of people ask for a recommended list of good Ruby and Rails book, so in order to DRY my efforts I had to write this post, so that I can point them here.

So without further ado, let's make a list.


1. Learn to Program by Chris Pine: If you need a gentle introduction to Ruby, then this is the best book for you. The online version of this book is free, and you can read it here.

2. Programming Ruby 1.9 & 2.0: This is more of a reference book than a tutorial book, so be prepared to dive into the details. Also, this might be the only Ruby book you'll ever need.

3. Eloquent Ruby: This is definitely one of the best programming book I've ever read. The book is so concise and easy to read that anyone who is blessed with little to no knowledge of Ruby can finish it within 24 hours.

4. Practical Object Oriented Design in Ruby: This book is all about writing changeable code. Code that will be easy to change without being the pain in the ass. Sandi will show you code that sucks and isn't easy to change and replace it with more elegant and changeable code.


5. Learn Ruby on Rails by Daniel Kehoe: This book is for absolute newbies, but if you are a more advance developer who is new to Rails you will be tremendously benefited from this book: After reading this you will be ready to learn and understand more advance books like Rails Tutorial.

6. Agile Web Development with Rails 4: This is one the best book for web development and is so interesting that I read it cover to cover(well almost). If you are new to Ruby and Rails then you should start with this book instead of starting with Ruby on Rails Tutorial by Michael Hartl.

7. Ruby on Rails Tutorial: If you are serious about Ruby on Rails, then you will read it couple of times. This book is filled with useful information. Michael Hartl will teach you web development by building sample application(Twitter Clone).

8. Ruby on Rails Guides: I know this isn't a book, but it is available in the mobi(kindle) version. Yay!

9. The Rails 4 Way: This book has been recommended so many times by so many good developers that I had to include it and to be honest, I've not spent enough time on this book to comment on its content.

10. The RSpec Book: If you are interested about testing the behavior of your application, then this is the only book you'll ever need. This book is more about BDD than Rspec

11. Pro Git: This is by far the best Git book out there, plus it is freely available in pdf, mobi and epub formats. This book is easy to read, easy to understand (via visual representations) and is so concise that you'll understand it in one read even if you are an absolute newbie. Also available on amazon.

12. The Bastards Book of Ruby if you are interested in web scraping and stuff.

Recommended Order for Rails developers: 1, 5, 6, 7, 8, 10, 11, 3, 2, 4, 9, 12 or something similar to this depending on your preference.

If I had you start over today, then I'd blindly follow this list.
Read more ...

Gmail will Show Images by Default

14 December 2013

From now on Gmail will automatically show you images in your messages. This is a killer feature. Why is that? because from now on your emails won't look like a complete crap because of default email behavior. Google will render images without asking for your permission.

Wait? showing images without permissions? what about my privacy and security? an attacker might send harmful content via images? what about that? Fear not Google is deliberately solving this problem. In the next paragraph I'll tell you how.

So, how Google is doing this without compromising my Security?
what is happening here is that the Google is caching every image on their secure proxy server to protect you from any harmful content. This way an attacker won't be able to harm your device. How cool is that?

I usually don't write blog posts about these things, but I found it so awesome that I could not resist myself :D

Here's how my emails looks like.

Now my emails don't suck. Thanks you Google.
Read more ...

How to Install Ruby on Rails on Windows

17 November 2013
Some of my friends keep asking me the same question "How to Install Ruby on Rails on Windows". So, I'm writing this post to save myself some time in the long run.
(If you are using Ubuntu then just use this Guide by Ryan Bigg)

Head over to Rails Installer and download "Ruby Installer" for appropriate Ruby version and also download Devkit.

Things to remember while installing Ruby via Ruby Installer:
1. Select "Add Ruby executable's to your PATH": This option will let you execute ruby files from command prompt.
2. Select "Associate .rb and .rbw files with the ruby installation"

Now double click on Ruby Installer and follow the instructions.

Install Devkit
1. Double click on devkit and extract to c:\devkit
2. Now open command prompt and change the directory to install path cd\devkit
3. Now run ruby dk.rb init
4. ruby dk.rb install

Installing Rails
1. Type "gem install rails" in command prompt
2. md c:\apps
3. cd\apps
4. rails new myRailsApp
5. rails server

Done. Congratulations you have successfully installed Rails and created a new Rails application.

By the way if you run into "JavaScript Runtime environment missing" error then just install Node.js
Read more ...

Keyboard Shortcuts I use to enhance my Productivity

9 October 2013

I'm not a big fan of using mouse to perform every other task. So, I challenge myself to use keyboard for almost everything to enhance my productivity. Here is the list of keyboard shortcuts I use to enhance my productivity.

OS Ubuntu:
1. Alt + Tab to switch between running programs.
2. Alt + ~ to switch between windows of existing program.
3. Ctrl + Alt + Arrow keys to switch between workspace.
4. Ctrl + Alt + T to open terminal.
5. Ctrl + Shift + Alt + T to open new window of the terminal.
6. Super to open HUD.
7. Alt + F10 to open the indicator menu.
8. Ctrl + Shift + Alt + Right(or any Arrow Key) to move current window to another workspace.

1. Ctrl + L to clear the current terminal screen(same as typing clear and hitting return key).
2. Ctrl + u to clear current line.
3. Ctrl + a to move the cursor to beginning of line.
4. Ctrl + e to move the cursor to end of line.

Browser(Google Chrome):
1. Ctrl + T to open new tab.
2. Ctrl + Shift + N to open incognito window.
3. Ctrl + Shift + B to access bookmark bar.
4. Ctrl + Shift + T to open previously closed tab.
5. Ctrl + L to select URL of the existing web page.
6. Ctrl + #number(1 to 9) to switch to tab based on ascending order.
7. Ctrl + Shift + I to open chrome Developer tool.
8. Ctrl + Shift + Del to delete browsing data.
9. Ctrl + O to open a file from local storage.
10. Ctrl + W(or Ctrl + F4) to close current tab.
11. Ctrl + D to bookmark current web page.
12. Ctrl + pageDown/pageUp to switch to next/previous tab.

Sublime Text:
1. Ctrl + P to open any file in existing application.
2. Ctrl + KB to toggle sidebar
3. Super + Alt + N to create new file/directory(You need to install AdvancedNewFile plugin).
4. Ctrl + W to close the file.
5. Ctrl + enter to  insert new line after.

Here's the best keyboard shortcut tip by Actual Advice Mallard.

Use Ctrl+Shift+T to re-open a closed tab

PS: I'll keep updating this list.
Read more ...

Back to Ruby: Learning Ruby for Rails

6 September 2013

I  have been learning Ruby on Rails since last 2-3 weeks, I've finished first two chapters from michael hartl's book, and I'm close to finishing 3rd chapter. The learning curve is very steep and tremendously awesome! I've learned a lot in last 2-3 weeks.

Now that I've decided to dig deep into the world of Ruby on Rails, I've only one thing in mind i.e. learn Ruby. Give Ruby the time it deserves.

How Am I gonna approach Ruby?

1. Learn Ruby The Hard Way

I've read first 15 exercises of Learn Ruby The Hard Way and I'm already liking it.

Nice things about Learn Ruby The Hard Way:
1. Write Code: Zed Shaw really make you write exercise codes instead of copying and pasting. Writing code is an excellent way to understand the syntax of the language.

2. Study Drills: Zed Shaw forces you to perform study drills at the end of each exercise like adding helpful comments, solving similar problems, searching for relevant terms etc.

3. Comments: Each exercise has it's own comment section where users discuss their problems. Unfortunately the comment section is closed, but it's still useful.

2. TryRuby.Org by CodeSchool

I've already completed this short course and I'm planning to revisit to make more sense. The course is completely free, but you have to sign up for CodeSchool. If you haven't signed up for CodeSchool then go and do it now. 

Good thing about TryRuby.Org by CodeSchool:
1. Fast Pace: The course moves very rapidly and you can finish it in 20-30 minutes.

2. Learn by Doing: Each level contains several challenges which you have to complete in order to move to next level. You have to write code by following the instructions giving on the left hand side, and that's the best thing about this course.

3. Learn to Program by Chris Pine

The online version of this book is completely free and contains 12 short chapters. You can go through the entire book in about an hour depending on your understanding skills.

4. Rails flavored Ruby by Michael Hartl

This is fourth chapter of Michael Hartl's online Ruby on Rails book. you can finish this chapter in 1-3 hours depending on your understanding skills.

Fort Newbies the path should be 2-3-1-4.

Additionally you can try the Ruby track on CodeCademy. 

That's it. My next target should be completing Michael Hartl's online Ruby on Rails book and finishing minor college project on Ruby on Rails. 

As always let's finish off with a Meme

Want to add anything? feel free to leave a comment.
Read more ...