Archive for the ‘technical’ Category

Ultra Simple PHP Profiling – Hack it #8

Tuesday, November 9th, 2010

We wanted to profile a few PHP scripts, so we tried xdebug, but there were a few issues:

  • Not suitable for a production server
  • Difficult to turn on/off for specific scripts and requests
  • Difficult to profile MySQL queries, without also attracting a mass of other data

xdebug is better for offline application profiling.

If you just want to track down a bottleneck, or see what your script is spending all its time doing, here’s a simple alternative.

To profile your SQL, replace mysql_query with mysql_queryx.

This generates a CSV file at /tmp/profile.1 for easy analysis.

Now create the file profile.php:

Too easy!

To stop profiling a page, set $profile = false.

If you’re concerned about performance, do something like $profile = rand(0, 100) > 99.

Server Upgrade

Saturday, November 6th, 2010

Server upgrade
Supernifty’s servers have recently been upgraded.

Our old server was barely coping with the load, particularly that generated by Speed Scrabble, so Supernifty is now on a faster, more powerful server.

This means a zippy, more reliable experience for everyone. If you do encounter problems, please get in touch. You may have encountered a few timeouts during the migration, but now everything appears to be great.

Finally, if you’re interested in the technical details, main components of the Supernifty architecture include:

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.