Archive for the ‘technical’ Category

Site Ranking Google Gadget

Thursday, February 11th, 2010

Good news if you use Google Gadgets – Supernifty’s Site Ranking is now available as a Google Gadget.

Site Ranking Google Gadget

So you can keep track of your website’s popularity right from your home page.

Learn more about site ranking, or go check out the Site Ranking Google Gadget.

Track your website’s popularity

Monday, February 1st, 2010

Supernifty is pleased to announce a new service that enables website owners to keep track of their website’s popularity.

Alexa assigns a world ranking to all the websites on the Internet, however, they only keep historical data for the top 100,000. So if your web site is outside the hallowed few, you can easily lose track of how your site has progressed over the weeks.

Bad week for Supernifty's site rankingSupernifty’s Website Ranking Tracker can do this for you. Once you’ve signed up, Supernifty will check your website’s ranking every day, enabling you to easily see how your site performs over time.

You can also download all historical data, for further analysis.

If you’d like to see how your site is faring in its journey towards world number 1, try it out.

It’s free for a month, then if you wish to continue using the service, upgrade for a very affordable fee.

BlackBerry Musical Instrument Tuner 0.1

Friday, November 14th, 2008

BlackBerry Instrument Tuner

BlackBerry owners rejoice! Supernifty is pleased to announce the release of Audio Tuner for the BlackBerry.

This release brings Supernifty’s super accurate tuning technology to the BlackBerry for the first time.

Why buy a tuner, when your BlackBerry can tune your guitar to pitch perfect accuracy?

And it’s not just a guitar tuner. You can also tune your autoharp, banjo, bass guitar, cello, mandolin, piano, ukulele and violin.

As this is our first release of the software, there may be glitches. If you try out the software, any feedback (good or bad) is appreciated.

Further details are available at the main BlackBerry page.

Get Audio Tuner for your BlackBerry.

Alexa in a nutshell – what’s your world website ranking?

Wednesday, June 18th, 2008

Alexa gives your website a world rankingAlexa is a company that provides a world ranking for all websites on the Internet.

I love this idea.

When I played a lot of tennis I often wished that I could have a world tennis ranking, so I would know how many tennis players I still needed to overtake in my quest for glory.

Federer - number 1 - like YahooI imagined a weekly notice from the tennis officials, telling me, Congratulations, your ranking has increased 143,643 places and you are now ranked 8,200,505th in the world.

Unfortunately, world tennis rankings don’t go past 2,000 so my dream of a world tennis ranking remains a dream. Not so, however, the almost as exciting dream of a world website ranking.

Alexa provides toolbars for popular web browsers. Install one, and Alexa will start telling you the ranking of every website you visit, while also adding your browsing habits to its statistics.

Nadal - number 2 - like GoogleThere are, of course, many problems with this method of ranking web sites, in particular, webmaster oriented sites get a huge advantage, but I prefer to ignore these trivial weaknesses, and instead concentrate on watching my website climb the rankings, pushing aside less awesome sites.

I’m not sure if visiting your own website yourself adds to your Alexa stats, but just to be sure I tend to visit Supernifty at least 1,000 times daily.

You should do the same. Visit Supernifty that is, not your own undeserving site.

The main problem with the Alexa ranking is knowing what a ranking really means. To help out on this, Supernifty has put together a simple table for evaluating your website, based on its Alexa ranking.

Simply look up your ranking, then check it against the table below.

Ranking Evaluation
15 million   You don’t even visit your own website? That’s embarassing.
5 million   OK, so now you’re visiting your own site.
3 million   Your Mum has also seen your website.
2 million   Your Mum has a dog, it likes to surf the net.
1 million   Your family and all family pets clearly are visiting your site.
500k   Your site is officially proper*.
200k   Your site is officially pretty good*.
20k   ur site is beats lolcats.com.
5k   Congratulations! You are more popular than Hillary Clinton.
1500   Time to run for president. You just passed Barack Obama.
3-100   To reach the coveted top 100, your site will need that something special. If you’re not a mega software company, or owned by Google, your site must contain at least one of the following: social networking; zillions of sites combined; porn; illegal downloads; or image/video sharing. That’s a tip for reaching the top 100.
2   You are God
1   God has an Uncle?

So now you know how good your site is, and by extension, how good you are.

* Supernifty certified. Stickers available on request.

Backup multiple MySQL databases with Python – hack it #5

Wednesday, May 28th, 2008

Keep copies, or risk the great sadness

Backing up is important.

If you host a website which has a database, and you’re not backing it up, you should.

If your database was wiped, and you lost your entire blog, wiki, customer details, and the rest, if you’re like me, you’d be deeply unhappy.

Most webhosting companies do backups, but are somewhat vague on guarantees and process. They often charge to do restores as well.

Best bet is to do it yourself.

This set of instructions applies to MySQL, and can be applied to one database or many.

Step 1. Backup your databases on the server
Below is a python script that will backup multiple MySQL databases. Put this on your web server, preferably in a directory called backup, with the name backup.py.

import os
 
databases = dict()
databases['*** db1 ***'] = '*** password1 ***'
databases['*** db2 ***'] = '*** password2 ***'
databases['*** db3 ***'] = '*** password3 ***'
 
def set_pass( name ):
 file = open( '/*** your home directory ***/.my.cnf', 'w' )
 file.writelines( ( '[client]\n', 'password=%s\n' % databases[name] ) )
 file.flush()
 file.close
 
for key in databases.keys():
 set_pass( key )
 os.system( "mysqldump --user %s --opt %s > %s.sql" % ( key, key, key ) )
 
os.system( "zip backup.zip *.sql" )
os.system( "rm *.sql" )
os.system( "chmod 600 backup.zip" )

About this script:

  • A problem with backing up multiple databases without intervention is the entering of passwords in a secure way. This script uses .my.cnf to set the password securely.
  • Fill in the database usernames and passwords. This script assumes the database has the same name as the username.
  • Fill in your home directory e.g. /home/john
  • The result of this script is backup.zip, in the current directory.

Step 2. Copy backup to your machine
This script connects to your web server, runs the above backup script, then copies the result back to your local machine. Put this on your local machine.

ssh -i "your_key" you@yourhost.com "cd backup; python backup.py"
rsync -avz --rsh="ssh -i your_key" you@yourhost.com:~/backup/ backup

About this script:

  • This script assumes the backup script is in the “backup” directory on your web server.
  • You need ssh and rsync to use this script. On Windows, PuTTY provides a great ssh client, but I don’t know of a good rsync implementation, other than cygwin. Instead of rsync, you could use scp, which comes with PuTTY.
  • If you want to automate this script (see later), you’ll want passwordless ssh, which means setting up “your_key”. Google on how to set this up.

Step 3. Repeat periodically
You want to automate this process so you can forget all about it.

  • Unix: crontab. If you’re unfamiliar with crontab, try “man crontab”. The main commands to use are “crontab -e” and “crontab -l”.
  • Windows: scheduler. Check out Control Panel->Scheduled Tasks, and add your client script.
  • As mentioned above, you need passwordless ssh so your scheduled task can run unattended.

There’s your nutshell guide to backing up multiple MySQL databases with Python.

Backups – Hack It #4

Wednesday, May 21st, 2008

Keep copies
Backups are an essential feature of any IT installation.

You’ve got to have backups. Not backing up is a ridiculous, unnecessary risk.

The average hard drive has a 20% chance of failure each year. How would you fare if your computer was stolen, or melted in a fire? If you don’t have a plan for data recovery, you are asking for trouble.

It shouldn't happen to you!

Try to put a value on losing everything on your hard drive, and remember that fires, robberies and hardware failure are all out of your control.

For instance, a friend recently lost all his photos. Over 10 years worth of memories, gone forever! Man, he was sad.

These days there are great, inexpensive options for backups.

Option 1: buy an external hard drive.
This is a big improvement on not backing up at all, however, there’s a problem. If you keep the external drive with your computer, you’re not covering all the bases.

Any localized event, such as a natural disaster or robbery, will render your backup solution useless.

If you copy your data off your computer, then take your external hard drive away to another location, then this is a fine solution. Otherwise, it’s not recommended.

Option 2: online backup
In recent times, some very competitive options have sprung up. This stores your data safely away from your computer, so this is a winner – you can’t lose both in the one event. The main factor in my opinion is security.

  • Mozy – unlimited storage for $4.95/month.
  • Carbonite – unlimited storage for $49.95/year.
  • Amazon S3 – incremental storage of 15c/GB/month. This is not on its own a backup solution. You need a user-friendly client to connect you to their backup service. For instance, JungleDisk.

I chose S3 and JungleDisk, primarily for security reasons. Most solutions tell you that your data is safe and encrypted, but that they can recover your data if you lose your password.

This means that if the company is hacked, or if you don’t trust company employees, your data is vulnerable. JungleDisk has the option to encrypt your data before it leaves your computer, and cannot be decrypted without your password.

It’s worth pointing out, that with Amazon’s incremental pricing, if you only need to backup a few gigs, then you’ll be paying less than $1/month to keep your data safe.

It’s a tiny price to pay for the guarantee that your data will not be lost.

PHP sessions on shared hosting – Hack It! #3

Saturday, April 19th, 2008

PHP

If you use sessions with PHP on shared hosting, there are a couple of potential issues:

  • You might be vulnerable to session hijacking. PHP stores sessions as files. Where are they being stored? If they are stored in a publicly readable directory such as /tmp (the default), then other users of your shared host can hijack any session from your website. The session ID is part of the filename, so an attacker can build his own cookie that will be authenticated by your website.
  • You don’t have control over session timeouts. The default session timeout is 24 minutes. From the php manual: “If different scripts … share the same place for storing the session data then the script with the minimum value will [determine the session timeout]“.

So… by default, sessions timeout after 24 minutes, which I think many users would find pretty irritating, and you are vulnerable to session hijacking from anyone having access to your shared server.

Not good!

The solution. Here is one way to solve both of these potential issues. Whenever your code starts handling a session, include the following PHP:

ini_set("session.gc_maxlifetime","21600"); // 6 hours
ini_set("session.save_path", "/your_home/your_sessions/");
session_start();

The first setting is the timeout in seconds, so for each hour of session survival, add 3600.

The second setting is the path to save session files to. Change this to a real directory in your home directory. Note that the first setting will not work unless you set this. Also note that the process running PHP needs to be able to write to this directory.

With this hack you can increase the security of your PHP sessions, and have them timeout over a period appropriate to your website. Hurrah!

Migration to Webfaction

Thursday, April 10th, 2008

Supernifty has just migrated to a new hosting provider: Webfaction.

These guys have all the up-to-date software, a great control panel, and undercrowded shared servers. They offer very good support and have wizard installations for all kinds of web frameworks, including Django, Rails, WordPress, etc. So far it has all looked very impressive.

As a result of the migration, a whole bunch of server software that Supernifty relies on has been upgraded. Hence there may be problems. If something does not work properly, please let me know. Although we’ve tested as much as possible, at 2am, sometimes things are missed.

MediaWiki and SEO #2 – robots.txt

Tuesday, March 25th, 2008

MediaWiki Flower
If you are using MediaWiki as your CMS, you’ll need to ensure robots.txt is configured correctly on your site.

Search engines don’t like seeing duplicate pages, and if you don’t configure robots.txt, MediaWiki will give the search engines exactly that, via its “random” and “search” functions. This can lead to your pages being incorrectly marked down, or not indexed at all.

To prevent this from happening, create a file, robots.txt, with the following content:

User-agent: *
Disallow: /wiki/Special:Random
Disallow: /wiki/Special%3ARandom
Disallow: /wiki/Special:Search
Disallow: /wiki/Special%3ASearch

where wiki is the directory of your MediaWiki installation.

Place this file in the root HTML directory of your web server. You can verify that the file has installed correctly by visiting http://your-web-server/robots.txt.

This fix prevents your MediaWiki based web site from being marked down incorrectly due to duplicated content.

MediaWiki, CMS and SEO #1 – META tags

Monday, March 17th, 2008

MediaWiki
Supernifty uses MediaWiki as its CMS. There are many advantages to this arrangement, mainly the simplicity of use, and the advantage of a familiar Wikipedia style interface for users.

However, there are disadvantages. One being that there is no way to include custom meta tags in your wiki pages. Also, there appears to be no way to make the title that appears in the title bar different to the heading that appears at the top of the page.

META tags: All the SEO guides mention them. Although historically they were quite important, their relevance now is debatable. But, you never know. Some search engines still look at them, in particular, the description meta tag.

Title tag: Search engines look at this. So, you want a descriptive title, but not necessarily a huge headline on your page. By default, in MediaWiki the title in the title bar is the same as the title on the page, and the title in your URL. Bummer.

A MediaWiki extension was written to address this problem. Install this extension, and you can set:

  • Any meta tag
  • A different title on the title bar (for the search engines) to the one that appears on your wiki page (and wiki URL).

Yeeha!