Include Laravel Facades in test coverage report

Image above is taken borrowed from

Recently i rewrote my project to use Laravel’s facades. So far so good, but i noticed most of code is skipped from test coverage report which is not good in anyway.

Turned out that i need to test the model (LogModel) itself and not the facade (Log).


public function test_adding_returns_item_with_new_id()
        $input = array('type' => 'a', 'text' => '1', 'data' => '2');
        $data = MySuperProject\Shared\Log::save($input);
        $this->assertEquals(2, $data->id);

turned into

 * Testing MySuperProject\Shared\LogModel instead of MySuperProject\Shared\Log 
public function test_adding_returns_item_with_new_id()
        $input = array('type' => 'a', 'text' => '1', 'data' => '2');
        $data = MySuperProject\Shared\LogModel::save($input);
        $this->assertEquals(2, $data->id);

to make things bit more assuring, i added a test to see if the facade returns the model as expected:

    public function test_Log_Facade_returns_LogModel(){
        $instance = new MySuperProject\Shared\Log;
        $this->assertEquals('MySuperProject\Shared\LogModel', get_class($instance->getFacadeRoot()));


7 steps to fix you phone if it doesn’t find 3G mobile network

Few days ago my HTC lost 3G connection (Disconnected because service is unavailable) and first i thought its broken. I remember the salesperson who was explaining (dis)advantages of HTC/Apple/Samsung – he mentioned that lot of people bring HTC One’s to service centers due to 3G malfunction.

But before rushing to the service center and loosing my phone (they will rip it, loose it, crash it, blame me for it and charge 50EUR afterwards), i decided to do my own investigation online.

So. We have a phone that has fully working WiFi, but refuses to connect via 3G. What do do to dododo do (proceed to next step inly if previous fails :D or just go to the step 7)

  1. Restart phone.
  2. Turn on and off Airplane mode (might sound silly because restart didn’t help, but that was exactly my case)
  3. Update software (Apps->Settings->About->Software Updates)
  4. Check that LTE is not enabled (set to App->Settings->Mobile data->Network mode -> GSM/WCDMA auto)
  5. Remove Access Point Names ant set them back in App->Settings->Mobile Data->Access Point Names. (if you don’t understand what are you doing ask your service provider to do it).
  6. Ask your wife (kid, friend, neighbour) to swap phones and try his/hers SIM card in your phone and your SIM card in their phone. If their SIM works, ask your service provider to replace your SIM card.
    If their phone works, try again in your phone (maybe disassembling “solved” the issue)
  7. Take it to the service center.
Screen Shot 2014-03-17 at 07.24.28

AngularJS + HighCharts + Draggable line

I received a fun-task – to make a chart. It was all fun before i summed up requirements:

  1. chart has to be responsive
  2. it should support drag-n-drop on _some_lines
  3. it should be superfriendly with AngularJS

First i wanted to use Flot for charts, but only draggable example/plugin I could find was from 2009. Which makes it 5 years old.

Then i rememeber Highcharts. And thanksgod highcharts is two things:

  1. Highcharts is draggable
  2. Highcharts is angular-friendly (there are many directives out there, but i found this one most friendly so far)

Last thing to do was join both together in JSFiddle.  And voila!

How to add comment to the JSON file

Have you ever opened a package.json or bower.json and wondered – whyyyyy is that there and whaaaaat was this for? And then thought - How do i add a comment in package.json for future ‘me’?

JSON is industry standard, and as for me, it should stay such. It is clean, compact and does not rely on indentation. Therefore it follows the rule of “writing code for humans, not machines”.

The only problem so far is – where do i put comments. For example, after I installed via the Bower the latest underscore.js version, i (and others too) noticed that underscore-min.js is removed.

OK, i found that i should add a underscore version in bower.json and package with -min version will be installed.

    "name": "My Super-Duper App",
    "version": "1",
    "dependencies": {
        "underscore": "32216a4afe97c0c3665897b58be73409d5571dcf"

Ach, cool, after bower install the ‘-min’ is included again. But how do i leave the note to myself why i am i having such a weird version there.

Perhaps i could use /* */? But no, JSON is all about the content, not comments. And I agree to that. When i receive a message (object) i have my own intentions towards using it. It is nice that you tell me what this information is about (this is what ‘RTFM’ stands for), but if i want to take your “int” and convert to “string”, i have all rights to do it.

Still, what do i do with UnderscoreJS now? If i cannot post a comment, why don’t i add my own key inside:

    "name": "My Super-Duper App",
    "version": "1",
    "dependencies": {
        "underscore": "32216a4afe97c0c3665897b58be73409d5571dcf"
    "comments": {
        "dependencies": {
            "underscore": "Remove version once -min version is in package again"

There you go, you have a nice comment property in bower.json. And it is your comment you can format it as you wish.


90 minutes in 50-70%. Hell on earth

A while ago i took the health test and Herr Docteur said i should focus on low HR workouts (50-70% from HRMax). I didnt listen to him and didnt do anything about it because running slow is booriiing. Soon i stopped running at all.

Now, when i am training for the marathon, i see great deal of these low heart rate workouts in my plan. And yesterday was first day – 90 minutes of 130 bpm run (a1/z2/a2 depending on the brand). Imposssssibru!

Luckily, my wife was running with me so the race wasnt hell on earth, but close enough.

I still dont understand my heart – i can run 2h with pulse of 180, but even 10min with 130 is the last thing i want to see in my todo list.


Date Weight Workout Distance km Pace min/km Feeling
2014-02-02 88kg 01:37:45 8.19 11:56 Iii-mmm-ppp-ooo-sss-iii-bbb-lll-eee
2014-02-01 88kg 00:38:53 2.45 15:53 Stupid snow
2014-01-31 89kg 00:39:42 3.37 11.47 Where is my beer

Get a Life. Restarted.

So i got myself a new sports watch. And how do we celebrate a new sports watch? With a run. riiight. And what is the temperature outside right now? -10°C Should we run? Of course?

Last year was very interesting. I trained for a half marathon, then i hit the runners plato. Then i didnt train for 2 months and made another half marathon. Then i again didnt run and made 10k on christmas. This must be put to the stop.

Now i am fat. I am 1.81m high and weight 89kilo which is at least 10k more than i want. Fat moron. I think i should print out my supersize belly and put as a wallpaper on computer background, maybe then i will get better.

So. This is a new year, new resolutions. I have a plan. Garmin plan. To do a marathon in 16 weeks. And today was the day 1.

Date Weight Workout Distance Pace Feeling
2014-01-31 89kg 30m 3km (waaat?!) 10:21 min/km Where is my beer

Install LAMP on Lubuntu

1. Open terminal and install LAMP (mind the gap caret ^ )

sudo apt-get install lamp-server^

This goes very smooth (takes about 116Mb). Only input from you is the MySQL password for the root user.

After installation:

  • web root is in /var/www
  • php.ini is /etc/php5/cli/php.ini
  • mysql configuration is in /etc/mysql/my.cnf

Install Node.js, Karma, Grunt and Bower on Lubuntu

I make this as a guide to set up new dev machine on clean Lubuntu machine.

Assumption: Everything here is written with assumption that reader is familiar with terminal, apt-get, sudo, etc. Otherwise, feel free to google away.

1. TL;DR;

sudo apt-get update;
sudo apt-get install -y python-software-properties python g++ make;
sudo add-apt-repository -y ppa:chris-lea/node.js;
sudo apt-get update;
sudo apt-get install nodejs;
sudo apt-get install curl;
curl | sh;
sudo npm install -g grunt;
sudo npm install -g grunt-cli;
sudo npm install -g karma;
sudo npm install -g bower;

2. Install Node JS
At the time of writing this, latest Ubuntu version is 13.x Saucy Something and node version in package manager still seems to be 0.6 (which as ancient as leaded 76 octane petrol). But according to this source there is one reliable-ish repo where you can get it.

sudo apt-get update;
sudo apt-get install -y python-software-properties python g++ make;
sudo add-apt-repository -y ppa:chris-lea/node.js;
sudo apt-get update;
sudo apt-get install nodejs;

3. Install Node Package Manager

 NPM comes via curl and Lubuntu doesn’t have it installed by default. So curl should be feteched along the way.

sudo apt-get install curl;
curl | sh

4. Grunt

sudo npm install -g grunt;
sudo npm install -g grunt-cli;

5. Bower

sudo npm install -g bower

6. Karma

sudo npm install -g karma

That’s it.

Screen Shot 2013-12-30 at 00.45.32

Grunt watch fails on Mac OS X Maverick

TL;DR: upgrade node to v0.10.21

I upgraded to maverick yesterday and along with disastrous reset of php.ini and httpd.conf i also experienced failing grunt watch.

edgars@Freyr ~/D/n/s/server> grunt watch
Running "watch" task Job 1, 'grunt watch' terminated by signal SIGBUS (Misaligned address error)

Solution was trivial – update node as well.

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

Which resulted in node update to v0.10.21 (was v0.10.20)

edgars@Freyr ~/D/n/s/server> node -v