Posts in "General"

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


A Photo I took in Sloveina!

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 Thybag.co.uk‘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.

Blog reboot.

Seeing as this Blog has no readers, I’m not entirely sure who this post is aimed at. That said, for some reason I feel compelled to make this post anyway – in much the same way I imagine most people do when they create a new blog themselves. So here it is!

New design, check. Rambling and incoherency (kinda) first post, check. Motivation to actually use this Blog properly, check.

Now, just for the reason this blog may as well have some content. I was asked earlier today how best to select rows from a database where a particular number existed in a comma separated list inside one of the fields. The issue being that performing a straight

SELECT * FROM 'someTable'
WHERE  'someRow'  LIKE '%7%'

would end up pulling in any records containing 77/27/73 along with the actual rows required (in which the number 7 itself actually existed). My off the top of my head solution was to include the comma’s in the query, which resulted in somthing along the lines of

SELECT * from 'someTable'
WHERE   'someRow' LIKE '%,7,%'
OR      'someRow' LIKE '7,%'
OR      'someRow' LIKE '%,7'

which would theoretically be able to get the 7 in any place while still excluding any numbers such as 27, 77 or 72.

If anyone knows of a more elegant solution to the problem it would be interesting to hear. Also any feedback/criticism on the new Blog layout would also be great.

By Carl on June 15th, 2011 in General

Focus

Focus is a useful skill. One I often feel I lack. The more I should be doing one thing, the more my brain wants to do something totally different. For example, I decided to sit down and try and  finish off a few more aspects of my main website: thybag.co.uk. Instead I ended up installing, learning how to theme and themeing this WordPress Blog and creating a small porfilo site around it. Although on the bright side, it does give me somewhere to complain about these things.

The focus issue at late seems to be even worse, I have exams at uni, which in most peoples mind would warrant me putting my focus in to revising for them. Well, not me. The knowledge i should be doing revision, combines with my natural procrastination instincts to drive me to do, what is actually a pretty impressive amount of work, on something totally different and unrelated. The result this time being that I’ve started and made quite a big of progress in to developing and constructing a brand new open source project (Magic).

I originally managed to justify it to myself, by claiming it was obstensably revising for a dynamic web exam that was coming up, But thats now long gone and my developemnt pace hasn t slowed all to much. My justifcantion also seems signifcantly weeker concidering the upcoming exams are on interface design, C and algorthums.. But hey, in reality isnt writing this blog just futher procrstination? If thats the case, i must resign myself to the fact im doomed and by doing that successful judtify getting another revision of Magic out the door by tonight. Yay.