All posts by Ramesh Jha

Start Unicorn on reboot in a Rails application

If you need to run some cron jobs on server, check out the ruby gem whenever. It lets you write cron jobs in ruby way. You can do lots of useful thing using whenever, create database dumps/backups, run scripts/commands on reboot etc.

Using whenever to start unicorn on reboot

1. Add whenever to your Gemfile and run bundle command.

gem 'whenever', :require => false

2.Writing a simple cron job
Move to the project directory and run

wheneverize .

Now, open the file config -> schedule.rb and remove the default contents. Add these lines instead. (you need to replace unicorn_app with whatever you’ve defined in your nginx config)

If you use capistrano for deployment, you should add this to config/deploy.rb.

require "whenever/capistrano"

Next time, you push the code to the server, it will create the required cron jobs on the server. Make sure, it’s working as expected and let me know (via comments) if you’ve any issue.

Check for open ports using this free tool : Port Checker

Few weeks ago I created a tool : port checker – that checks for open ports. It’s a simple web app built using Sinatra (a lightweight framework in ruby) and Foundation (an advanced front end framework), over a weekend.


More about this little web app

It simply checks for open ports on your computer (useful in testing port forwarding setup or security reasons obviously). You need to specify the port number and IP Address (optional, it selects the origin IP by default, so it’s not required unless you want to scan for other device or server IP). Then it tells you whether the port is open or closed.

Later I also added a port scanner, so it can scan for some common ports (~20) in a single click. (However it restricts the IP address to origin to prevent any misuse)


  • simple and easy to use
  • mobile friendly design (thanks to the Foundation framework)
  • online port scanner (I may add some other features like port range scan or so, based on the suggestions on HN)

Note : It’s a web app intended for casual use. If you need a more comprehensive tool for scanning ports or security audits, then you should check out Nmap (or Zenmap if you prefer to use graphical interface over the command line), a free and open source tool for network scanning.

PS If you find the tool useful or have any suggestion/feedback, let me know via comments.

Getting started with Android Studio on Ubuntu/Linux (14.04 LTS)

Android Studio is the new development environment for Android (officially recommended). It’s based on IntelliJ IDEA (Integrated Development Environment from JetBRAINS).

android studio

You can still use Eclipse IDE though (however, it may not be supported once the Android Studio comes out of beta) but Android Studio brings lots of new features and improvements (Advanced Android code completion and refactoring, multiple APK generation, Maven based build dependencies etc), so lets set up Android Studio on Ubuntu/Linux. (tested on Ubuntu 14.04 LTS (64 bit Intel Machine))

1. Install JDK 6 or later

First, install Oracle JDK 8 (although you could also choose OpenJDK but it has some UI/performance issues) using WebUpd8 PPA.

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo apt-get install oracle-java8-set-default

To make sure, it’s installed successfully, open a terminal and type (you should get the version number of the jdk you’ve installed e.g javac 1.8.0_11)

javac -version

2. Download and install Android Studio

Download the Android Studio package for Linux and extract it somewhere (e.g home directory).
Then type :

cd android-studio/bin

3. Install SDK Platforms

You need to install some SDK before you jump into building android apps. Click on Configure -> SDK Manager to open Android SDK Manager. Select the latest API (to test against target build, e.g API 19 (Android 4.4.2)) and some packages in Extras (Android Support Library and Android Support Repository). Then install the selected packages.

That’s all. Now, the development environment is ready :-)
If you need some help then learn Android development at TreeHouse or checkout official docs.

Upgrading to Ubuntu 14.04 LTS

Ubuntu 14.04 “Trust Tahr” is released and It’s time to upgrade.

Step 1. Backup

Backup all the important files/configs/ etc. The upgrades usually go smooth but that doesn’t mean you shouldn’t have backup ready, in case anything goes wrong.

Step 2. Disable proprietary drivers

Remove proprietary binary drivers for graphic cards (Nvidia/AMD) etc as the linux kernel version will change in 14.04, the older graphic drivers may not work. So, it’s better to uninstall them before upgrade and reinstall after upgrade. And reboot the system.

Step 3. Start Update manager

From Ubuntu 13.10, it should be available in update manager. Just type

sudo update-manager

and follow the upgrade instructions.

From Ubuntu 12.04 LTS, you need to provide -d option for force upgrade (until, it’s officially available in next few months (until 14.04.1), by July/Aug 2014) :

sudo update-manager -d

And you should see 14.04 available in update manager.

update manage ubuntu 14.04

Click on “upgrade” and follow the instruction. And of course, you should reinstall any proprietary drivers if removed earlier.

Note : If you don’t see the message “New Ubuntu Release ‘14.04’ is available”, then you may need to check settings and enable the option that says : notify me about new ubuntu version for long term support version.

Ubuntu 14.04 LTS is released!

Ubuntu 14.04 (code named as Trusty Tahr) is released.  It’s a LTS release, so, it will be supported for next 5 years (the earlier LTS edition (12.04) was released two years ago). If you move from LTS to LTS (as I do, for primary development environment), then it’s time to upgrade.

Download Ubuntu 14.04 LTS

What’s new in Ubuntu 14.04 “Trusty Tahr” ?

In the latest Ubuntu 14.04 Desktop edition, the default desktop environment Unity has improved a lot. Now, you can easily change menu bar settings to windows title bar instead of top menu bar, It also supports  high DPI screens and text scaling as well, Improved screensaver and locked screen etc.

So, before switching to alternate desktop environment like Mate/Cinnamon or GNOME, you should give it another try. You may like it. Although, new version of GNOME (3.12) will also be available soon.

Here are some other changes/improvements in this new release.

  • Ships with Python 3 by default, although you can easily install python 2 from the package
  • Linux Kernel 3.13
  • Updates and new features for AppArmor
  • Newer version of Upstart (1.12.1)
  • Latest version of LibreOffice (4.2.3) with lots of new features
  • New Xorg display driver (15.0)

Read official release notes for more details and if you also want to know about the new features for Ubuntu 14.04 LTS Server edition.

Parallelly, other flavors of Ubuntu 14.04 are also available. So, if you don’t like the default desktop environment (Unity) in Ubuntu 14.04 LTS, then check out these editions :