Sticky Bootstrap Popover

The word “sticky” is to describe a behavior that a popover will keep open while the mouse cursor is over it. This is a common sense behavior but not supported in bootstrap. I’ve searched github issues and stackoverflow questions but none of those solutions works.

So I made a fair easy fix. A live example can be found here.

This writing is based on bootstrap v2.3.1.

Posted by Cheng Guangnan on Apr 25, 2013

Install Ruby native libs on Ubuntu

This is been tested on Ubuntu 12.04.1 LTS.

apt-get install build-essential
apt-get install zlib1g-dev
apt-get install libxml2-dev libxslt1-dev
apt-get install libmysqlclient-dev
apt-get install libsqlite3-dev
apt-get install libssl-dev
  • zlib1g-dev is required by gem bundle
  • libxml2-dev libxslt1-dev are required by gem nokogiri
  • libmysqlclient-dev is required by gem mysql2
  • libsqlite3-dev is required by gem sqlite
  • libssl-dev is required by rails

Note:

  • Ideally you won’t need to read this post. rvm requirements should provide whatever you need. But things aren’t always working. It’s nice to have an redundant.
  • Ideally you would be able to work with a Fedora where things are better named as mysql-devel, sqlite-devel, etc.

Posted by Cheng Guangnan on Jan 14, 2013

Command line tool for Google Refine

This is a command line tool to help you upload csv or tsv files to Google Refine from the command line.

It’s written in Ruby and distributed via rubygems. It can be installed from:

gem install google_refine

Now the executable upload-to-refine will be available in your command line. The usage is:

upload-to-refine [FILE]

You could pass some options as well:

upload-to-refine [FILE] --host remote_server:3333
upload-to-refine [FILE] --header-lines 1
upload-to-refine [FILE] --limit 1000

Posted by Cheng Guangnan on Jan 13, 2013

Setup PHP with Nginx on Fedora 17

spawn-fcgi

yum install php-fpm

open /etc/php-fpm.d/www.conf, replace "apache" to "nginx"

chkconfig php-fpm on
service php-fpm start

nginx

location ~ \.php$ {
  include /etc/nginx/fastcgi_params;
  if ($uri !~ "^/images/") {
    fastcgi_pass 127.0.0.1:9000;
  }
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

wordpress

(I don’t like wordpress, but if you have wordpress installed at /blog, here is how to make it work with nginx and php)

location /blog {
  index index.php;
  try_files $uri $uri/ /blog/index.php?$args;
}

Posted by Cheng Guangnan on Jan 02, 2013

Load American Community Survey data into PostgreSQL

U.S. Census Bureau releases the ACS data in a complex format in the purpose of make it accessible from desktop softwares like Excel.

Developers are having a hard time to figure out how to re-construct those files into an intuitive state. Thanks Lee Hachadoorian whom made it and shared it on github.

I’ve use Lee’s work to import the ACS 2010 into PostgreSQL successfully. Thanks Lee!

Posted by Cheng Guangnan on Jun 10, 2010

Happy Fish with RVM and Git

fish_prompt

Revised with rvm 1.18.18 on January, 2013

There is a minor change, check this commit.

Original post

I enjoyed Fish shell. But it was having problems with RVM.

The RVM website provided a wrapper of the bash command rvm which works mostly okay but won’t active RVM until you type rvm in the shell. New shell sessions will still use the system Ruby by default.

It did take me sometime to figure it out that let’s just simulate the typing by add the following line to “~/.config/fish/config.fish”.

rvm > /dev/null

Then I found that the wrapper doesn’t support all the functions. For example, rvm current will not return the current active Ruby version.

The reason that I wanted rvm current is to use that in the shell prompt to show me the active Ruby version. Hey! I can just use ruby --version for that!

There is one more thing. Now under Fish rvm use may give you something like below.

set: Could not add component ~/.rvm/gems/jruby-1.6.7.2/bin to PATH.
set: No such file or directory

My tip is that just create the folder.

Now I can use Fish as the main shell. Nothing left behind.

My Fish config code for RVM is loaded to Github. Go check it!

Posted by Cheng Guangnan on Jun 09, 2010