Recent Updates RSS Toggle Comment Threads | Keyboard Shortcuts

  • Dark Liquid 6:50 am on April 9, 2012 Permalink | Reply
    Tags: , , , , radio   

    My First “Proper” Node.js app 

    So over the weekend I cranked out my first proper node.js application. It’s a very simple frontend for controlling MPD (the music playing daemon). When I say simple, I mean just a start and stop button and a button to ask it to update its track database. It’s designed as a simple tool for G3 Radio to control the automated jukebox they run between their live DJ shows. More features are on the cards as per the wiki for the project, but at the moment it does the job.

    It’s using express.js as the webservers and mpd-socket for talking to MPD. I have it load JSON files for its configs. I’m using the lovely everyauth middleware for auth against a flat file, which takes all the pain out of that process. It was pretty easy to write after I wrapped my brain around some annoying issues I was having.

    Anyway, if you fancy seeing some bumbling attempt to make a node.js application and/or need something like what I’ve described,  check it out on github: g3hal on g3radio @ github

     
  • Dark Liquid 9:28 pm on March 31, 2012 Permalink | Reply
    Tags: cucumber, , , testing   

    Automated Web Testing With Cucumber, Selenium and a custom fixtures server 

    Recently I’ve been working on a website that is a single page AJAX driven application that’s essentially just a frontend to an API, rather than doing any of it’s own processing.

    For testing it I wanted to be able to test without hitting the API but since the application is so javascript heavy and makes use of various complex workarounds for various browser issues, testing it using the usual methods never worked and only “real” browsers cut the mustard.

    I’ve tried a number of headless browsers such as zombie.js but they’ve all had issues so I’ve settled on using selenium for testing in a real browser. The other issue is that most web application testing systems assume at least some kind of backend system that you can then mock the http calls of. However in my case the entire app is client side and has no server at all, so doing that wasn’t an option.

    The solution I came up with was a cobbled together selection of rake tasks, shell scripts, a custom node.js server and some hooks in cucumber to set up fixtures.  I run my tests against a live server through a recording proxy to get the results of the API calls, then format the results into little fixture files to get loaded by the fixtures server based on tags on my cucumber scenarios. It’s quite a flexible setup now it’s running, the only chore is writing the fixtures, though hopefully I can knock up a quick script to generate the fixtures automatically from my proxy recordings.

    I wont go into the details of running cucumber with capybara and selenium, since those are already well documented elsewhere, such as on the capybara github page. However, I’ll run through my scripts.

    First off, I have my bash script to actually setup my server and run all my tests, it goes a little something like this:
    UPDATE: Made some amendments thanks to suggestions from Ralph Corderoy in the comments.
    UPDATE 2: Removed set -eu line since breaking out on errors means not shutting down the fixture server when tests fail.

    What is happening in the above should be fairly obvious, but essentially I’m running my fixtures server and capture it’s PID so I can shut it down later. I wait for a bit, then execute my tests via a Rakefile, then I send a command to the fixture server to shutdown, wait for a bit, then force a shutdown in case it’s not done it already. Simples!

    The fixture server can be found in my random scripts repository on github. It’s hard-coded to run on port 7357 but that’s easy to change. I’ve tried to document how it works in the code but a gist of it is that the fixture server will server static assets but fall through on all other requests to look at whatever fixtures it has loaded. By default, it will have loaded no fixtures so will 404. However, it has some special URLs for loading in fixtures. On /_fixtures/load/:fixture the server will load a json fixture file with the name :fixture.json. Multiple fixtures can be loaded for the same path and the server will work it’s way through them, serving each one once until it has no more where it will then 404 again. Fixtures can be cleared from memory with a call to /_fixtures/clear and you can inspect the currently loaded fixtures by calling /_fixtures/inspect. A call to /_fixtures/shutdown will instruct the server to shut itself down. At the moment the fixture server only supports loading fixtures for GET and POST requests as that’s all I’ve needed, but it’s easy to extend that.

    The fixture files themselves are very simple. Here is an example one:

    In the above fixture file, the server is setup to respond with a failure message the first time it is accessed with a GET on /test, a redirect the first time it is accessed with a POST on /test/post and a success message the second time it is accessed with a GET on /test.

    In cucumber, using the stuff I’ve mentioned above, we can now do cool stuff like configuring fixtures for each scenario. I use something like this to setup my fixtures:

    I slap that in a .rb file in my features/support directory and I can now use the @authed and @notauthed tags to load the appropriate fixtures into the server, like in the following feature:

    You’ll notice that I can do cool things like load multiple fixtures by specifying multiple tags. The fixtures get loaded in the order that that tags appear so I can create fairly complex fixture scenarios from simple individual fixtures.

    All in all I’ve found it a reasonably nice simple way of being able to test client-side only apps that drive APIs without having to hit the actual API server. Obviously if you are developing your own API server as well, you should be writing tests for the API server in addition to the client, but this way to can keep them nicely de-coupled in your tests so you don’t have to hit live data, which based on your project might be impossible to test against anyway.

     
    • Ralph Corderoy 11:16 am on April 1, 2012 Permalink

      Nice write-up, though I stumbled where you nouned apply! My brain is wired to know that word has one meaning and sound. Perhaps ‘appli’, if not ‘app’? On the bash you may like to know &> does the job of > followed by 2>&1, e.g. &>/dev/null, and ‘set -eu’ is always handy at the start of a bash script, e.g. curl(1) fails, though you’d expect the kill(1) to fail; kill $PID &>/dev/null || true.

    • Dark Liquid 3:32 pm on April 1, 2012 Permalink

      That use of apply was a mistake caused by writing the original draft for this article on a phone. Bloody auto-incorrect!

      I wasn’t familiar with the set flags, but yes, having looked them up that makes a lot of sense. As for the &> shortcut I was aware of that but for some reason I keep finding myself using the long form regardless. Old habits I guess :)

      Thanks Ralph, I’ll amend the script accordingly.

  • Dark Liquid 11:22 am on March 9, 2012 Permalink | Reply
    Tags: , , , jquery   

    http://blog.multiplay.co.uk/2012/03/using-the-jquery-deferred-object-pipe-method-to-validate-success-data/

     
  • Dark Liquid 7:00 am on February 7, 2012 Permalink | Reply
    Tags: , ,   

    Updates 

    So life has had some ups and downs recently but nothing I feel too inclined to elaborate on. None of my plans have really worked out so far, the exercise hasn’t really happened nor the writing or work on other projects. Driving is still going fine despite a busted alternator and other minor issues. Money, money, money.

    I recently signed up for Netflix. Seems like a cool service but had such an appallingly poor selection I cancelled before my free trial ran out. Also, I couldn’t find a way of getting it working on the PS3 as there seemed to be no app available unlike LoveFilm. Speaking of which, I’m loving. Much better selection and nicely working on the PS3. Cheaper too for the streaming only package. I finally got to see the black and white French film Angel-A, a film I’ve been wanting to see for a long time. It was everything I had hoped for, a really beautiful, quirky film. I’m liking these streaming services, they are actually making me watch films again. CONVENIENCE, PEOPLE! This is what the industry needs to pick up on. People are cheap and lazy, make your damn products to fit instead of sticking your head in the sand and hoping everyone will change to suit.

    Work is fun. I’ve been working on a big project for some time now, getting into UX as well as working with some interesting tech, playing with the new-ish HTML5 technologies. Fun stuff.  I still sucks though, just slightly less so.

     
    • Lorcian 11:42 am on February 7, 2012 Permalink

      Taking my theory in a weeks time, not looking forward to it. 55 questions… and I can only get 5 wrong. Not going to be much fun. So, I’m going to probably have to spend the next few days really cramming for it. I’m hoping i’ll pass, it’ll encourage me to see the whole thing through to the end. Sorry things havnt been too great for you. Things will pick up though, they always do. eventually.

  • Dark Liquid 2:57 pm on January 16, 2012 Permalink | Reply
    Tags: , , php, wordpress   

    Just wrote a quick article about setting up contextual help in wordpress plugin on the Multiplay tech blog. Read it here: http://blog.multiplay.co.uk/2012/01/updated-contextual-help-in-wordpress/

     
  • Dark Liquid 9:30 am on January 14, 2012 Permalink | Reply
    Tags: gaming, ,   

    New Years 

    So, it’s a New Year. This year starts off with me being poor having spent obscene amounts on being able to drive. Debts are mounting up across all the various accounts but hopefully everything will work itself out. I’m hardly in such a bad state that I can’t dig myself out of it.

    I generally don’t make resolutions for the New Year, but I am going to try and do some more exercise. Having spent the last 4 years or so essentially sat on my ass the whole time, I was shocked a few days ago when I did some simple exercise to find that pretty much all my strength has gone. Not really shocking, given my activity levels, but it really made the point that I need to do something before I turn into some fatty spherical lump that lift a fork without losing his breath. Taking the typical geek route, I’m focusing on statistics, statistics and more statistics. I’m hoping actually tracking and graphing staff might gave me some immediate visual goals to reach for, since just doing exercise, as a participant with no tracking, never feels like I’m making any progress, which is never encouraging. Hopefully Fitocracy and/or RunKeeper will provide some much needed guidance and motivation.

    Since working for Multiplay, games have become a large part of my life again. Having now bought over 300 games in the last 2 years, I have quite a large back catalogue to play though. Typically these are all indie title but for a few more mainstream items, since that tends to be where my interests lie. [Generic FPS] just doesn’t interest me, though I will say that I’m enjoying the independent, single-player only Hard Reset immensely at the moment. I’ve played a lot of Skyrim recently, which has been a lot of fun. I’m always amazed by the things fans will do, and this beautiful track by Malukah Fenix certainly qualifies as amazing:

    My writing has taken a bad hit this last year. I’ve barely written anything or read anything for that matter (well, barely read anything means less than 20 or so books in the year for my appetite :P ). There are many stories I want to finish and that a few people on Protagonize want to see the conclusions of, so I need to get back on the saddle. I had said to myself last year I would try and seriously pursue publication, but that hasn’t happened. I’m hoping this year, now I have more time due to driving to work, things will be different, but if I’m entirely honest with myself, I doubt I’ll put the required time or effort into making a serious attempt. Not only is it a lot of work, it’s quite intimidating. I do want to finish at least one novel though by the end of the year and hopefully get into the meat of editing it with an eye to publish it independently, for kicks, since I’m not sure I’m even interested in mainstream publication or actually making a living from writing.

    I’d also like to try and get back into music again and I have a computer game I’ve been meaning to develop for some time. So many projects, so little time.

    Lets hope the time thing changes this year. Or, more proactively, let’s actually try to change that this year.

     
  • Dark Liquid 1:39 pm on December 2, 2011 Permalink | Reply
    Tags: cars, driving, insurance, , ,   

    So NaNoWriMo is over, though if I’m honest it ended for me barely a day after I began so I reach December with barely 1 days worth of words written, let alone the whole 50k minimum. I wasn’t really expecting to have the time or energy to work on it, as the commute to work after 2 years is starting to wear me down, so I’m not really too cut up about it.

    And on the happy note of the commute, I finally passed my driving test. I passed it by the skin of my teeth, more by luck than I’d like, but hell, I’ll take the win after the umpteen failures I’ve already collected. Now I have the fun, fun, fun time of trying to get car insurance that isn’t cripplingly expensive. It’s looking might it actually might be cheaper to buy a brand new car on finance and pay the insurance on that, as the insurance on my current car (which depressingly I realise I’ve owned for almost a year without being able to drive it) is more than double the quotes I’m getting on new cars and the finance costs of new cars over 5 years or so are roughly equal to the insurance premium (which should hopefully drop after the first year) whilst also having better fuel economy. Kinda sad that I buy a used car, only to find almost a year later it’s as if not more expensive for me to own and run than a brand new one.

    Money, money, money! Arrrrgh!

     
    • Chelle (@Asheyna) 5:37 am on December 3, 2011 Permalink

      YAY for the test! Driving is cool, like bow ties, and fezes. Good luck with all the car stuff… I hate gov’t/administrative crap… makes me want to buy an island (you’d be invited of course).

  • Dark Liquid 5:43 pm on October 26, 2011 Permalink | Reply
    Tags: ,   

    NaNoWriMo Cometh! 

    NaNoWriMo is on the horizon once again. After putting out a call for suggestions on what story to develop via Google+, the story Crowd Dodging won out, so this years NaNoWriMo will be a tale of three teenagers inventing their own sport, losing control of it to big media and then fighting to take it back.

    Or it will be, if I can actually get it written.

    I’ve been having trouble outlining it, coming up with scenes, etc. The idea just don’t want to form in my head. This is typical of me, I’m not a great planner in any sphere, for example in programming I find it much easier to think through ways to do something by trying the actually code a solution, rather than by planning it all out with flow charts and everything else beforehand. However, I do like having lots of goals to meet, which, without a plan, is quite hard. I think instead I might have to outline as I go and use my notes more as a map to refer back to for consistency, rather than as a guide of where to go.

    However, what I have done so far is working out well. I’m using Zim, a desktop wiki application to keep notes, which I save to a dropbox folder so I can access them wherever I go. Mapping out my protagonists is going reasonably well, I’m currently using the Dresden Files RPG character generation sheets to flesh them out a bit (the game uses FATE as a rule system, which is fairly story-focused and works very well). I’ve been doing with using Fiasco or Do as scene generators, but neither really suit the genre I’m writing for, so I’ve not bothered.

    The worst thing though is that I’ve been quite busy recently since getting off holiday, so I doubt I’ll have much time to develop my outline further or even get any writing done. Which is why I’m worried about not having an outline, because without clearly defined goals, I’m likely to flounder in the limited time I do have!

    But what the hell, lets have a go anyway.

     
    • Chelle (@Asheyna) 6:09 pm on October 26, 2011 Permalink

      Well you’ll have me cheering you on! And giving you random weird suggestions for scenes. I too am having trouble plotting too much of my novel, no real clear outline although I know the major plot arc from beginning to end. I plan to just see what happens.

      I hope you find the time to write it, Crowd Dodging is such a neat concept!

    • Mykell 7:46 pm on October 31, 2011 Permalink

      Love it, and so excited. I hope we both make our count this year…

  • Dark Liquid 3:54 pm on October 18, 2011 Permalink | Reply
    Tags: ,   

    Help me choose a project for NaNoWriMo

     
  • Dark Liquid 7:11 pm on October 15, 2011 Permalink | Reply
    Tags: , , , unity   

    Unity 

    So, I’ve been using Unity since it’s official release in the last update. With this new release, I though it about time to talk about it.

    Now, Unity gets a lot of mud thrown at it. The main complaints I’ve seen are it ‘dumbs down’ Linux. I don’t think this is true. However, it does lack some things, things that for me define the Linux experience, and that annoys me.

    These things mainly are configurability. This isn’t to say that it isn’t configurable, but rather that a lot of this configuration is hidden behind arcane, invisible methods like the gconf system for example. Linux for me has always been about providing an environment where the user is in control, where everything can be configured and where the configuration of those programs is relatively standardised and easy to do (easy being a relative term here, I doubt anyone would argue that the sendmail config file is easy, as an example of the bad end of the scale). I found Unity to fail at providing this kind of environment. Sure it gets out of your way and lets you ‘just work’, but it does it by hiding a lot of things unnecessarily, rather than being an elegant solution.

    Now that the main negative is out of the way, it’s time to move on to the positives.

    Generally, I found the workflow in Unity not much different to my usual one. I was annoyed to find my Win key hijacked away from my usual Synapse/Gnome-Do program but I got used to it. The global menu I found fairly easy to get to grips with and it didn’t cause any problems. I quickly learnt to always look up for options. This might be due to having some experience with OSX though for a number of years, so for a new user or one experienced in non-global menu systems, it might be more disconcerting.

    Apart from it just ‘getting out of the way’ I didn’t really find it did much for my workflow at all. Since I try to avoid using the mouse, I did basically what I did before – trigger the application search to run an app and use the keyboard to switch workspaces. I didn’t really use the icon bar as I could generally type the name of the app in the search before I could remember what the icons did or what Win+Num shortcut mapped to them.

    The notification icons not showing was a massive problem as a lot of apps I used didn’t support the new system and so I had to hack around in the gconf settings, which I would have never discovered if not for others posting solutions. I found on my dual monitor system that the system tray icons would have issues – some would only work on the primary screen and not the other, the ones on the right never triggering or only flashing their menus intermittently only to whisk them away instantly.

    I didn’t find it all bad though and I think for the mass market, the new user that only wants to use what’s provided through the ubuntu software centre and has one monitor, it does it’s job. However, I found it to be quite hostile towards customisation, something I’ve never associated with Linux before. It seems to me to be trying too hard to be OSX, providing a single end-to-end software eco-system and user experience. This isn’t a bad thing, after all, OSX is very popular for a reason and it does provide a very tight, well balanced system if you want to do things in the way it provides.

    I think there is a place for Unity, but it’s not really for me. I’ve found Ubuntu have developed this OSX style philosophy further in 11.10 and I found myself not liking it at all. On my main desktop machine I’m now trying out GNOME Shell, in the hope that it provides a nice balance between what a Linux system means to me and a productive, uncluttered desktop that gets out of my way and just lets me work. After using it for a while, I’ll write up how I feel about it.

     
c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
shift + esc
cancel