Yii : route config for subdomains

April 29th, 2015 § 0 comments § permalink

Recently I was setting up a subdomain for a existing project, I needed to configure a different root route for the it. First I tried to do it with htaccess but I failed. Then I found a solution after some googling.

// protected/config/main.php
    'urlManager' => array(
      'urlFormat' => 'path',
      'showScriptName' => false,
      'caseSensitive' => true,
      'rules' => array(
        'home' => 'site/index',
        'http://about.site.dev/' => 'about/index',

This will result in two different root route for site.dev and about.site.dev. I you know a better solution please let me know.

ubuntu : custom battery notification settings

October 25th, 2014 § 0 comments § permalink

By default in Ubuntu the battery discharge notification was set based on remaining time. The remaining time was never accurate nor even near of prediction which caused sudden shutdown or hibernate while working. The only work around the internet was suggesting was to set the notification for percentage of battery remaining instead of time remaining.

Setting notification for percentage remaining.
Since these settings are in Dconf, we may need dconf-editor to makes this easier. I have explained how to install dconf-editor in Ubuntu : Add applications to system tray blog post.

After installing open the dconf editor and navigate to following path in tree sidebar.

org -> gnome -> settings-demon -> plugins -> power

, or you can try to find “battery” and reach the same.

Then update the following settings,

critical-battery-action : The default action to take when battery is empty. Set the critical-battery-action to hibernate if available.

percentage-action : At what percentage of battery OS should take the default which is set just before. I set it to 5.

percentage-critical : At what percentage of battery you need to get the critical notification. I set it to 10.

percentage-low : At what percentage of battery you need to get the first notification for battery low. I set it to 20.

And finally,

use-time-for-policy : Uncheck the checkbox.

Thats it. you are done. You can either restart the system or logout and login back for the changes to take effect.

Unit next time.

Ubuntu 14.04 systray fix

October 22nd, 2014 § 0 comments § permalink

In Ubuntu 12.04, we need to whitelist application to show in systray, but Ubuntu 14.04 removed the systray whitelist settings from DConf. This caused issues for applications like xchat, parcellite etc.

System Tray

System Tray with Xchat

Even though I found lot of solution while googleing, the only one worked for ubuntu 14.04 is,

sudo apt-add-repository ppa:gurqn/systray-trusty
sudo apt-get update 
sudo apt-get upgrade

If you don’t want to update the whole packages, you can try installing only the following ones,

sudo apt-get install libunity-core-6.0-9 unity unity-services

After installing you need to either logout and login or restart your computer. Now the applications likes xchat can be easily minimized to system tray and open when ever you want.

Ubuntu: Convert video to audio in CLI

October 5th, 2014 § 0 comments § permalink

Converting a video on Ubuntu is pretty easy with avconv. If you don’t have avconv command in your PATH, you need to install libav-tools

sudo apt-get install libav-tools

After installing avconv,

avconv -i /input-file-name-with-path output-filename.mp3

This will convert your video input file into mp3.
-i option is used to indicate the input file.

You can use --help for more help and details options.

Install erlang on ubuntu

October 5th, 2014 § 0 comments § permalink

Using Apt

Installing erlang on ubuntu is quite easy with apt.

sudo apt-get install erlang erlang-doc

Now you can enter into the interactive prompt using erl command and compile with erlc

Build from source

If you want erland 17.0 or latest, you may need to build erlang from the source, I highly recommend to use @bryanhunter‘s build-erlang-17.0.sh gist. It worked for me on Ubuntu 14.04. This gist will install all the dependencies needed for erlang 17.

You can download the file, give executable permission and run as sudo user.

  wget https://gist.githubusercontent.com/bryanhunter/10380945/raw/build-erlang-17.0.sh
  chmod u+x build-erlang-17.0.sh
  sudo ./build-erlang-17.0.sh

Install haskell on Ubuntu

October 4th, 2014 § 0 comments § permalink

As I thought of learning some functional programming, I started out with Haskell

In ubuntu you install via apt.

sudo apt-get install haskell-platform

This will install GHC(Glasgow Haskell Compiler), GHCi(GHC’s interactive environment) and cabal.

Try Haskell

You can try haskell using GHCi. Type ghci on command prompt and you will enter into its interactive environment.

GHC's interactive environment

GHC’s interactive environment

Congratulations, You are in. Now the prompt is Prelude>, if you can change this into ghci> by typing :set prompt "ghci> " , But that’s totally optional. You can try some basic arithmetic operations over GHCi.

Now if you wanna exit from this interactive environment, you can type in :quit. You can also type :? in GHCi for help or other options.


Cabal is a package and build system.It is only used to build packages. Where as Cabal-Install will help you to install and manage your Haskell libraries.

If its a first time you might need to run cabal update which will download the most recent list of packages available in Hackage.

Cabal Update

Cabal Update

Cabal will look for a .cabal file in the present working directory. If you don’t have one you can use cabal init to create one interactively.

Cabal init

Cabal init

Cabal can install packages only from hackage and should be build with cabal.


Hackage is a online repository of Haskell packages.

Git : Delete remote tag

April 18th, 2014 § 0 comments § permalink

Here is how you can delete a git tag in the local and remote repo. It is pretty similar how we delete remote branch.

To delete tag locally use

git tag -d v1.0.0

To delete tag in the remote repo

git push origin :refs/tags/v1.0.0

Thats it.
Thank you.

HAML : Using variable in JavaScript block

February 10th, 2014 § 0 comments § permalink

While I was getting started with HAML templating, everything went fine until I need to use a HAML variable inside a JavaScript block. I hope you may familiar with JavaScript block in HAML like below.

  var a = 10;

But what if that variable a is a HAML variable and I need to use  inside the :javascript block? I had no idea how to do it, so went for some googling. The result yeilded was pretty amazing and easy. I just need to interpolate the variable as we do string interpolation in ruby.


That’s it you are done. Now you are using a HAML variable inside the :javascript block.

Pretty easy right?

Configure ace editor

February 10th, 2014 § 0 comments § permalink

While I was working on my latest side project, I though of using ace editor for syntax highlighting and code styling. But, configuring editor was bit confusing for me. There was a bunch of CDN links of ace editor available on the site, But didn’t have much information about which one I should use. I tried some of them but didn’t worked for me. At last after some googling, I got the below solution.

I started with defining a div for the editor.

<div id="editor"></div>

Now I need to add the ace editor script, the script worked for me is the one given below.

<script src= '//d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js'></script>

At last need to configure the editor, as you needed

var editor = ace.edit("editor");

You can configure the editor as you need, I set the mode as json for my application. You set it as ruby, php, etc.. as you need.


Mongodb : Install on Ubuntu

December 12th, 2013 § 0 comments § permalink

As part of getting started to NoSQL DB’s I thought of trying out MongoDB.


Installation was quite easy. Here is how I installed mongoDB on your ubuntu.

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
sudo apt-get update
sudo apt-get install mongodb-10gen

Thats it, installation is over.

Start mongoDB

The mongoDB is setup with upstart, so you can start the service with the following command

sudo service mongodb start

Explore CLI

You can enter into mongoDB CLI to explore more, just type mongo in your terminal

mongoDB CLI

mongoDB CLI

Everything is fine. But when I do unclean shutdown sometimes, mongoDB service won’t start automatically. So after each unclean shutdown I need to do remove the lock file and start service manually.

sudo rm /var/lib/mongodb/mongod.lock
sudo service mongodb start

Happy exploring mongoDB.