Month: October 2011

Firefox cross domain font embedding

Firefox has a limitation for cross domain font embedding in that it does not allow you to embed from another website. This .htaccess snippet allows you to bypass this limitation and embed fonts located on another webserver.

<FilesMatch "\.(ttf|otf|eot|woff)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin ""

Use PHP to display Gravatar images

All URLs on Gravatar are based on the use of the hashed value of an email address. According to their best practice you should:

  1. Trim leading and trailing whitespace from an email address
  2. Force all characters to lower-case
  3. md5 hash the final string

Of course in PHP this is trivial as the following function shows:

function fetchGravatar() {
$fetchHash = md5(strtolower(trim('')));
$GravatarImage = '' . $fetchHash;
return $GravatarImage;

Profiles are also available if you require them.

CSV to .plist conversion

Property list files (.pfiles) store serialized objects and are often used to store a user’s settings. They are also used to store information about bundles and applications in OSX and recently iOS.

Danilo Campos wrote some time ago some background information and provided his source and blogged about the subject. Better than that however, he provided an OSX binary to download if you want to get going straight away.

This little application makes it easy to format and process your source data in a familiar environment like Excel and then convert ready to use in your application.

EDIT: It seems Danilo has taken his blog offline, and also this binary. I suggest you now use this online tool:

PHP Host Settings Without phpinfo()

Occasionally a webhost will block the very useful phpinfo() command making it difficult to understand any limitations of the server configuration. This script can display relevant information to help you understand what is happening behind the scenes.

$d_func = ini_get("disable_functions");
$up_max = ini_get("upload_max_filesize");
$up_max = str_replace("M","",$up_max);
$up_max_size = "Megabytes";
$post_max = ini_get("post_max_size");
$post_max = str_replace("M","",$post_max);
$post_max_size = "Megabytes";
$input_max = ini_get("max_input_time");
$mem_limit = ini_get("memory_limit");
$mem_limit = str_replace("M","",$mem_limit);
$mem_limit_size = "Megabytes";
$exec_time = ini_get("max_execution_time");
$safe_mode = ini_get("safe_mode");

if(!is_null($d_func) && $d_func !== ""){echo "Disabled Functions: \n $d_func";}
if(!is_null($safe_mode) && $safe_mode !== ""){echo "<span style='color:red;'>Safe Mode is Active</span> <br>";}
if($up_max >= 1001){$up_max = $up_max / 1024; $up_max_size = "Gigabytes";
if($up_max >= 10001){$up_max = $up_max / 1024; $up_max_size = "Terabytes";}}
if($post_max >= 1001){$post_max = $post_max / 1024; $post_max_size = "Gigabytes";
if($post_max >= 10001){$post_max = $post_max / 1024;$post_max_size = "Terabytes";}}
if (min($input_max,60)){$input_max = $input_max /60;}
if (min($exec_time,60)){$exec_time = $exec_time /60;}
if($mem_limit >= 1001){$mem_limit = $mem_limit / 1024; $mem_limit_size = "Gigabytes";}

echo "Maximum Upload Size = $up_max $up_max_size<br>";
echo "Maximum Post Size = $post_max $post_max_size <br>";
echo "Maximum Input Time = $input_max minute/s<br>";
echo "Memory Limit = $mem_limit $mem_limit_size<br>";
echo "Maximum Execution Time = $exec_time minute/s<br>";

Disappearing Folders in OSX Lion

After installing Mac OS X 10.7 Lion I noticed folders were missing. For me the main issue was that the Library folder in my user account seemed to have vanished. As this folder holds nearly all the data that applications save without asking such as mail, preferences, calendars and virtual disks it was important to have an easy way to manage it, especially as I wanted to exclude the Steam folder located there in Time Machine.

Simply launch Terminal from your applications/utilities folder and type

chflags nohidden ~/Library