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…

Must-have Chrome extensions for Web Developers

As a Web developer, we always look forward to building the best web applications. But things do not always go well with developers. Users nowadays ask for better UI, better UX. An inappropriate color for a link or a wrong position of an image on a website could become annoying…

Resolve issue "No Qt bindings could be found" on Git-cola (OSX)

I am using OSX and I wanted to install git-cola for manage my Git projects. Unfortunately, after installing python using brew, I could not run it. When typing git cola to terminal, I kept getting the following error message: Traceback (most recent call last): File "/usr/local/bin/git-cola", line…

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…

Using "flex" property in CSS to define webpage layout

Designing a flexible layout which can scale to different screens on many devices is non-trivial. We often use float, position: absolution or other properties to achieve the desired result. However this process is uncomfortable to developers and we always dream of a better way. Today, I want to introduce to…

UNIX commands for daily tasks

UNIX is a base OS for many popular OS you are using right now, from Linux to Mac OSX. Those OS share common commands so it is pretty easy to switch from one OS to another. Because it is so important to understand and use UNIX commands, I want to…

Using PhantomJS to serve HTML content of Single-page App

One big drawback of Single-page application is the ability to fully support SEO as traditional sites. The reason is because in a single-page application we often use a technique called lazy-rendering, in which the real content is not rendered from the server but only the basic layout is returned. Many…

View printers information on Mac OSX

Do you know that there is a hidden feature in Mac OSX which allows you to view information of all printers added on your Mac? Last week I was looking for a way to know the IP address of a network printer which I added a long time ago but…

Install python and pip as local user on shared Linux

A few days ago, I was struggling to install python on a Linux machine, in which I had no root permission. That machine was shared with many other users and there was only an old python version already installed on the machine. After a bit of search and trial, I…

Common DNS configuration issues

DNS is one of the most fundamental parts of a website. No website can run without a proper configuration on DNS. For beginners, it might be a bit difficult for them to understand and resolve DNS-related issues. This post aims to provide a bit more help for those who are…

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…

Executing shell script from Ruby code

Many times when we are developing an application using Ruby, we want to run a shell script to do certain task. For example, imagine that I have a script do_something.py which performs a very complex calculation and returns the result. From the extension, you can easily guess that…

How to create private git server

Github, Bitbucket or Gitlab are common git servers you have heard of. But do you know that you can also create your own git server with just a few lines of commands? Today I'm going to show you how to do that. In this post, I am assuming that you…

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,…

Understanding Locking in Rails ActiveRecord

Data consistency is very important in many applications, especially for application related to finance, banking, etc. A small error could become a tragedy if we do not treat it seriously. This time, I am going to talk a bit about Locking and how you can use it to protect data…

Useful NGINX configurations for Rails app

Nginx is now becoming the favorable choice of many Rails developers when deploying the Rails app. It is lightweight, fast and has almost everything we need. In this post, I am going to introduce a few useful configs which I often use in Rails app. 1. Redirect www to non-www…