Archive for the ‘development’ Category

Online Regular Expression Tester

Friday, November 22nd, 2013

Supernifty has made available an online regular expression tester.

Of course, there are already numerous online regex testers available but in our defence, this one is fast, free, simple and easy to use.

Also, regular expressions are seriously cool; if you don’t already know them, you really should.

We have plans for more regular expression shenanigans; watch this space.

If you do try Supernifty’s Regex Tester and have feedback, thoughts or comments, get in touch!

Book Review – Python for Data Analysis

Sunday, January 20th, 2013

Python for Data Analysis is primarily a reference for Pandas. Pandas is a Data Analysis library for Python.

Also covered in less depth are some other components in Python’s data analysis ecosystem. There are chapters on iPython and NumPy. A chapter on plotting and visualization provides a great rundown of matplotlib, along with mention of alternatives like chaco and mayavi.

Pandas is then presented in significant depth, with sections on data storage, data transformation, data aggregation and time series analysis. This forms the bulk of the book.

This is a well-written book that provides a good summary of Python’s data analysis capabilities, however, it will not teach you how to do data analysis. This book will show you how to use the Pandas library.

Note: This book was provided by O’Reilly Media as part of their blogger review program.

I review for the O'Reilly Blogger Review Program

Book Review – Programming Computer Vision with Python

Tuesday, September 18th, 2012

Programming Computer Vision with Python covers the foundations of computer vision along with numerous interesting and practical examples.

Topics covered include:

  • Basic image handling and processing in Python
  • Image descriptors and points of interest
  • Image mapping and homographies
  • Augmented reality
  • 3D scene reconstruction
  • Clustering, searching and classifying images
  • Image segmentation and
  • Interfacing to OpenCV

Python forms an integral part of this book and is used throughout the book. It is an ideal language for this purpose, being easy to understand and with excellent libraries. The scientific library numpy is used extensively.

This book is well-written, easy to understand and a lot of fun. There was a heavy emphasis on practicality which I appreciated.

Typically the theory would first be explained in text, then implemented in code. Finally a practical example would demonstrate how to apply the theory.

There are some great examples. This is where the book shines.

For instance, in the chapter on image classification, we are given an image of a Sudoku. The grid location is first determined, then the contents of each cell in the grid are classified into digits.

It was great to see some machine learning algorithms applied to real problems. PCA (Principal Component Analysis) is used extensively. SVM (Support Vector Machines) and the Naive Bayes Classifier are also used to solve real computer vision problems.

The author clearly knows his stuff, often pointing out pitfalls and demonstrating many handy tricks.

A very enjoyable and recommended introduction to the world of computer vision.

Note: This book was provided by O’Reilly Media as part of their blogger review program.

I review for the O'Reilly Blogger Review Program

Speed Scrabble Notifier for Firefox

Wednesday, September 28th, 2011

If you’re a Speed Scrabble player and running Firefox, then you might be interested in trying the new Speed Scrabble Extension.

The add-on helps you keep track of who is currently online so you can easily drop in for a game. Try it out!.

Speed Scrabble is a fast, fun and free online multiplayer word game. If you’ve not played it before then check it out!

If you aren’t a Firefoxer, there are similar extensions for Safari and Chrome.

If you’re a software developer interested in seeing how the extension works, the source code is freely available and can be used for any purpose.

If you have any thoughts on the new extension, feel free to get in touch!

Python localization made easy

Friday, September 16th, 2011

Here’s a set of simple steps to localize a Python application for different translations. This tutorial provides a clear set of steps with sample code.

Step 1: Initialize your application

Here is the code to initialize your application with localization enabled:

If you can’t see the source code try here.

This snippet looks for a resource file based on the users locale. For instance, “res/” for English. If it fails to open the appropriate translation file, it falls back to NullTranslations, which simply performs no translation.

Step 2: Prepare your application for translation

trans.install() generates a global function available to all modules in your application: _().

Find all the strings in your application that you wish to translate, and wrap them with the _() function.

i.e. “Hello” becomes _(“Hello”).

This applies to parameterized strings as well. e.g. “Hello %s” % name becomes _(“Hello %s”) % name.

Step 3: Generate the pot

That’s messages.pot.

Run the command xgettext *.py or pygettext *.py. Under Windows, you might have to look for this tool. Under the Python installation directory, try Tools/i18n.

This command looks for all strings inside the _() function, and generates the file messages.pot.

Step 4: Translate

Send your generated pot file to your translator. They will replace the empty strings with the appropriate translations and return the file to you.

Step 5: Generate the mo

Save the returned file to reflect the new language that your application has been translated to. e.g. messages_De.po

Run the command msgfmt -o res/ messages_De.po to generate the required .mo file.

As with pygettext, if your system doesn’t find this command, look in Tools/i18n under the Python installation directory.

After running this command, the translation file required by the application will be in the res directory. When you’re distributing the application, make sure the res directory goes too.

Step 6: Test

On Windows XP, you can change your locale with the following steps:

  • Start->Control Panel->Regional and Language Options;
  • Under “Regional Options”, choose the locale for the translation file you have created and click “Apply”;
  • Start the Python application;
  • (Hopefully) enjoy your translated application!

In summary…

It’s straightforward to setup localization with Python once you know how.

JavaScript Task Queue – Hack it #9

Sunday, July 17th, 2011

Suppose you have a lot of tasks with completion callbacks to complete in the browser, but you want to do them sequentially. For instance, you might have a list of AJAX requests to make to your server.

This JavaScript demonstrates a simple solution:

If you can’t see the source code, look here.

Real-Time Auctions with HTML5, PayPal, and Google App Engine

Tuesday, June 28th, 2011

Google App EngineSupernifty’s latest series of technical articles demonstrates the use of Google App Engine and PayPal to build a real-time auction site.

We also show off some HTML5 and discuss some of the issues associated with designing a site suitable for mobile devices.

All pretty interesting if you’re into this kind of stuff. Check it out:

Or go straight to the source code.

Regular expression and Javascript Text Transformation Library

Tuesday, March 8th, 2011

Regex LibrarySupernifty has a new resource – Text Transformer. It’s a handy place to keep JavaScript text transformations and regular expressions.

If you’ve ever spent time building a complicated regular expression or transformation, check out this new page. Building regular expressions is tricky enough that you should only have to do it once, or not at all.

If someone hasn’t already built a regex that does what you want, submit yours to the site so that you can use it again later.

The site uses JavaScript to build the transformations, full source code for each transformation is available for perusal and modification – a useful learning resource.

You can also chain transformations together. For example, chain Extract Text from HTML with Word count to get the word count of a HTML page. Handy!

Keep track of new transformations with the rss feedRSS feed

We also have an API available so potentially the tool could be integrated into other applications. If you have ideas, or want to learn more, please contact us.

This will increasingly become a useful resource for JavaScript developers and regex writers, as well as anyone needing to do tricky text transformations – watch this spacesmile