best practices

Working with temp files in Ruby

Temp files are necessary in cases when you need to store some data before feeding it into another program. In this post, I am going to show you several ways of creating temp files and how to use them in Ruby code. Temp files or temporary files are files created…

Working with temp files

Tempfiles are necessary in case you need to store some data before feeding it into another program. In this post, I am going to show you several ways of creating temp files and how to use them in Ruby code. Temp files or temporary files are files created at a…

Understanding things inside ~/.ssh

We have been using SSH all the time but not all people really understand the files we put inside the ~/.ssh folder on our computer. It was a myth to me when I was first using SSH, but things are pretty clear to me now and I want to share…

Funny issue with "grep"

The other day I was working on a simple program on CentOS and I met an issue which turned out to be quite funny. At first I didn't think it worth a post here, but later I decided to put it here so that I won't ever make the same…

Execute command remotely via SSH

Working as a web developer, you will eventually get familiar with server configuration, like how to setting up Nginx or Apache, how to check production logs, how to tune server for better performance, etc. Almost all of those things are done via SSH. In the past, I had to log…

Git rebase or Git pull?

A few days ago, one member in my lab and I were about to finish a project together. We also used git server for sharing code and collaborate. However, when I used combination of git fetch, git stash, git rebase and git stash apply to fetch new code, he said…

Tips for debugging your production web app

Running the app in development or staging environment is a lot easier than production environment. There are so many unexpected factors which make your application unstable in production, such as a high number of concurrent users, lots of queries to database, etc. And when something go wrong on production app,…

Using git bisect to find bad commit

Today, I am going to introduce a technique to easily find out the first bad commit in your git repository. With this technique, you can save a lot of time debugging a code introduced by certain commit. Let's get started! First, assume that we have the following commits in our…

Gem Idol: Friendly Id

This week, I would like to introduce a gem which is being used in almost every project I have been working on. And it becomes more important for us nowadays because everyone want their website to be SEO efficiently. Link: https://github.com/norman/friendly_id Developed by: Norman Clarke…

Gem Idol: Figaro

Today, I really want to start something different which I believe would be very helpful to new Rails developers. I remember the time when I first came to Rails world, I was impressed with its amazing community and gem ocean. I could find almost every thing I needed which has…

Several tools to monitor your Rails application

After your Rails application is deployed to server, there would be tons of things could happen to your app which you have never expected when running the app in your local environment. In that case, you definitely want to have a tool to support you monitoring the application and quickly…

You should always commit Gemfile.lock and schema.rb

One of common mistakes I see with new (and some experienced) Ruby on Rails programmers is that they do not commit Gemfile.lock and schema.rb very often to source control version such as Git or SVN. I personally think that it is generally bad practices and we should commit…

How to configure SSH for multiple Github accounts?

Note: I only refer to Github in this post but this method can be applied to any Git servers (such as Bitbucket, Heroku, etc) If you work with Github for a while, you would realize that there are two kinds of links for you to work the Git repos: HTTPS…