Imagine a scenario where you would prefer to type instead of clicking. That day would be epic. As a developer, it’s our job to use and spend time on command interface it can be shell, bash, or it can be a editor like vim, emacs etc. Lot of optimization has been made since the beginning of these things. Today i will specifically talking about shell/bash prompt.

We generally use 20% of the features available there, to attain maximum efficiency in long term it learning rest 80% will help tremendously. So let’s get down to business.

I. Using search in prompt

One can search through the commands one has previously typed. Just use

 Ctrl + R

, this would enable backward search such that one can search through logged commands.

II. Using alias for long commands or shortcuts

For this one needs to use .bashrc or .zshrc(more about this later) file in the

   ~/

directory which is

 /home/username

. There you have to add a alias <alias_name>=<your long command> for eg. for using p for python use

 'alias p='python'

now you can just use p python_script.py to run the python script, or you can add your ssh command to server ip,which are pretty long. Isn’t that handy!

III. Configuring rsa key for auto pushing to github/git network.

You might be typing username and password every time you want to push to github. There is an easy way to do this automatic. One need to paste the key from ~/.ssh/ directory, keep in mind the key ends in .rsa . If you have one already generated and configured with ssh-agent then paste the key in github profile settings under SSH realted area.

If you haven’t done it yet, do it by using key-gen utility

 key-gen -t rsa -C "your_email_id"

-t is for defining the type of key which rsa in this case -C is to providing commenting so that you can identify different keys for what we are using email id. then add generated keys to ssh-agent using

 eval "$(ssh-agent -s)"
ssh-add ~/.ssh/<key_id.rsa> '''

And then follow the procedure to add it on github profile Additonal link: github-ssh

IV. Using zsh instead of bash

zsh is an shell designed for interactive use, most of its features are from bash, so one can easily use as bash replacement.

  • One of most fruitful feature is one don’t need to type cd for changing the directory. Just type directory and enter & you are in directory.

  • Other feature is intelligent autocorrection, supposedly you made some type in case, zsh would auto correct it. For modifying the configuration use file at ~/.zshrc like adding alias or export or path. Additional link:zsh-link

V. Using oh-my-zsh framework for zsh

oh-my-zsh is most popular command line utility framework on github. It has premade zsh configuration which you would have to write otherwise in bashrc/zshrc files. you can use lot of themes from lot of community themes.

A screenshot of my terminal using oh-my-zsh is given below oh-my-zsh-screenshot Some useful mentions

  • I can see full path of my working directory

  • I can see git repository branch, i am working upon

  • I can see time stamp for each command

  • also if my git repos has been modified and there are uncommitment changes, i see all that on one terminal.

Isn’t that wonderful! Additional link:oh-my-zsh

VI. Mutliple tabs instead of mulitple windows

Lot of people bring a new command window for different task. Using tabs is recommended since you can switch easily and also see what is running on different tab.

Just use Alt + T for new tab and Alt + <tab_number for eg.1,2 > for switching the tab.

That’s all for now. For more detailed information follow the links provided in the post

Next time it will be productive while being python developer.

Problem ?

Problem arises when you don’t get to know why my program dysfunctional , inspite of correct logic . The problem may be with memory handling or in the thread handling . Learning syntax is half part , gaining proficiency is another part .

What exactly is memory management ?

In C/C++ assigning memory & handling threads can PITA until one reach a level of experience . Let’s go by an example:

#include <stdlib.h>

void bad_memory(void){

	int* array_alloc = malloc(20 * sizeof(int));
	array_alloc[20] = 10 ;
}

int main(void){

	bad_memory();
	return 0 ;
}

The above code has two errors . It doesn’t pops up during compilation and during execution . First one : assigning out of bound index of array_alloc a value i.e array_alloc[20] Second one : not freeing the allocated memory resulting in memory leak .

###Valgrind to rescue ! By definition : The Valgrind tool suite provides a number of debugging and profiling tools that help you make your programs faster and more correct. The most popular of these tools is called Memcheck. It can detect many memory-related errors that are common in C and C++ programs and that can lead to crashes and unpredictable behaviour.

To rescue onself run the executable using valgrind command

valgrind --leak-check=full ./a.out

The result is as following

valgrind --leak-check=full ./a.out
==25516== Memcheck, a memory error detector
==25516== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==25516== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==25516== Command: ./a.out
==25516==
==25516== Invalid write of size 4
==25516==    at 0x400512: bad_memory (in /home/rooted/Documents/git-repos/workshop/code/a.out)
==25516==    by 0x400522: main (in /home/rooted/Documents/git-repos/workshop/code/a.out)
==25516==  Address 0x51f2068 is 0 bytes after a block of size 40 alloc'd
==25516==    at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==25516==    by 0x400505: bad_memory (in /home/rooted/Documents/git-repos/workshop/code/a.out)
==25516==    by 0x400522: main (in /home/rooted/Documents/git-repos/workshop/code/a.out)
==25516==
==25516==
==25516== HEAP SUMMARY:
==25516==     in use at exit: 40 bytes in 1 blocks
==25516==   total heap usage: 1 allocs, 0 frees, 40 bytes allocated
==25516==
==25516== 40 bytes in 1 blocks are definitely lost in loss record 1 of 1
==25516==    at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==25516==    by 0x400505: bad_memory (in /home/rooted/Documents/git-repos/workshop/code/a.out)
==25516==    by 0x400522: main (in /home/rooted/Documents/git-repos/workshop/code/a.out)
==25516==
==25516== LEAK SUMMARY:
==25516==    definitely lost: 40 bytes in 1 blocks
==25516==    indirectly lost: 0 bytes in 0 blocks
==25516==      possibly lost: 0 bytes in 0 blocks
==25516==    still reachable: 0 bytes in 0 blocks
==25516==         suppressed: 0 bytes in 0 blocks
==25516==
==25516== For counts of detected and suppressed errors, rerun with: -v
==25516== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 2 from 2)

There are two errors : Heap error for invalid assign & Leaks relating lost memory .

Valgrind can also be misused to profile your code (pun intended ) Further Valgrind can also be used for Bounty programs (like google chrome).

Conclusion !

There are other tools for debugging like GDB which is very elaborate & pro-like . Apart from that Valgrind is there . As pointed out what’s better than finding out bugs as quickly without any pain .

Comments welcomed . Pros & cons ?

Brilliant jerks ?

So who are Brilliant jerks (someone awesome at coding/hacking?) Yes , they are top coder people , algorithmic strong and overrunning , specialist in their areas but with an collaboration problem with them . They get arrogant for their material and are blame gamers .

Philosphy !!

This philosphy is very much followed and applicable to startup culture and growth culture companies . Startup is not looking for brilliant geek but also for a team player , who can effectively communicate with the team and maintain the integrity. A culture where you don’t aim at others for the problem , a culture you believe in peer review system .

How to handle them?

The thing is one can’t just trust them the best way is just to avoid these people because it is very much important to preserve the existing resources and something which can go side by side with them . The collaboration part is most important .

Filtering out soon ?

So how one filter them out , it’s simple you can smell them out during the personal interview . Whether the person is trustful ,making false statement & commiting their own mistakes .

GROWTH IS DIMINISHED BY SUCH JERKS

Buzz word

Growth is buzz word in todays IT world especially startup world & culture, if one is not continously growing , that is endangering sign. Either someother company may take over you like the cases happened for Kodak. So growth hacking is like “MOVE FAST & BREAK THINGS”. One need to evolve and growt from/with the existing products and service. Its like branching out .

How to Growth hacking?

The hacking word isn’t misleading, infact it is the inspiration for the Growth Culture . It isn’t easy to continously Rise high & higher , so one need to do it either by hook or by crook . That all is matter to find way between the hurdles. So having a hackers way to do the stuff isn’t bad at all. Further this talent isn’t easily visible just through face to face interview generally & one can’t simple induce it just that . So just watch & observe precisely to find it .

Benefits

One may definitely argue and fight for the cons but the truth is Growth hacking or other alternative Productivity is addictive habit , one you are into it , one does go for it everyday & everytime. And ofcourse there are options to rollback if anything goes wrong .

Conclusion

Finding solution any-how is main motive ,it can done through being creative or just using the conventional methods.

Haskell is a functional language & very different from imperative langauges such as python,ruby,c++..etc . It is also called declarative language, the reason is simple one just describe the problem in the program instead of instructions on how to solve the problem .

Why Haskell ?

It’s just not the haskell , this is about functional language , equal importance is for the Scala . The main context for functional langauge is involvement of “Academia” , which other imperative language fails to bridge . It so much fun to learn mathematics and science using functional langauge .

Syntax

Syntax might seems very unconventional to conventional programmers , but it’s just for the good . Functional programming discourages mutable variable & does not allow reassignment to variable.

Haskel limelight:

"-- " is used for comments
let this = [ 1,23,42,97] -- 'this' represents variable name for the list
length this  -- length is a function
				--notice while passing arguments no brackets are used
let start = head this -- return the first element of list

let latter = tail this -- return list apart from head

let access = this !! 2 -- '!!' used to access element 2 tell the possition.
						--	ofcourse indexing begins with "0"

null this --null is function 'this ' act as argument will return true if argument is null

let loop = repeat 4 --repeat act as infinite loop and generate an infinte list
					--infinity concept is just kept in mind
let slice = take 2 this --slice first two elements from the list
let duplicate  = replicate 2 5  --finite loop for generating argument 'n' times


let append = x ++ y -- (++) appends two lists one after another

let two_dim = [[1,4,5],[2,9,7],[1,2,3]] --syntax for two dimensional list

let concatenation = concat two_dim --this would reduce two dimensional list to one dimensional by concatenating each sublist to single list

Well if you reached so far , won’t you like to evaluate yourself .

expandList :: [Int] -> [Int]
expandList lst = if null lst then [] else (replicate (head lst) (head lst)) ++ expandList(tail lst)

You have to guess the purpose of above function .

Put it in comment section .