Javascript : Non blocking / Async example

/**
 * Created by Aseem on 12/7/16.
 */

console.log("1: Start app")

var slowProcess = setTimeout(function(){
    console.log("2: app processing async - non blocking ");
},1000);

console.log("3: Exit app")

 

The out of this is non blocking, which mean the flow will not wait  or get blocked for slowProcess

Sample console output

➜ async git:(master) ✗ node nonBlocking.js
1: Start app
3: Exit app
2 : app processing async – non blocking

 

Motivating story – Honesty Pays

At the point of death a man, Tom Smith, called his children and after praying for them, he advised them to follow his footsteps so that they can have peace of mind in all that they do.

The youngest child, Immaculate, a female, looked at others and yeled, “Daddy, its unfortunate you are dying without a penny in your bank account, personally, I can’t emulate you. Other father’s that you tag as being corrupt, thieves of public funds left houses and properties for their children; even this house we live in is a rented apartment, sorry, i can’t emulate you, just go, let’s chart our own course, let’s paddle our own canoe.”

Few moments later, their father gave up the spirit.

Three years later, Immaculate went for an interview in a multinational company. The interview panel had already penciled down a candidate for the highly coveted post but wanted to complete the formality of interviewing all applicants on the list.

As soon as Immaculate sat before the interview panel, the Chairman of the committee asked, “Which Smith is yours” and
Immaculate replied, “I am Immaculate Smith. My Dad Tom Smith is now late he died a poor man…”

But the Chairman cuts in, “O my God, you are Tom Smith’s daughter? ”

He turned to other members and said “This Smith man was the one that signed my membership form into the Institute of Chartered Administrators and his recommendation earned me where I am today.

He did all these free. I didn’t even know his address, he never knew me from Adam. He just did it for me.”

He turned to Immaculate, I have no question for you, consider yourself as having gotten this job, resume tomorrow, your letter will be waiting for you.

Immaculate Smith became the Corporate Affairs Manager of the
company with two cars, one official and one for private use, attached to the office, with a duplex and two drivers and a salary of £100,000 per month excluding allowances and other costs when she travelled outside England.

After two years of working in the company, the Group Managing Director of the company came from America to announce his intention to resign and needed a replacement. A personality with high integrity was sought after, again the company’s Consultant nominated Immaculate Smith.

In an interview, she was asked the secret of her success and the sudden sky rocketing profile and in tears, she replied, my Daddy paved these ways for me. It was after he died that I knew that he was financially poor but stinkingly rich in integrity, discipline and honesty.

She was asked again, why she is weeping since she is no longer
a kid as to miss her dad still after a long time.

She replied, “At the point of death, I insulted my dad for being an honest man of integrity. I hope he will forgive me in his grave now.

I didn’t work for all these, he did it for me to just walk in.

So finally she was asked,” Will you follow your father’s foot steps as he requested?

And her simple answer was, “l now adore the man, I have a big picture of him in my living room and at the entrance of my house. He deserves whatever I have after God.

Are you like Tom Smith?
It pays to build a name, the reward doesn’t come quickly but it will come however long it may take and it lasts longer.

Integrity, discipline, self control and fear of God makes man wealthy, not the fat bank account.

Leave a good heritage for your children.

Are you building a good name for your children not a fat bank account?

As an agent of CHANGE, please share this true life story with your loved ones. God bless us all.

GIT : Generate git Ignore file using online tool -> gitignore.io

Hi Friends,

When we create project using IDE like eclipse, web storm, intellij, a lot of additional files shows up other then required code base. Best practice is to add “.gitignore” file, mention the pattern of (non required) files and commit it. That way git will ignore those file and will not track any changes for those file.

To generate the pattern, you can take help of below online tool, this will give you .gitignore file which can be added and used.

https://www.gitignore.io

Go Lang : Setting up Go lang on Mac using brew

Install go by brew on Mac

Install golang by brew. I think that’s the easiest way to install go on OS X.

$ brew install go
==> Downloading https://downloads.sf.net/project/
machomebrew/Bottles/go-1.4.yosemite.bottle.ta
############################################# 100.0%
==> Pouring go-1.4.yosemite.bottle.tar.gz
==> Caveats
As of go 1.2, a valid GOPATH is required to use the `go get` command:
  http://golang.org/doc/code.html#GOPATH

`go vet` and `go doc` are now part of the go.tools sub repo:
  http://golang.org/doc/go1.2#go_tools_godoc

To get `go vet` and `go doc` run:
  go get golang.org/x/tools/cmd/vet
  go get golang.org/x/tools/cmd/godoc

You may wish to add the GOROOT-based install location to your PATH:
  export PATH=$PATH:/usr/local/opt/go/libexec/bin
==> Summary
?  /usr/local/Cellar/go/1.4: 4557 files, 134M

Set Path for Go

Go needs paths for his root directory. I wrote like that.

# .zshrc
# go
export GOROOT=/usr/local/opt/go/libexec
export GOPATH=$HOME/.go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

It is actually religious problems how people set $GOPATH and $GOROOT. Let you set them up to your belief.

Run Tiny Program

To test, run tiny program of Hello World.

~/workspace
▶ vi hello.go
// hello.go
package main
import "fmt"

func main() {
  fmt.Printf("Hello, world!")
}
~/workspace
 go run hello.go
Hello, world!%

Now it’s working well!

Python : List of Python Tutorials

If you are looking for a single list of python tutorial, then you landed on a very good blog post.

Learn Python online – A curated list of courses on Python

Here is the link : http://bafflednerd.com/learn-python-online/

This will allow you to try our different python courses available online.