Friday, June 27, 2014

Unable to use Fontawesome because of library PIL

Was trying to use fontawesome library to generate PNG files. However, met many errors along the way. In simple steps:

1. downloaded and installed brew

2. sudo brew install freetype

3. sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install pillow

4. python fontawesome.py --size 128 play

Wednesday, May 7, 2014

Warning: mysql_connect(): No such file or directory in but file exists in terminal

This will fix the issue:

sudo su
ln -s /Applications/xampp/xamppfiles/var/mysql/mysql.sock /tmp/mysql.sock
mkdir /var/mysql
ln -s /Applications/xampp/xamppfiles/var/mysql/mysql.sock /var/mysql/mysql.sock

Sunday, May 4, 2014

Custom files redirection error on wordpress

Even though the permissions for the folders and files are correct, a 404 error kept showing on the wordpress site. This can be resolved by modifying the .htaccess file and modifying the headers to something like this (the highlighted section is what is new):


RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/rest/(.*)$ [OR]
RewriteRule ^.*$ - [L]

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]


# END WordPress

Wednesday, April 30, 2014

Persistent ampersand/html entities in jquery
















You can solve it by doing this: $('
').html("HTML YOU WANT TO CONVERT").text()



Sunday, April 27, 2014

SimpleXML error - unterminated entity reference.

While repurposing a blog today into XML doc, ran into the usual ampersand error. Warning
: SimpleXMLElement::addChild(): unterminated entity reference.

The error is a result of addchild inside SimpleXML, which does not automatically escapes ampersand. The best way to fix this problem is to simply not use the addchild method but instead of going direct:

// change the following:
// $childnode = $xml->addChild( $key, $value, 'url' );

// into this:
$xml->addChild( $key );
$xml->$key = $value;

Weird characters in PHP crawler/curl such as รข€™s...

Solution is to convert the doctype to UTF with the following line of code at the header:

header('Content-Type: text/html; charset=utf-8');

Tuesday, August 27, 2013

Sinaporean getting a california (US) drivers license

This guide probably doesn't apply exactly if you are trying to get a license in other states of the USA. It is heavily skewed towards that of California.

This is what I did in my initial days here in California:

Getting a license in California is fairly easy here in San Francisco and actually a lot less hassle than in Pennsylvenia. There is no medical examination required, no proof of residence required. So essentially, you can get your permit/driving license on the 1st day you are here if need be.

Here are the steps in general (for learners permit/driving license):

1. Print your I-94 for registration of learners permit. The federal government done away with the white slip of paper call I-94 which was handed to you when you first enter the country and taken back each time you leave. But they have since do away with that and you basically need to go http://www.cbp.gov/i94 to print it out. And you need this in case you get pulled over by the police.

2. Get your SSN from an SSN office in the USA. This will take a few weeks and probably proof of residence etc.

3. Find the nearest DMV (you can do so by googling for DMV San Mateo, DMV Daly City, DMV Santa Clara). I did this on google maps.

3. Study for your Written Test. Trust me, you really need to read this. Do you know if you can actually cross the bicycle lane while driving/turning? Which freezes faster? Intersection or bridges? Better start studying if you want that learners permit on first try.
http://www.dmv.ca.gov/pubs/

Common Questions

1. I have a driving license in Singapore and have been driving for ten years, do I need to take the drivers test all over again (including written + behind the wheel?)
- Sadly, this is not recognised. So yes, you have to take the test all over again - as if you do not know how to drive.

2. I have an out of state license (e.g. PA, NY etc) which has expire, do I actually need to sit for the test all over again?
- California state allows non out of State Drivers License (eventhough they have expired) to be exchanged for a California license. However, you are expected to take the written test before the license will be issued to you.

3. Do I need an IDP (International Drivers Permit) to drive in the USA?
No you do not. Not for the USA.

4. So what should I get a california driver's license?
If you are interested to buy a car, or get insurance for your car (its cheaper if you have a california license).

5. What proof of identity do I need to buy a car in California?
All you need is your checkbook and a valid california drivers license. Was told that you could actually register a car even if its just a drivers permit.