Homebrew: How to start and stop background services

Anyone that has installed application running in the background from Homebrew, knows how to use launchctl that actually runs every application when the computer restarts. It is pretty straight forward task but most of the time you need to know the location of the .plist file that defines how to run it installed with homebrew.

Now there is a quicker path how to control them by simply adding following package to home-brew:

brew tap gapple/services
 And you have available to start, stop services directly from home-brew with following command to get a list of active services:
brew services list
So for example if you have installed postgresql you can start it as a background service with:
brew services start postgresql
or stop the service with
brew services stop postgresql

Which is much more easier and simpler than finding the right .plist file inside cellar folder of brew

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 “Stop procrastinating! How to prevent it.”

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 “AngularJS ngInclude directive and scope inheritance”

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);

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.

How to record iPhone screen

To record iPhone screen has never been easier

Developing great new iOS application requires not just a usable application, but also a great video presentation of it. How it works, basic usability tricks to make users want to get your new application which you spent numerous hours to make it perfect.

If you are working alone on next big thing or inside a small agency or team and you probably have a limited budget to outsource your video production one of the hardest parts was shooting the actual content from iOS device, whether it is iPhone or iPad. Until now you could use some kind of recording of iOS simulator or using airplay method to sync the video. It worked but it was somehow clunky experience and you needed to buy extra software.

With the release of Mac OS Yosemite version everything has changed. Now you can record you iOS device screen directly without buying additional software whatsoever. All you need to have the computer upgraded to Yosemite version and an iPhone or iPad to latest iOS 8. iOS device needs to connect to your computer through lighting cable.

Continue reading “How to record iPhone screen”

AngularJS and Ruby on Rails work together

Finding the best integration of AngularJS and Ruby on Rails

Recently I got really excited with AngularJS so to make it work perfectly with Ruby on Rails there are some configurations needed. There are available blog posts on how to integrate it perfectly but somehow I wasn’t happy with the available preferences. Some offered to add the javascript files manually to the project and to manual project organization, others offered some kind of gem packager or even automated as a rails app template.

My goal is to describe how to start new rails app project from the scratch but the instructions should be succinct enough to be able to reuse them for the existing project (Actually I did extract it from the existing application I am working on). For the front end development I recently discovered great gem that really can make it more closer to pure full stack javascript development.
Bower is a great javascript package manager by the people who are working on Twitter Boostrap. It is like Bundler but made for javascript instead of ruby language. When I found out that there is a ruby gem that is integrated with rake tasks so I can easily update all javascript libraries without needing adding gem library for each one. The gem is called bower-rails.

My initial plan is to evolve this post into a series of blog posts on how to develop a fully functional demo application so I’ve included some steps that are might not needed but are good to have. Don’t worry I will provide explanation why I am using each of them.
Here is my plan what I will try to achieve with this series of posts:

  • creating a new demo project with angularJS from scratch, showing all my changes along the way, and trying to explain every step. this will include creating basic rails 4 app
  • adding basic gems
  • setup front end development with Bower
  • adding angularJS
  • implementing basic Rails and AngularJS controllers

Continue reading “AngularJS and Ruby on Rails work together”