One of my PHP web applications stopped working today. After I investigated the issues, I noticed that this is a very famous, yet unsolved error. I have no idea why it happens, but I do have a work around solution for it. Basically, this article applies to you if you match all of the following: You use PHP Your web applications talk to other servers via domain name (e.g., example.com rather than 123.1.1.3) You use XAMPP (instead of...
Read MorePHP Network Error
[PHP]imagecreatefrompng Error (After upgrading FreeBSD)
Today, I found that one of my PHP scripts stop working. After some investigations, I found that it was the function, imagecreatefrompng, which caused the problem. Interestingly, other similar functions such as imagecreatefromgif and imagecreatefromjpeg were completely working fine. The program stopped working when calling imagecreatefrompng only. Initially, I thought the problem was coming from the PHP side. Therefore, I tried to get the...
Read MoreNatural Sort. MySQL. Sorting a 2D Array By Multiple Columns in PHP Naturally. Array_MultiSort with Natural Sort
MySQL has a biggest missing feature: It does not sort naturally. This has been an opened request since 2003, and MySQL team has no plan to fix this in a near future. I have looked for a solution to solve this problem for a while. Unfortunately, I found nothing useful. Here is a summary: The + 0 Trick Many developers suggest this solution: SELECT names FROM your_table ORDER BY age + 0 ASC This is not a good solution because it only...
Read More[PHP]How to get the number of CPU cores in Fedora, Ubuntu, and FreeBSD
I am working on a PHP application which needs to be deploy to multiple places. One of the variables is the number of CPU core. Since each server has different number of CPU cores, I need to specify the number of CPU core in my application for each server. I think there should be a smarter way to do it. PHP is a scripting language, it has limit support on accessing the hardware level information. In short, there is no library or function...
Read MoreWeird JavaScript Date Bug
Today I found a very weird bug in JavaScript – The date function. I never expected to see a bug in the standard JavaScript implementation. Here is my code. It does nothing more than adding 21 days on the reference date: var referenceDateObject = new Date(2011, 9, 10); var deliveryDateObj = new Date(referenceDateObject.getTime() + 24 * 60 * 60 * 1000 * 21); var deliveryDateMonth = parseInt(deliveryDateObj.getUTCMonth()); var...
Read MoreA letter to Microsoft Internet Explorer Development Team
Dear Microsoft Internet Explorer Development Team, Would you like to take the source of Firefox (or any browser besides Internet Explorer) and call it Internet Explorer 11? Thanks. –Derrick If you found this solution useful, would you like to visit the following sponsors?
Read MoreEnough “Rails Surprise”! Goodbye Ruby On Rails.
Couple months ago, I published an article about Ruby On Rails. I was wrong. The idea of Ruby On Rails is really good. You can create a very simple database-driven web application (i.e., User can add, browse, remove and search records) in less than half an hour. There is no way to do something similar in such a short time using other programming languages. However – perhaps this is the tradition of the Rails development team, it comes...
Read MoreRuby On Rails gives no “surprise” in the latest version
I haven’t upgraded my Ruby On Rails and related Ruby gems for 5 months. One of the reasons is that Rails development team likes to break the backward compatibility, such as: NameError: uninitialized constant ApplicationController To avoid this kind of surprises, I tend to stick with a working, stable version. Recently, I upgrade the entire Ruby On Rails family(2.3.2 -> 2.3.4), and surprisingly, my Ruby On Rails apps work perfectly...
Read MoreIE is “fxxking”, but it is not an excuse to leave bug in the codes
Today, my co-worker found that the web-application he developed worked only in Firefox, and it didn’t work in Internet Explorer(IE). He immediately asked me if we should ignore the IE users or not. I know that he was working on JQuery(Javascript). It is not surprised that IE does not support the standard JQuery. However, it doesn’t mean that we can simply remove our support to IE users. In fact, IE still have more than 55% of...
Read MoreInterviewing a software engineer / developer / programmer
I am going to have a face-to-face interview with a candidate of a PHP programmer position this afternoon. I was told to prepare some technical questions for the interview. If a candidate earns an face-to-face interview opportunity, that means his resume should have a very good match to the position requirement. However, people can put anything on their resumes, there is no way to tell whether the information on the resume is true or not...
Read More