GotchaCode

Happy New Year 2014

A very happy new year to all the readers of this blog. To start with, I would try to publish a post at least once a week so that it may satisfy your appetite on a regular basis. Also, I am meditating about something new on this blog. It will be revealed when the time comes. With that said, have an amazing start to the year.

Using HTML5 localStorage Into Your App, Check ldb.js

Last night, I was hacking on a small utility library for use when using HTML5 localStorage. When you work with localStorage, it often gets into repetitive state when use use same command again and again. This library just abstracts the process and makes things easier for you. It would work on all modern browsers.

/**
* Ldb.js
* Copyright(c)2013 Vinit Kumar
* MIT Licensed
*/

var Ldb = function () {};

/**
* [check Checks for localStorage support on the browsers]
* @return {[String]} [status of localStorage Support]
*/
Ldb.prototype.check = function () {
if (!localStorage) {
return 'Please use a Modern browser, your browser does not support localStorage yet';
} else {
return 'Bingo, your Browsers supports localStorage, phew!';
}
};

/**
* [get Gives the data stored in the key]
* @param {[String]} key [Key to retrive the data stored in localStorage]
* @return {[JSON]} [The JSON data stored | Error message saying no data stored with that key]
*/
Ldb.prototype.get = function (key) {
if (localStorage.getItem(key)) {
return JSON.parse(localStorage.getItem(key));
} else {
return 'No such key exists, Are you sure you have saved data with the key?';
}
};

/**
* [set Saved data in the localStorage database]
* @param {[String]} key []
* @param {[JSON]} value [The JSON data that gets stored in the localStorage]
*/
Ldb.prototype.set = function(key, value) {
if (typeof (value) === 'object') {
var stringValue = JSON.stringify(value);
localStorage.setItem(key, stringValue);
return 'Successfully saved your data to the key' + key +' key!';
}
};

/**
* [remove description]
* @param {[String]} key [Key for the data to be deleted]
* @return {[String]} [Status message for the remove operation]
*/
Ldb.prototype.remove = function(key) {
if (localStorage.getItem(key)) {
localStorage.removeItem(key);
return 'Successfully removed data with the key'+ key +' !';
} else {
return 'No such key exists, nothing to remove';
}
};



This is all code for the utility as of now. More features are going to flow in coming weeks. Also, you can just install it using 'npm install ldb' or 'bower install ldb.js'. The code is Open Sourced here. https://github.com/vinitkumar/ldb.js

How To Focus And Learn One Thing Perfectly?

In Software development, there are so many things to learn. Especially, if you are web developer there are so many things to learn. Should you learn Rails, Django or .NET? Or should you learn Angular, Backbone or Ember?

It is a very tricky question and has been puzzling me for quite sometime. But some time back, it kind of dawned on me that I should just try and own one technology at one time. Say if it's Django try and learn everything about Django. Become the best in your company at Django. The benefits are two fold:
- You will have a stable career and you will be happy with the quality of your work.
- You can use that understanding of that technology with understanding and learning other technologies really fast.

Another problem that I sometime face is lack of motivation to learn if something gets really tough. I learned that instead of setting a super tough goal, I should rather split it up and own it one by one. First of all, it gives me a sense of achievement and confidence. Also, my whole effort would be on completing that goal with best of my abilities.

The things I said above is not rocket science, but if you are at my stage of learning. It might be useful to you.


With that said, May the Force be with you!

                ____                  
_.' : `._
.-.'`. ; .'`.-.
__ / : ___\ ; /___ ; \ __
,'_ ""--.:__;".-.";: :".-.":__;.--"" _`,
:' `.t""--.. '<@.`;_ ',@>` ..--""j.' `;
`:-.._J '-.-'L__ `-- ' L_..-;'
"-.__ ; .-" "-. : __.-"
L ' /.------.\ ' J
"-. "--" .-"
__.l"-:_JL_;-";.__
.-j/'.; ;"""" / .'\"-.
.' /:`. "-.: .-" .'; `.
.-" / ; "-. "-..-" .-" : "-.
.+"-. : : "-.__.-" ;-._ \
; \ `.; ; : : "+. ;
: ; ; ; : ; : \:
; : ; : ;: ; :
: \ ; : ; : ; / ::
; ; : ; : ; : ;:
: : ; : ; : : ; : ;
;\ : ; : ; ; ; ;
: `."-; : ; : ; / ;
; -: ; : ; : .-" :
:\ \ : ; : \.-" :
;`. \ ; : ;.'_..-- / ;
: "-. "-: ; :/." .' :
\ \ : ;/ __ :
\ .-`.\ /t-"" ":-+. :
`. .-" `l __/ /`. : ; ; \ ;
\ .-" .-"-.-" .' .'j \ / ;/
\ / .-" /. .'.' ;_:' ;
:-""-.`./-.' / `.___.'
\ `t ._ / bug
"-.t-._:'





What Is Information Overload And What To Do About It?

Each one of us uses one Social Network or another. It was fine in the earlier days when it was connecting you to your long lost friend, colleague or someone you knew. But do we realize what it is doing to us now?

We are being subjected to information overload and that too in the worst form. There are endless stories about all the stuff that doesn't even matter to us. We are being fed so much about our friends that we are not even interested to know about them anymore. Sharing every crap that happens in your life is a common norm and anyone who doesn't stick to it is dated. 

Well, that fact is, we should just shut this information overload and take control of our life. We don't really need to be subjected to this and become depressed and deprived people. Life has better meaning than all of it. We are born to do great things in life and not being sucked into this emotional and depressing wormhole that these Social Networks are creating.

With that said, not all of the Social Networks are bad. Some of them like Twitter and Google+ gives us the option to minimise the intrusion of this excess information. So take a stand and control what kind of information gets to you. Clean up your friends and following list. Follow only those person and group you are really passionate  about. Pick up some nice offline activity, meet some nice people , play some music, watch sunrise or sunset, start running etc. There are so many nice things to do. So just shut up laptop/tablets/smartphones and get some life people!