Rss feed

You are currently browsing the archives for the General category.

Archive for the ‘General’ Category

PJAX-Standalone version 0.6.0 released

As the first major bit of work I’ve done on PJAX-Standalone (Pushstate AJAX) in quite some time (aside from the occasional bug fix), version 0.6.0 of PJAX-Standalone includes a totally overhauled demo site (saving future PJAX uses from the horror of encountering my design skills), in addition to the bug fixes, code tweaks and features I was initially planning.

Key changes include:

  • Updated docs & demo
  • Options to enable/disable autoAnalytics and¬†returnToTop
  • Universal Analytics support
  • Access to request information in callbacks via
  • Fixes for title handling & control click not working

A fuller list of changes found in the new version can be found in this github pull request.

The new and improved PJAX-standalone sample site is also now live.

PHP Secret Santa

Secret Santa ScreenShot

PHP Secret Santa

After a few years of neglect I decided it was about time I gave my ageing PHP Secret Santa App a bit of an update.

The original, having been the result of a spur of the moment, hacked together reaction to the idea of running a CS Secret Santa between my friends (way back when in my second year of UNI), was as you may have guessed a pretty crappy implementation. The code was awful and the word awful just doesn’t capture just how bad the UI really was. Despite this, I’ve still somehow ended up running the script almost every time Christmas rolls come around.

My newer version of the script functions, effectively, the same as my original. Rather than taking the more common approach of putting the names in to two arrays, shuffling one, then joining em back together until no one ends up with themselves, I decided to stick with my original “names in a hat” style algorithm. Mostly just for nostalgia value. The implementation effectively mirrors its real world equivalent, with each user taking their turn to grab a value from the “hat” (array of users who need gifts buying from them) ¬†and putting it back and taking another if they happen to get themselves. This continues until every user has someone to buy for. The one flaw with this plan is that when the final person comes to pick, if it so happens that the only person left in the “hat” is themselves, there a little stuck. My solution to this problem was essentially just to make them swap with another user. Which so far has worked pretty well ūüôā

Once everyone has been assigned someone to buy for, the next step is just email everyone telling them who they have. It may not be the shortest, simplest or most straight forward solution, but I quite like it either way.

The next step of the Rebuild was to try and create a “slightly” nicer looking UI, although due to my terrible design skills I’m not sure how successful this was, but on the bright side, I found an excuse to make a JavaScript Add User button.

As normal the code can be found on my github or you can use the live version here:

Please feel free to ask questions, point out bugs/flaws or even just use the script for your own Secret Santa’s.

JSnip 0.5, a Portfolio Section and a little blog optimisation.

A Photo I took in Sloveina!


As a result of¬†a holiday in¬†Slovenia (obligatory photo to the right), being a little busier than normal at work and a hint of having nothing interesting to post it appears it’s actually been quite a while since I last updated my blog.

My solution as you may have noticed is this somewhat rambling posting purportedly providing interesting information and such.

Probably the most interesting update to the estimated two people that actually read this blog is the release of my latest version of JSnip. The new version includes with it an array of bug fixes and a brand new LightBox Snippet, along with a rather snazzy little zoom animation to go with it. As always you can get the full code on Github and check out the new features on the sample page.

Probably less interesting would be the fact¬†I¬†finally got a more or less functioning version of my portfolio page¬†on-line¬†(minus quite a few projects I lack pictures for). The best part of this being my site is now finally free from those pesky “coming soon” pages, and that I’ve also found somewhere to dump a little feed from my github.

Least interesting of all, but probably still quite a nice change for anyone who actually views these pages is that the blog should now be loading signifcantly faster thanks to the addition of WP Super Cache. (Previously page loads were taking a good ice age and a half which was kinda ridiculous)

P.S. Click the Holiday Image to the right to see the new JSnip Lightbox in action.

Recent Stuff

Since I couldn’t think of anything in particular to Blog about, I thought I may as well quickly try and summarise all the random bits and bobs I’ve been working on and hacking at over the past few months.

A Javascript Game

JavaScript Game Screen Shot

JavaScript Game

Prior to starting this little project the closest thing¬†I’d¬†ever created to an actual game was a text based World of Zull mod as part of my Degree’s java module. Despite this I had always wanted to try my hand at¬†creating¬† a simple game and thought now was as good a time as any to have a go. Since¬†I¬†knew so little about creating games I opted to try and do it in a language I was¬†relatively¬†comfortable¬†in,¬†JavaScript. The added advantage of this also being that anyone with a modern web¬†browser¬†would be able to play it without the worry of having to install anything extra. Since my main aim with this project was to learn exactly how to create games myself, the whole thing is built in pure self coded JS, without the aid of any pre-existing game building frameworks.

The game itself is more or less an¬†asteroids¬†style space shooter, except with a infinite-ish game-play¬†area (something¬†that proved far more challenging than i had¬†originally¬†envisioned¬†due to the need to unload and reload star¬†fields¬†in order to prevent browsers slowing to a¬†halt.) To simplify the code i created a basic javascript¬†inheritance¬†mechanism¬†and a number of distinct objects to manage the¬†different¬†elements of the game, star¬†fields, your ship,¬†enemy¬†ship’s the HUD etc. The¬†majority¬†of the GUI consists of DOM elements¬†absolutly¬†positioned relative to a¬†central¬†div, with the ships drawn with the HTML 5 canvas API.

Over all the most challenging aspects of the whole¬†endeavour¬†proved to be coming up with a relatively accurate collision detection mechanism¬†that wouldn’t bring browsers to a crawl.

The game can be played online from my (still in development) website‘s holding page – although my latest collision detection algorithm has yet to be added to the live version.

An Updated version of the Magic Framework

Screenshot of Magic Layout

Magic V2

The new version of magic was written partially in response to working on a reasonably large CakePHP project and wanting to get a better understanding of  how MVC pattern PHP frameworks really work. Additionally it provides me with a nice starting point for small projects in which I want to use the MVC design pattern, yet want to avoid the overhead associated with many of the larger PHP frameworks (Since they are often significant overkill for a lot of  smaller projects).

The new version is a ground up rewrite including;

  • Ultra Light MVC framework, with a router and fully PHP enabled Views.
  • Database managed via¬†PEAR
  • A set of base modules to provide all the¬†functionality¬†needed for a basic user system.
  • New¬†default theme
  • Basic¬†templating support

Since the new version of magic was originally developed as an¬†independent¬†side¬†project it’s currently still within my own local SVN¬†repository¬†rather than the google code project. Once¬†I¬†get it to a¬†usable¬†state I will overwrite my now¬†defunct¬†Google code copy with the new one.

DIY Uber Desktop

Picture of DIY desktop stack

Uber Case

Since space is hard to come by in student accommodation, I spent a weekend on a DIY project to try and make better use of mine. Using a load of scrap wood, screws and a small tub of black paint a few friends (Ryan and Amy) and I set about constructing a custom container for my working desktop, gaming desktop and server pc (Which both runs my Minecraft server and streams my media around the house). In addition is also provides me with an extra shelf and somewhere to fit the switch, wireless router and external hard-drives.







Import & export MySQL database’s via the command line.

If your website, webapp or forum has a particularly large database, backing the database up or restoring it via PhpMyAdmin (or similar tools) can often cease to be an option. PhpMyAdmin for instance will generally struggle with files over 5MB, which isn’t all that helpful when your sites database is in the hundreds of megabytes, if not the gigabytes.

The solution, if shell access is available, is to switch to using shell commands instead. Once logged in to the server (via putty or the terminal of your a linux or OSX user) backing up the database is as simple as running

mysqldump --opt -h yourDBHost -u yourUsername -p yourDBName > backupfile.sql

(obviously with yourDBHost, yourUsername and yourDBName changed to whatever they are for your server)

Restoring the database again can be just as easy, using a command such as

cat file_to_import.sql | mysql -u yourUsername -p yourPassword -h yourDBHost yourDBName

Or if the server is windows based (Useful for importing database’s in to local WAMP or XAMPP databases)

type file_to_import.sql | mysql -u yourUsername -p yourPassword -h yourDBHost yourDBName

will perform much the same action.