Stop procrastinating! How to prevent it.

Still trying to stop procrastinating?

stop procrastinating

There are probably numerous days that you site behind the computer to do some research or get some work done and doing a short break to read some news or check social updates and as you done this you aren’t aware that time passes as you jump from one link to another while the time is passing by rapidly. You have probably tried many things, like avoiding to use those sites, setting time aside for short breaks or some other solution but every time you spend more time doing nothing than to spend that time into something productive.

My way of curbing procrastination time to minimum

You probably procrastinate as everyone but you don’t do it so efficiently, there are many ways to curb this behavior especially with avoiding reading the news updates all the time. We live in an era of information overload and we developed a habit of a need to be constantly updated with latest updates.

I am using few tools which are completely free of cost for basic usage you will need to prevent procrastination. Here is how I do it:

I have installed self control app on my computer and you can get it at this link. It is free of cost. Basically what it does is that you add a list of web sites that you want to block for a selected period of time.

You are probably wondering now which pages should I add to this blacklist. Well the obvious sites should be the social networks. Most of the links we click to other sites are coming from there to funny videos or interesting stories. There are ton of these sites, but major one should be Facebook, Twitter, Google+ etc. Though have in mind if you develop for social network logins you have to keep alert to remove them for that period otherwise you can do no related work to it for that day. Other useful list of sites that need to be blacklisted are on your history list in your favorite browser. Go through the history and check all the sites that shouldn’t be there during your work hours and add them to the list.

Next step is to add time inside self control for how long it should be blocked. First advice never do mistake and set it over 24 hours. Perfect time to set the limits is 10-12 hours. You would probably say I don’t work so many hours and I agree you mustn’t but from the time you set the time and all other chores you need to do during the day believe me that is the most optimal time especially if you are working for yourself or being in a startup environment. It is dynamic over the day so keep on tracking your time that way.

So next step is to activate the self control and you magically stop procrastinating. Wrong. Keep on reading.

Continue reading

AngularJS ngInclude directive and scope inheritance

ngInclude directive and scope

There are many times when you want to include a html snippet code from another file but preserve the scope of it. It is usually when you have different form fields for the various objects and you want to have a global controller that oversees the updating of different forms. So if you want to take the quickest route and use ngInclude directive you would be surprised that it is not properly linking to your controller and you cannot access the form instance.

This is due to ngInclude internals and how they work. ngInclude creates for each use as a new child scope so overwriting anything inside the new included HTML file content will be written into child scope and not in the one you’ve anticipated to be. So there are few workaround around this as creating a new object inside the scope for example

$scope.data = {}

inside the controlling controller and then in the imported html file set values inside the

<input type="text" ng-model="data.name"/>

This works if you don’t have a problem with static value being inserted into all html files, but if you want maximum flexibility then this is not the perfect solution. So after inspecting the source code inside ngInclude.js, I have seen a room for improvement and created a similar directive to ngInclude called ngInsert, which instead of making new child scope it inherits the current scope and continue using it inside. You can pick up the whole source code at this gist. You can use it in the same manner as existing ngInclude. Continue reading

Extending Javascript objects with a help of AngularJS extend method

Multiple ways of extending javascript objects

/**
 * One-way reference from subclass to superclass (instance)
 * Most of the time this is what you want. It should be done
 * before adding other methods to Subclass.
 */
ChildClass.prototype = new SuperClass();
 
/**
 * Two-way reference
 * Superclass will also get any Subclass methods added later.
 */
ChildClass.prototype = SuperClass.prototype;
 
/**
 * Cloning behavior
 * This does not setup a reference, so instanceof will not work.
 */
angular.extend(ChildClass.prototype, SuperClass.prototype);
 
/**
 * Enhancing a single instance
 * This could be used to implement the decorator pattern.
 */
angular.extend(subClassInstance, SuperClass.prototype);
Quote

Be that likable person

Become genuinely interested in other people.

Smile.

Remember that a person’s name is to that person the sweetest and most important sound in any language.

Be a good listener. Encourage others to talk about themselves.

Talk in terms of the other person’s interests.

Make the other person feel important and do it sincerely.

Smile, smile, smile :)

AngularJS directive multiple element

How to get AngularJS directive multiple element

You probably know there exists opening ng-repeat-start and finishing directive ng-repeat-end like:

<ul>
 <li ng-repeat-start="user in users">
   {{user.firstName}}
 </li>
 <li ng-repeat-end>
   {{user.firstName}}
 </li>
</ul>

You would think it is a specially made directive that works that way but actually it is not. It is part of any directive so you can use it inside your too. When you create new directory and inside you factory function you need to return an object with multiElement options set to true. This way it will behave same as ngRepeat directive over multiple non nested fields. Small excerpt from ngRepeat.js file denoting this:

var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) {
  ...
  return {
    restrict: 'A',
    <strong>multiElement: true,</strong>
    transclude: 'element',
    priority: 1000,
    terminal: true,
    ...
   }
}];

From native angularJS directive there are few more directives that support multi element spanning. They are ngIf, ngShow, ngHide and ngSwitch. So by adding multiElement to your custom directive you can make to transclude over angularjs directive multiple elements at the same time. This also comes handy because you can do nesting of multiple elements if they are contained inside another one.