Cufon font replacement

Cufon is pretty good. Much easier to work with than sIFR. The embedding part rocks as you can do it all online. For my own site I use it for headlines. Since the cookbook section contains recipes from around the world I limit and extend the characters to:
– uppercase
– lowercase
– numerals
– punctuation
– basic latin
– and extras including Serbian Cyrillic aphabet: čćšđžČĆŠĐŽабвгдђежзијклљмнњопрстћуфхцчџшАБВГДЂЕЖЗИЈКЛЉМНЊОПРСТЋУФХЦЧЏШ„”‘’–—«»°ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿŔŕ


<script type="text/javascript">; </script>

to the buttom of the page, but before other JS scripts, like Google Analytics, really makes the difference. There is no flicker in replacing the default font and Cufon font. Apparently it helps with IE quirks as well.


Ligatures with Fontographer 5

Creating a ligature
A ligature is a glyph made up of one or more glyphs. Most commercial fonts have some commonly used ligatures like æ, and œ. However, Fontographer makes it easy to create ligatures of your own without drawing a thing.
To create a ligature:
1.    Open the outline window for the “f”.
2.    Choose Select All and then choose Duplicate to create another “f”.
3.    Move the new “f” to the right.
4.    Go back to the font window.
5.    Copy the “l” into the same window using the Copy Component command from the Edit menu.
6.    Move the referenced “l” to the right of the second “f”.
7.    Choose Decompose Component from the Edit menu.
8.    Choose Remove Overlap from the Element menu.
Duplicate the “f”.
Copy a reference glyph into the window.
Move it into place.
Choose Decompose Component.
Then choose Remove Overlap.
Remove any extra points.

Apache and nginx on same server with multiple IP addresses

In order to get this to work, you need to specify the IP and port each should listen in the domain configuration file (and NOT in the global web-server config).

nginx configuration for a domain (/etc/nginx/sites-enabled/ contains:


Apache configuration for another domain contains:

In this case, this was at the top of /etc/apache2/sites-enabled/

WIth this setup, each web server has its own IP to listen to and they both serve on port 80.

nginx config file which works great with Codeigniter 2.0

This config file works great on Ubuntu 10.04 LTS server with nginx 0.7.65. Other software includes php 5.3.2, Code Igniter 2.0. Performance-wise I was able to squeeze 12,000 requests per second on static files and ~250 req/s on dynamic PHP pages.

This is a copy-paste from Chris Gaunt’s github page with a change in server name.

server {
    listen 8080;
    access_log /home/metak/;
    error_log /home/metak/;
    root   /home/metak/;

    # If file is an asset, set expires and break
    location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
        expires max;

	# Serve the directory/file if it exists, else pass to CodeIgniter front controller
	location / {
		try_files $uri @codeigniter;

	# Do not allow direct access to the CodeIgniter front controller
	location ~* ^/index.php {
		rewrite ^/index.php/?(.*)$ /$1 permanent;

	# CodeIgniter Front Controller
	location @codeigniter {
		root /home/metak/;
		fastcgi_index index.php;
		include fastcgi_config;
		include fastcgi_params;
		fastcgi_param SCRIPT_FILENAME /home/metak/;

	# If directly accessing a PHP file in the public dir other than index.php
	location ~* \.php$ {
		root /home/metak/;
		try_files $uri @codeigniter;
		fastcgi_index index.php;
		include fastcgi_config;
		include fastcgi_params;
		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;


CodeIgniter 1.7.2 and SQLite 3

Nice little trick to get CI and sqlite3 to work together. Specify the database file location but prefix it with ‘sqlite:’.

$db['default']['database'] = 'sqlite:'.APPPATH.'data/dictionary.sqlite3';

Tip taken from:

Compare two directories

Great command for recursively comparing directories on Linux or Mac.

diff -rq dirA dirB

It sorts all files by name and than reports if a file exists in one and not the other. It also reports if files of same name exist in both directories but differ in content.

Subversion pre-commit hook for detection of byte-order marks (BOMs)

Byte-order marks can mess up your code badly. Some of my CodeIgniter PHP code was receiving “headers already sent”, thanks to BOM’s alone. So, our goal is to reject a commit that contains one or more PHP files with BOMs. You can easily change the script to filter other files as well. The script is known to work on Dreamhost.

Enough of talking, here is the pre-commit hook, a bash script, you were desperately searching the Internet for:




CHANGED=`$SVNLOOK changed -t "$TXN" "$REPOS" | $GREP "^[U|A]" | $AWK '{print $2}' | $GREP \.php$`

GREP2="grep -l $REGEX"

    MESSAGE=`$SVNLOOK cat -t "$TXN" "$REPOS" "$FILE" | $GREP2`
    if [ $? -eq 0 ]
        echo 1>&2
        echo "***********************************" 1>&2
        echo "Byte order mark error in: $FILE:" 1>&2
        #echo `echo "$MESSAGE" | $SED "s| -| $FILE|g"` 1>&2
        echo "***********************************" 1>&2
        exit 1