Very similar like Base16 or Base64, Base 62 uses sixty-two distinct characters, most often the numbers 0 – 9 to represent values zero to nine, and letters a – z and A – Z to represent values ten to sixty-one. The encode method of base62 transforms a decimal number (Base 10) to Base 62, while …Read More →

I followed this postgresql installation guide to install Postgresql 9.3 on our CentOS 6.5 server. But it always failed at the step of initializing the database: By looking at the Postgresql startup logs inside /var/lib/pgsql/9.3/pgstartup.log, I found some fatal error talking about out of memory issues: < 2014-10-15 17:53:17.876 EDT >FATAL: out of memory at …Read More →

As a dynamic programming language, ruby parses and compiles your code at runtime. This gives you the ability to call methods dynamically, define methods at runtime or even handle function calls that doesn’t even exist. But how about the performance speed? define_method To define a method on the spot, you can use define_method which is …Read More →

Ruby is a powerful dynamical programming language. You can easily use it to build large and complex software. However, there are times when you just want to use it to make a basic script to automate your workflow, and simply run it by typing: ruby your_script.rb. The problem comes when you want to let your …Read More →

We have a website that is built by Rails. We also serve a bunch of APIs for customers. The api server is built on Grape, an amazing REST-like API micro-framework for Ruby. Recently I uses my spare time to learn Golang, a pretty new but fast growing language, and is extremely impressed by it’s simplicity and …Read More →

Recently, our filtering worker that I wrote in Java, kept getting connection errors. The worker uses JDBC to connect MySQL server and do some queries. The errors are like this: [ERROR] Caused by: java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost. [ERROR] Caused …Read More →

Recently, I’m trying to implement a real-time notification feature to our Rails application. Socket.IO from Nodejs is really a good choice, and since I’ven wrote pretty much code using Eventmachine, it’s really not hard to understand it. Turns out the real ‘bitching’ part is how to share sessions information and do authentication between rails and socket.io. Firstly, …Read More →

Gisgraphy is a free opensource geocoding and webservices solution. It is a greate alternative to google’s geocoding API, which has lots of limitation on usage. Gisgraphy can provide the best relevance of geocoding, since it combines both geonames and openstreetmap dataset. In fact besides geocoding, Gisgraphy can be used for Reverse geocoding / street search, Street search, Find nearby, Fulltext search, Address parser. I’d recommend you go to their demo site …Read More →

Linode has recently increased the CPU from 4 cores to 8 cores, and also doubled memories of all their plans. To be honest, I really don’t know how 8 cores could be fully used for a website, which just uses their 1GB or 2GB lower plans. I really wish they should have upgraded to SSD …Read More →

Upload a file is a common action for websites. And CarrierWave gem provides a very simple and flexible way to achieve that for Rails application. In realistic situation, you may only allow user to upload files within a limited size or with certain type. For example, only image file type (extension .jpg .jpeg .gif .png) with 5 MB …Read More →