Monthly Archives: June 2012

You are browsing the site archives by month.

Convert latin1 tables/fields to utf8

I had some screwup which made all my tables/fields latin1. That sucks, because I didn’t want to manually correct this. I found the following lines of code that fix this problem.

mysql --database=marlon -B -N -e "SHOW TABLES" \
| awk '{print "ALTER TABLE", $1, "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;"}' \
| mysql --database=marlon &

Also note that if you’re converting from some other obscure character set it’s best to first convert to binary and then convert to utf8, making sure you won’t lose data in the conversion.

How to fake ajax requests with cURL

If you need to fake ajax requests you can do this in the console (on Mac).

curl -H 'X-Requested-With: XMLHttpRequest' -d "my=var" http://localhost/en/my/page