Uncategorized

To “Gulp” or to “Grunt”

Hello "Blog"!

Well, the answer is what you prefer! 🙂

Both of these are great tools to automate the tasks for your application. Both have great plugins and allow the developers to really speed up their development cycle by integrating some very cool plugins to automate your process. For instance code analysis, linting, minification and many more, but the question is what would you choose?

Here are some high level differences:

GruntGulp
Matured.

More support and bigger community.

More than 5000 plugins.

Relatively newer.

Lesser number of plugins

File based

Each task input/output spins up hard-disk as the results are stored in the hard-drive. Multiple tasks require multiple disk read/writes.

Stream based

Gulp uses in-memory streams to run multiple tasks sequentially. Therefore only the final output results in disk activity.

Might perform slower when there are multiple tasks configured.Relatively faster due to in memory processing.

Configuration over code.

Tasks are configured…

View original post 228 more words

Standard
Uncategorized

Quick intro to Git – Part I

Hello "Blog"!

Hello friends!

Lately I was challenged and given an assignment to consume some source code hosted on GitHub and contribute to it by performing few given tasks. I, being pretty new to Git spent few hours over internet and trying to figure out how does this thing work. I had no prior knowledge on it and given the fact that of my past experience has been on Microsoft technologies I was actually little scared. 🙂

But, let me tell you, i felt much better when i completed that challenge. Although I must admit that despite being a simple challenge it was still daunting to me.

Anyways, I felt that it would be kind of nice to share my experience and may be help others to understand about git.

What is Git?

Git is an open source project that has a great community support and a solid user base. If you are an open source developer then Git is probably a first class requirement for you…

View original post 562 more words

Standard
Uncategorized

== vs ===

JavaScript language provides two comparison operators for comparing the equality of the two values. It sometimes can cause a big confusion to the execution of the code if it is not clearly understood how these internally works. I’ll try to explain these differences using some examples.

Type Coercion

Type Coercion means that when the operands are different types, one of these operands will be converted to an equivalent value of the other operand’s type. This comparison is mostly done to a number. This implicit conversion process is known as Type Coercion.

For example: ‘2’ == 2 returns true.

‘==’ equality operator

A.k.a. loose equality operator and are considered evil by some. They are evil because syntactically the code would just look just fine but the output of the comparison could be something like unexpected. Here is the reason why this unexpected behavior can happen. == Operator tries to implicitly convert the type of one of the operands to a common type and then doing the comparison between them. Java-script would not complaint about the types mismatch but try to smartly do type coercion and present a result. Few developers find it scary and it can cause various bugs into the system. Consider following examples and see for yourself what this can cause:

1 == 1 //returns true;

1 == ‘1’ is executed as 1 == ToNumber(‘1’), hence 1 == 1 // returns true

‘1’ == 1 is executed as ToNumber(‘1’) == 1, hence 1 == 1 // returns true

undefined == null // returns true

new String(“”) == true//returns true because an object is always true

“” == true //returns false because empty string is considered false

“” == false //returns true because empty string is considered true.

Above mentioned examples apply to all condition constructs in JavaScript for example an ‘if’ statement.

‘===’ equality operator

A.k.a. strict equality operator would also take into account the data type of the operands before doing the comparison. It will simply return false if the types are different. In case of objects, the instances being compared should refer to the same instance to be truthy.

Here are some examples:

1===1   //returns true

1===’1’ //returns false

“” === false //returns false

 

Standard
Uncategorized

Quick intro to Git – Part III

In this article I am going to show you how to play with branches and merges.

Create branch

As shown in previous article, I was working on the master branch. GitHub gives you the flexibility to create branches and allows you to cherry pick your changes to be merged back to your main branch. So lets make a new branch:

On your repository, you will see a pull down button showing you the current branch as master. Click on it and type name for your new branch. I called this Feature1. Click on the blue bar that says ‘Create branch: Feature1’.

createnewbranch

Clicking this will create a new branch Feature1 from master. You will see all your files in your branch (I know i have one file only :)). Clicking on the same button should show a tick mark against ‘Feature1’, which means you are now in Feature1 branch.

currentbranch

Clone branch locally

What i am doing here is that the Feature1 branch code is being cloned into a new folder called TestRepoFeature1.

C:\work\amar\Code\TestRepo [master =]> git clone https://github.com/amarsingh19/
TestRepo.git -b Feature1 ../TestRepoFeature1
Cloning into '../TestRepoFeature1'...
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 6 (delta 0), reused 6 (delta 0), pack-reused 0
Unpacking objects: 100% (6/6), done.
C:\work\amar\Code\TestRepo [master =]> cd..
C:\work\amar\Code> cd TestRepoFeature1
C:\work\amar\Code\TestRepoFeature1 [Feature1 =]>

Make edits

Now I am going to make some changes to FirstFile.txt such that it looks like this:

This is first file.

Version 3

Branch: Feature1

Next lets do commit and push the changes.

git add FirstFile.txt

git commit -m "Feature1 first commit..."

git push -u origin Feature1

and voila! If you check your repository on GitHub Feature1 branch should get updated with your changes.

Merge Feature1 changes to master

To initiate the merge, you will have to submit a New pull request to the owner of the original repository. Pull request is something like you’re requesting the owner of the repository to review your changes and merge into the main branch. You can do so by clicking on the button highlighted:

pullrequest_button

Since I am the owner of the original repository, I see below screen

merge_step1

Click on the ‘Merge pull request’ button:

merge_step2

Click on the ‘Confirm merge’ button. At this stage you can delete this Feature1 branch.

merge_step3

Now lets check what happens to the main branch. Open FirstFile.txt and notice the contents have been merged from Feature1 branch.

master-updated

This completes one complete workflow of creating a repository, branching and merging the changes back to the main branch. I hope I was able to provide good information here.

 

Standard