Using xpath in Google Chrome

Yes, it’s easy. Open the Inspector and click Elements to activate the tab. On a Mac, do a search by pressing Command-F and enter your XPath query.

For example:


Voila! Your matched elements are highlighted.

Screen Shot 2014-10-02 at 12.58.28 PM

1 Comment

Posted by on October 2, 2014 in Uncategorized


Stalling MySQL under DDoS

In the most recent DDoS attack on my servers I’ve noticed that my provider was blocking all malicious pockets, but was causing the network latency big enough for MySQL connections to time out.

After increasing the connection time and net read timeout limits the problem was gone.


The pages seem sluggish, but they do open up within 5-7 seconds.

Leave a comment

Posted by on October 1, 2012 in MySQL


ec2ssh – ssh utility Amazon forgot to include

Last week I wrote a bash script that makes connecting to AWS instances ridiculously easy. It’s called ec2ssh.

Let me show you how easy it is to use. You type ec2ssh in your shell, and a menu displays with a list of running instances. Each of your servers is numbered and grouped by security group, so it’s easy to find your instances. You can do several things here. You can type the number of the server you wish to connect to, or define a list or range of servers you wish to ssh to in a sequence.

Additionally, you can run ec2ssh with parameter, a filter, to narrow down your list of servers. Say, you run a typical environment with web, database, application servers. If your instances were tagged by meaningful names like:
– Live MySQL server A
– Live MySQL server B
– Live MySQL server C
– Live Web server A
– Live Web server B

– Live Web server XYZ

you can limit the list by specifying a meaningful parameter such as:
ec2ssh live – would list all production servers
ec2ssh mysql – would list MySQL servers in dev, staging and production
ec2ssh i-2asf3234dd – would list information for given server instance
ec2ssh sg-adf23df2d – would list all servers in a given security group

Parameters are case insensitive. To use a script, download it from the ec2ssh github page. If you’re a github user please fork the project and submit any new features or fixes.

Thanks and enjoy! Your comments are very welcome.
Leave a comment

Posted by on February 1, 2012 in Linux, Mac OS, Uncategorized


Tags: , , , , ,

How to make iPhone visual voicemail work with Chatr Wireless

When I got my new iPhone 4S it worked fine with Chatr’s voicemail. It was displaying the red dot over the voicemail icon to notify me that there was a message I haven’t heard. Then, several days ago, something got corrupted and I couldn’t retrieve my voicemail any more. I read their FAQ’s which suggested shutting down the phone and keeping it off for several minutes. It didn’t work, so I called their support. They couldn’t help me find the codes to program the visual voicemail, but they gave me the phone number that the phone uses to listen to the voicemail. In my case it was +16472789973.

I searched for an answer on Google and found the codes. If you have this problem you need to type:


Press call and you’ll hear a beep. Nothing else will change. Clear the calling number and verify the new number by typing:


When you click Call, the phone will display the number of your voicemail access number, in my case 16472789973. If it worked, you should be able to retrieve your voicemail by clicking the Voicemail icon.

Non-advertised feature

Chatr makes extra money every time you listen to your voicemail. Each call is 25 cents/min. However, if you dial your voicemail access number from another phone, and provide your phone and pin, you’ll not be charged for listing to those messages.

Leave a comment

Posted by on January 8, 2012 in Uncategorized


Tags: , , , ,

Fun with VoIP boxes

I’ve been spending some time lately testing and configuring VoIP services on my recently bought Linksys SPA-2102 VoIP box.

I finally settled with two services: Callcentric and

Callcentric seems to have better quality, while provides a Callback service. Not *69 call back, but the one that enables you to call with low rates when travelling abroad. You basically call your number from say Bosnia. You get a fast busy signal. When you hang up the system calls you back and gives you the dial tone. So, you pay the low rates instead of $$$ that overseas companies charge.

Callcentric is my choice of VoIP provider for inbound and outbound calls. It works great, unlike behind the CellPipe 1730 modem on Bell Fibe.

Porting from Bell to CallCentric (LNP)

CallCentric provides a free account that comes with a 1-777 number. This number is not reachable from a regular landline, but it can be used to test the quality of the service by dialling the echo service. I ordered a local Toronto number and tested it for about two days. I was very happy with the quality of calls. I was ready to leave Bell, so I requested my home number to be ported to Callcentric. This is done by a form on CallCentric’s web site. I had to sign a form and upload it to their site along with the latest Bell Canada bill. I was informed that the line would be ported in two days. On the second day, I received an email that the port has completed.

Setting up the local number

I set up the ATA with my account details, but it didnt work properly as I already had a local number (DID) working on my VoIP box. It turns out you can have multiple DID’s on the same CallCentric account, but they can’t be used with the same VoIP box, even if you have a box with two lines. Their support explained that I need to open another account with a temporary number, forward my DID to that temporary number from the other account. That’s a little bit of a workaround, but as long as I don’t have to pay two bills I’m happy. We’ll see.

Sit, VoIP, sit! Behave like a landline!

The default setup of the calling plans is little cumbersome. You need to dial 1 before the area code, even if it’s your local area code. Let’s fix this! I live in Toronto, where 416 and 647 are both local and normally dialled without a starting 1.

Take CallCentric’s default calling plan:


and change this recipe to:


What it does is it recognizes the number starting with 416 or 647 and prepends “1” to it.

Make overseas dialling super easy

We travel to Bosnia every year. The numbering system there is “06” for cell numbers and “05” for landlines. I want to be able to dial a number as if I were there. So, to dial a hotel with a phone number 011 387 51 215 775, I’m going to change a rule to allow 051 215 775 to dial this number.


Leave a comment

Posted by on October 13, 2011 in Uncategorized


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 Western European diacritics characters and 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.

Leave a comment

Posted by on November 27, 2010 in Uncategorized


Tags: ,

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.

Leave a comment

Posted by on November 24, 2010 in Design


Tags: , ,

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.

Leave a comment

Posted by on November 2, 2010 in Apache, Linux, nginx


Tags: ,

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;


Posted by on October 2, 2010 in Linux, nginx, Ubuntu


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:

Leave a comment

Posted by on January 13, 2010 in Uncategorized

%d bloggers like this: