Installing PDO_OCI and OCI8 PHP extensions on CentOS 6.4 64bit

I am currently working on a PHP project that requires using an Oracle server as the database. I tried setting up the Oracle PHP extensions directly on my development machine (MacOSX) but failed after a few tries. I also managed to ruin my Homebrew-PHP setup which brought me more joy.

So I ended up using Vagrant which is what I should have done in the first place. So I booted up a Vagrant box with CentOS 6.4 64bit.

This tutorial assumes that you have already installed php and other packages (e.g. php-pdo) you normally need. This was also tested with an installation of Oracle 11g Express. I’m not sure if this will work for higher versions.

Read more →

Affable Aerith: a minimalist Wordpress theme inspired by Svbtle and Medium

I made a new Wordpress theme to brush up on my frontend skills. I’m calling it Affable Aerith for no specific reason. As usual, it’s a minimalist theme. The design is inspired by Svbtle and Medium with some touches taken from the default theme of Octopress. It’s also mobile-ready.

The theme is based on the excellent Bones Wordpress Starter Theme. The following is a list of some of the tools I used to make all these interesting.

Read more →

Offline maps in iOS using OpenStreetMap and Route-Me

This tutorial is heavily based on Rupert’s article here. However, the steps in this article are very different on some points. There are some steps that I had to figure out using other sources.

Read more →

Android Button background image pressed/highlighted and disabled states without using multiple images

In Android, if you provide custom background images for buttons, you will lose the pressed and disabled image effects. The common way to fix that is to provide additional images for those states. I’m lazy and I find this inconvenient especially during the prototyping phase of app development.

Read more →

Removing extra separator lines for empty rows in UITableView

I discovered this by accident. It’s probably been there for a long time but I just noticed it now. Normally, if you have very few rows in your table, it would look like this:

Default row lines

Read more →

FirePHP on Nginx: 502 Bad Gateway

We have switched from Apache to Nginx a month ago. PHP is running on FastCGI using PHP-FPM. I have just recently tried to debug our app using FirePHP and got a 502 Bad Gateway response from Nginx. It looks like Nginx by default limits the header output. This is the error in Nginx’s error log:

2011/09/21 09:36:16 [error] 816#0: *5 upstream sent too big header while reading response header from upstream,
  client: 192.168.56.1, server: v.piclyf.com, request: "GET /pics HTTP/1.1",
  upstream: "fastcgi://127.0.0.1:9000", host: "v.piclyf.com", referrer: "http://v.piclyf.com/dashboard"

The fix that I found is to increase the values of fastcgi_buffer_size and fastcgi_buffers. Add these 2 directives to your PHP FastCGI config in Nginx (i.e. /etc/nginx/sites-available/default):

location ~ \.php$ {
  root /your/site/root;
  fastcgi_index index.php;
  include fastcgi_params;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  fastcgi_pass 127.0.0.1:9000;

  # set these two:
  fastcgi_buffer_size 16k;
  fastcgi_buffers 4 16k;
}

Read more →

Using an object's id as a key in NSDictionary

I was working on a utility class and was playing with the idea of using the id of an object (e.g. NSObject) as a key in NSDictionary. Setting it directly doesn’t work though:

NSObject *obj = [[[NSObject alloc] init] autorelease]; // we'll use this as the key

NSMutableDictionary *dict = [[[NSMutableDictionary alloc] init] autorelease];
[dict setObject:@"a value" forKey:obj]; // won't work

Read more →

A solution to Boot Camp partition error: "Files cannot be moved"

So I was able to partition a Macbook Pro 2010 (Snow Leopard) using Boot Camp in order to install Windows 7. I just want to point out this possible solution when you get this error when trying to create a partition:

Your Disk Cannot Be Partitioned Because Some Files Cannot Be Moved

Back up the disk and use Disk Utility to format the disk as a single Mac OS Extended (Journaled) volume. Restore your information to the disk and try using Boot Camp Assistant again.

Note that I said this is a possible solution. That means that this may not work for you. Most of the solutions I found on the Internet point to using defrag tools like iDefrag. I didn’t want to go that way cause I really don’t have the money to buy those tools.

Here’s what I did to fix this error:

  1. Clean up the hard drive. Move large files to an external backup disk. There are tools like OmniDiskSweeper to that can help in finding large files.
  2. Reboot and boot up using your Mac OS X Install DVD. (Press C when after the startup sound to boot using the DVD)
  3. Choose Utilities > Disk Utility in the menu and Repair the hard drive.
  4. Restart and try partitioning using Boot Camp again.

I’m not ultimately sure if Step 1 is really required but I don’t have time to test it again.

Read more →

Adding allowed open_basedir paths in a MediaTemple DV

This is a quick fix for PHP errors like these on a Media Temple DV:

Warning: include_once() [function.include-once]: open_basedir restriction in effect. 

Read more →

Getting a list of a Facebook user's friends with their email addresses

This article assumes that you are familiar with the Facebook SDK Core Concepts and know how to request a user’s access token. This also uses the Facebook PHP SDK.

Read more →