Archive

Archive for the ‘Applications’ Category

Web Accessibility Evaluation Tool

December 1st, 2009 No comments

Want to know if your websites complies to the accessibility guidelines?

Test your website with WAVE, the Web Accessibility Evaluation Tool. This tool gives a visible report that reveals the accessibility of your website.

http://wave.webaim.org/

How to debug a segmentation fault caused by PHP

December 1st, 2009 4 comments

A segmentation fault can have many causes, the best thing to do when you have a segmentation fault is debug it to find out what’s causing it.

I explain to ways two do this.

With The GNU Debugger

  • First install the gdb package with apt-get or yum.
  • Second, stop all httpd processes
  • Start Apache in debug mode

Redhat

httpd -X

Debian

apache2 -X
  • Find the parent process id from Apache

Redhat

cat /var/run/httpd.pid

Debian

cat /var/run/apache.pid
  • Start the gdb program
gdb
  • Connect the GNU debugger to the Apache process
attach <apache process id>
  • The debugger will halt the process, but we want to run it till the segmentation fault has happened
continue
  • Now try to reproduce the segmentation fault. When this happens you will see the fault in the debugger.
  • To see what happened, get the backtrace
bt

With Valgrind

  • Install valgrind with yum or apt-get
  • Stop all Apache processes
  • Start valgrind with Apache in debug mode

Redhat

valgrind /usr/sbin/httpd -X

Debian

valgrind /usr/sbin/apache2 -X
  • Try to reproduce the segmentation fault and valgrind shows what happened

MySQL profiler

March 4th, 2009 1 comment

When your query is slow you can debug your query with EXPLAIN. But did you know that since MySQL 5.0 you can use a profiler in MySQL?
It’s easy to use and can help you to find the bottleneck in your query.

How it works

Open a MySQL console and turn on the profiler:

mysql> set profiling=1;
Query OK, 0 rows affected (0.00 sec)

Then execute the query you want to profile, you can execute as many queries as you want. But by default only the last 10 will show up in the profiler.

mysql> select count(1) from files;
+----------+
| count(1) |
+----------+
|    13631 |
+----------+
1 row in set (0.09 sec)

Now check what’s the query ID with the command:

mysql> show profiles;
+----------+------------+----------------------------+
| Query_ID | Duration   | Query                      |
+----------+------------+----------------------------+
|        1 | 0.09114000 | select count(1) from files |
+----------+------------+----------------------------+
1 row in set (0.00 sec)

To get a the details of this query use the query id.

mysql> show profile for query 1;
+----------------------+-----------+
| Status               | Duration  |
+----------------------+-----------+
| (initialization)     | 0.000003  |
| checking permissions | 0.000031  |
| Opening tables       | 0.000028  |
| System lock          | 0.000018  |
| Table lock           | 0.000009  |
| init                 | 0.00002   |
| optimizing           | 0.000008  |
| statistics           | 0.000023  |
| preparing            | 0.000012  |
| executing            | 0.000008  |
| Sending data         | 0.0909409 |
| end                  | 0.000013  |
| query end            | 0.000005  |
| freeing items        | 0.00001   |
| closing tables       | 0.000008  |
| logging slow query   | 0.000003  |
+----------------------+-----------+
16 rows in set (0.01 sec)

Now you see the duration of every step MySQL takes. You can see a lot more like the CPU usage, just take a look at the manual.

Twitter integration

February 28th, 2009 No comments

I’ve started using Twitter (sorry only in dutch), the nice thing about this service is the free API. Thanks to this API there are many ways to integrate twitter in your websites and your life.

Website

To show your tweets on your website you can use the widgets from Twitter. Or you can use Twitter counter.

Applications

For using Twitter on your mobile or desktop check out this site for a large list of Twitter apps. I have a Windows mobile based phone (Samsung Omnia) and I use Tiny Twitter. And on my Ubuntu desktop I use gTwitter.

Photo’s

I have a Flickr account and want to connect this to Twitter. This way I can mail my photos from my mobile to Flickr and automatically post this on Twitter. I was searching for a service like this and found Snaptweet. This did indeed what I wanted, but it was taking 10-20 minutes to see the photo on Twitter. That’s to long for me.

Next service I found was Twittergram, but they have a problem with the connection to Twitter so I couldn’t test it.

Another option is to use the Flick RSS feed and use the Twitterfeed service.

For now I’m using Twitpic, they also offer a email address to send your pictures.

pgFouine PostgreSQL log analyzer

February 11th, 2009 No comments

If you have a busy PostgreSQL database you may want to know which query takes up most of the time of the postmaster. To create a nice overview of slowest and most frequent queries you can use pgFouine.
This PHP script can parse a PostgreSQL log and create different reports.

The command I usually use:

./pgfouine.php -from "- 1 week" -memorylimit 512 -file <logfile.log>
-logtype stderr -title 'PostgreSQL analyze' -report db-report.html=
overall,bytype,hourly,slowest,n-mosttime,n-mostfrequent,n-slowestaverage,
n-mostfrequenterrors -format html-with-graphs

Developing on Ubuntu

February 9th, 2009 No comments

On my work I use a HP laptop with Ubuntu Intrepid. With Ubuntu and some nice applications you have a good platform for developing (web) applications.

These are the applications I use:

  • Firefox – Of course for surfing the internet, and with plugins like Firebug very useful for debugging javascript .
  • Thunderbird – My default mail client
  • Evolution – For access to my work calendar
  • KeePassX – ForĀ  storing passwords
  • Charles – A web debugging proxy
  • Geany – A fast text editor with a IDE
  • Meld Diff viewer – A diff and merge tool
  • RapidSVN – Front-end for subversion
  • Zend Studio – My most used IDE
  • Avidemux – A simple video editor with support for many codecs
  • Truecrypt – For securing important files
  • Dropbox – Used for the keepassx database, making it available on all my computers
  • VirtualBox – Running a Windows XP environment for testing with IE and using Visio (didn’t found a good alternative yet)