Archive for the ‘technical’ Category

Speed Scrabble Safari Extension

Sunday, July 18th, 2010

Speed Scrabble Safari ExtensionIf you’re using Safari as your web browser (Apple users, this means you!) you may be interested in the Speed Scrabble Safari Extension.

Speed Scrabble is a fast, fun word game, suitable for single player, but often more fun as multiplayer.

This Safari extension enables you to see when there are players waiting to play on the Speed Scrabble server, so you can join them for a game.

Speed Scrabble Safari Extension Screen Shot

If you use the extension, remember to play the occasional game – otherwise anyone else waiting for a game through the extension won’t know that you are available!

py2exe, python 2.6 and wxPython – hack it #7

Tuesday, July 6th, 2010

Python
If you’ve tried to build a client application with Python 2.6 and wxPython, you might hit a problem.

Python 2.6 no longer includes the Visual Studio dependencies required by wxPython. These dependencies may not be present, either on your build machine, or the target user’s machine.

When building with py2exe, you may encounter an error similar to:

error: MSVCP90.dll: No such file or directory

The solution!

To successfully build your executable, you need the Visual Studio 2008 redistributable package, which can be obtained from Microsoft. Run this on your build machine to install the appropriate DLLs.

If your build still fails, you may need to copy the DLLs into your build directory. Locate msvcp90.dll, msvcm90.dll and msvcr90.dll on your machine and copy them to the build directory.

Once you have a successful Python build, you also want your executable to run on the target machine. To do this, your install script needs to install the vcredist package as part of the installation.

The command you need to run as part of your client installation is:

vcredist_x86.exe /q:a

If you are using NSIS as your installer, the appropriate code is:

File /r vcredist_x86.exe ;to copy the file
ExecWait ‘”$INSTDIR\vcredist_x86.exe” /q:a”‘ ;to install

With the Visual Studio redistributable installed, it will now execute successfully on the target machine. Hurrah!

OpenID available on Supernifty

Thursday, April 15th, 2010

No more passwords
Supernifty is pleased to announce OpenID as a login mechanism on its website.

OpenID is a scheme that allows users to login to Supernifty, by entering their login details at another site.

So if you already have an account with Google, Yahoo, AOL, or any other OpenID provider, you can now log in to Supernifty without having to set up yet another account, or create yet another password. Hurrah!

Handy for the Speed Scrabble players, and any of Supernifty’s other offerings requiring login, such as the time tracker, site ranker and lifestyle tracker.

Currently, only the most popular OpenID providers are listed – if you use a provider that you’d like to see listed, let us know.

Supernifty – saving you from remembering yet another login smile

Smartphone Market Penetration

Wednesday, March 17th, 2010

Some stats from ComScore illustrate the state of the mobile market. This post provides some simple charts of the data.

What’s the breakdown of smartphone market share?

Smartphone Market Share January 2010

Clearly BlackBerry are doing incredibly well, covering almost half the market.

Which platform’s been growing the most over the last 3 months?

Smartphone Growth (Millions) from October 2009 to January 2010

Somewhat surprisingly, BlackBerry continue to consolidate their position, taking most of the new entrants to the market.

Interestingly, in the original statistics, Google appear to be doing the best, and Microsoft the worst. However, in terms of actual numbers, BlackBerry continue to be number 1 for growth, with Microsoft and Palm equal losers.

These stats are based on the US market. Visit ComScore for the original figures.

Remember me with PHP – hack it #6

Monday, March 15th, 2010

PHP persistent sessions
“Remember me” functionality was recently implemented on the Supernifty login screens. The PHP documentation is surprisingly non-obvious so here’s how to do it.

If you’re already using the $_SESSION variable, the default is for this variable to live only for as long as the browser. Once the user closes the browser, the cookie will be deleted, and they’ll be logged out.

To remember a user across browser sessions, here’s what needs to be done.

Tell the browser to remember the session

You do this with the line:

setcookie( session_name(), session_id(), time() + 86400*30 );

This overwrites the default session cookie, with a cookie that will persist on the user’s browser for one month.

Note that since cookies are set in the headers sent to the browser, this needs to be done before writing any content to the browser.

With HTML like

<input type="checkbox" name="remember" value="remember"/>

You could have a handler like:

$remember = $_POST['remember'];
if ( isset( $remember ) && $remember == 'remember' ) {
setcookie( session_name(), session_id(), time() + 86400*30 );
}

Tell the server to remember the session

Bizarrely, PHP’s default session time is something ridiculous like 24 minutes.

To tell the server to remember the session for longer, you need to set some PHP environment variables, like so:

ini_set("session.gc_maxlifetime","2592000"); // 24*30 hours
session_set_cookie_params( 86400*30 );
session_start();

More details about PHP’s session lifetime

With these two pieces in place, you can now implement a “remember me” checkbox on your login screen with PHP, while continuing to use the $_SESSION variable.

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.