Kaleem Ullah's Blog

Show total label only in bar chart

Posted in Rails, Ruby by Kaleem Ullah on December 19, 2011

To Only show Total label in bar chart, We just need to enable stackLabels on y-axis.

yAxis: { title: { text: 'Thousands' },
stackLabels: {
enabled: true,
formatter: function(){
return this.total


Remove untracked files from git repository

Posted in git by Kaleem Ullah on August 10, 2011

Lets say you added 5 new files in your repository and for some reason you don’t need them anymore and want to remove.

There is a magic command which will work for you which is

git clean [options] [path]

There are some useful options available with this command.

1) --dry-run: It will not remove anything, just show what would be done
2) -d: Remove untracked directories in addition to untracked files.
3) -X: Remove only files ignored by git
4) -x: It will remove ignored as well non-ignored files by git.


git clean -f -x
git clean -f -X

(If the git configuration variable clean.requireForce is not set to false, git clean will refuse to run unless given -f or –dry-run.)

Tagged with: , , ,

Configure haml & factory_girl as default generator in Rails 3

Posted in Rails by Kaleem Ullah on August 10, 2011

Rails 3.0 didn’t provide facility to set haml & factory_girl as default generators but these can be set via 2 gems.
Its very simple to add those.
In Gemfile, add

gem "haml-rails"
gem "rails3-generators"

In config/application.rb,

config.generators do |g|
g.fixture_replacement :factory_girl, :dir => 'spec/factories'

(I assume you already installed haml, rspec-rails, factory_girl_rails gems)

That’s it. Now if you generate scaffold then by default you will have views as haml and fixture as factory.

Install dnssd gem on ubuntu

Posted in Gems, Rails by Kaleem Ullah on May 16, 2011

If you got following error during dnssd installation

checking for dns_sd.h... no
unable to find dnssd header
*** extconf.rb failed ***

then you have to install few libraries:
sudo aptitude install libavahi-compat-libdnssd-dev

Tagged with: , , , ,

github theme to Vim

Posted in git by Kaleem Ullah on January 29, 2011

Do you love github syntax highlighting theme? If yes, then you can apply that theme also on your vim.

1) Download file: http://www.vim.org/scripts/download_script.php?src_id=12456
2) create “colors” directory at ~/.vim/
3) Copy github.vim (downloaded file at Step 1) to /.vim/colors/

cp github.vim ~/.vim/colors/


ref: http://www.vim.org/scripts/script.php?script_id=2855

Tagged with: ,

Class of an object

Posted in Ruby by Kaleem Ullah on January 28, 2011

In ruby, There are commonly 3 ways to test the class of an object.

1) instance_of?(class)
It will only test the immediate class of object.

n = 1
n.instance_of?(Fixnum) #=> true
n.instance_of?(Object) #=> false because Object is superclass of 'n' not the immediate one.

2) is_a?(class) OR kind_of?(class)
Both is_a? and kind_of? will return true if object belongs to immediate class or superclass.

n = 1
n.is_a?(Fixnum) #=> true
n.kind_of?(Fixnum) #=> true
n.is_a?(Object) #=> true

3) ===
Same like is_a? but different in syntax as this one’s look good from readability point of view.

Fixnum === 1 #=> true

Important thing is === is non-commutative

1 === Fixnum #=> false

That’s it.

Tagged with: , , , , ,

git autocompletion

Posted in git by Kaleem Ullah on January 17, 2011

Now you can auto-complete git commands. But how?

1) Save below file into your home directory

2) Add below line into your .bashrc file
source ~/git-completion.bash


3) Restart Terminal

You can see more details for configuration in above mentioned link.

Ruby String Interpolation

Posted in Ruby by Kaleem Ullah on January 10, 2011

The string interpolation in ruby is defined as ‘evaluation of any expression(and conversion to a string) in another string’. Like

str = "String";

"This is #{str} interpolation" => This is String interpolation

As you noted above, # and {} needs to evaluate expression in a string.

Only in double quotes string literals  an expression can be evaluated.

If there is any global, instance or any class variable, then there is no need of curly braces {}.

For Example

@hrs = 24

"There are #@hrs hours in a day."   => There are 24 hours in a day.


Mongrel on Rails 3

Posted in Gems, Rails by Kaleem Ullah on January 9, 2011

Are you sick with Webrick? Install Mongrel on Rails 3.

In Rails 3, We need to modify app/Gemfile with

gem 'mongrel'

Next,  install gem

bundle install

and you will see following output(my case)

Installing fastthread (1.0.7) with native extensions
Installing mongrel(1.1.5) with native extensions

After successful bundling, your application ready to run on Mongrel.


Tagged with: , ,

Qoum hai Quran sai

Posted in Inspirational words by Kaleem Ullah on September 21, 2010

Soum hai Iman sai, Iman rukhsat soum ghum

Qoum hai Quran sai, Quran rukhsat qoum ghum