In a nutshell:
As a discussion of microservices grows longer, the probability of a comparison involving Netflix approaches 1
]]>First the simple case – a generic method (just wrapping a call to a Javax Response.readEntity)
1 2 3 4 5 6 7 |
|
And here’s the syntax of a method that takes a GenericType object as argument (ie, which can take the class of a generic type as an argument), and for the calling that generic method.
1 2 3 4 5 6 7 8 9 10 |
|
One of the trickier aspects of this whole game, is what to name the identifier of the type parameter. You cant call it “class” as that’s a reserved keyword and opinion seems to be divided between “clazz” and “klass”. In this example I’ve opted out and called it “type”.
]]>I’m sure lots of people use the following pattern. You write a method that takes a heap of arguments, but which can have some defaults. You then introduce one or more overloads, with progressively fewer arguments, and sensible defaults filled in.
To avoid duplication of your actual logic, the overloads only add the defaults, and then call the original, many argumented method. For example:
Original pattern:
1 2 3 4 5 6 7 8 9 |
|
So that was fine, But then things moved on, and I needed to introduce a little more complexity in the form of an unknown number of arguments using varargs. So I simply added a new method, migrated the logic and refactored to something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
The middle method in the above snippet doesn’t work (and throws infinite recursion warnings) as it simply calls itself, rather than the varargs method with a single argument.
What confused me is that I googled about a bit, and couldn’t find any discussion of what to do in this case, so I tried the following, and felt pretty pleased with myself.
1 2 3 4 5 |
|
But of course – I was completely missing the point. I didn’t need the single argument overload as calls with a single argument already call the varargs overload! So it just needs deleting – and happy days.
1 2 3 4 5 6 7 8 9 10 |
|
1 2 |
|
Works fine if you delete the single argument method. Of course. Face palm.
]]>It turns out there is a poorly documented feature, the .nvmrc file. Simply drop one into your project folder, and in it just put the version number of node (or one of NVM’s aliases, such as ‘stable’).
1
|
|
As simple as that! Then open a new bash session and browse to your folder, node should be up and running.
]]>Longer: All this does is provide a light, mobile optimised (ish – see below) page that redirects you to TFL’s existing mobile departures pages. It’s pointless, and TFL do have such a page of their own now. But most of my pet projects are more about having fun and solving a problem.
So, for this project I’ve used some things, and learnt some things:
It’s also my first (fairly unsuccessful) attempt at a mobile first design. It’s already looking better than it did thanks to some of my awesome colleages helping me out a bit.
It’s all on github here (unusual for me, as I usually use bitbucket). Pull requests welcome.
PS – I think this would be awesome on a .London domain name, but they cost about £30, so that’s not happening unless someone want’s to sponsor me!
]]>The first thing I did was lookup a photo of the relevant train (google images) and doodle a sort of caricature of it onto a post-it note one lunchtime at work. The gist was to simplify the look so that it would look reminiscent of the real thing but sufficiently “toy like” that it doesn’t look over detailed and fussy on a model only 11cm long.
For example – 10 windows becomes 4, or even 3 on the driving ends, the driver’s door vanishes, as do the corridor’s between coaches and lots of little outline details etc etc.
I formulated a plan to find an existing Brio compatible train, cannibalize the wheels and bogies, knock up a new wooden body, and join it all back together. Then I discovered that BigJigs sell a wagon that is simply a rectangular block already.
I bought six of these, sanded off all the paint, unscrewed the bogies and wheels, and sprayed them with a toy-safe aerosol white primer/undercoat. I then carved the ends into a simple approximation of the driving ends of the class 444 trains.
Next I learnt how to use Inkscape (this was actually a bit of a joy to learn and use) and drew up a design as an SVG. I drew the side view first, which I then extended to span the roof and opposite side. The full drawings are available to download from bitbucket here. They’re free for your own use, legal bit follows:
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/.
The simplified side-only view is shown below.
The first attempt at getting the design from computer to toy was not successful. I read that you can use iron-on inkjet t-shirt transfers on wood. The short answer is you can’t. The longer answer is that when you heat it with an iron, the transfer melts and becomes very slimy and slippy, at which point it slips and smears all over the place. Your mileage may vary, but I gave up.
The second plan was to try getting some inkjet water-transfer paper. But because I was up against a deadline (Christmas) I ran out of time to order some off the internet. I’d still like to try this, but at the time I fell through to plan C.
My final attempt was simply to print the design out on paper, and glue it onto the model. I painted the ends black and yellow by hand. The end result actually looks OK. I then lacquered the whole thing with a toy-safe semi-gloss aerosol varnish/lacquer. When it was all dry, I simply screwed the bogies back on (making sure to check the magnetic couplings were in north/south matched pairs, and that the two driving cabs had the opposite polarity, so they would join together) and I was done.
A quick note on toy safety. There are lots of European standards on things like toxicity of paints, and more importantly – small parts that could be a choking hazard. This model probably doesn’t meet them, and you should treat these as novelty/models not toys for tiny children (at least not children so tiny that they still chew on everything they see). For toy safe paint and Varnish, check out the Painter’s craft range from Rust-Oleum (check the label to make sure, as not all Rust-Oleum products are safe). Or look for any paint that conforms to the EN-71 standard.
And that is how I arrived at the final result. Let me know if you like it, or if you try it for yourself.
]]>I had remarkable trouble googling for this problem, hence this keyword laden post. Basically if you come across a single pipe (or bar) symbol inside double curly brackets then you might think that this is a mistyped OR symbol, or if you’re a bit more JS savvy, a bitwise shift operator. In fact you have to remember that angular expressions are not vanilla javascript – they are parsed by angular itself and have their own syntax. The single pipe is in fact a filter operator which slightly confusingly is often used to format numbers, for example with localised decimal seperators.
I had to go on quite a google treasure hunt to find that out, so hopefully this can act as a bit of a signpost for the curious in future.
]]>So this year I’ve made him and my 2 year old niece a joint Christmas present of a custom, one of a kind Brio style train, which is an accurate (ish) caricature of a SouthWest trains class 444 Desiro. These little wooden trains are awesome, I’ve never met a toddler who didn’t like them. There are a bunch of different manufacturers, of which Brio is just the most famous.
Some of the models are just generic “toy trains” but others are models of real trains past and present, but they’re mostly based on either German and American trains. So I made some that look like the trains you can see at my brother’s local station in Petersfield, specifically, a SouthWest Trains Class 444.
Here’s the end result:
Full details of how I built it, and the designs for the sides and top to follow in another blog post (if I get around to it).
I got around to it! I’ve written up how I made the trains in another blog post.
]]>(Get-Module (Get-Command Some-PowershellModule).ModuleName).Path
]]>You can fly around with the cursor keys and mouse (Babylon default behaviour). Then hit the ‘a’ key to trigger an animation (and an error – after which you can’t fly around any more!) [Edit – fixed thanks to the peeps over at the HTML5 game devs forum]
The whole reason I wanted to do this was for fun, and to try and provide a visualisation for this 3d dogfight Code puzzle, but someone beat me to it, so now it’s just for fun.
]]>I thought I ought to tell people about them. So here’s one of them:
From the Greek: Chronos (time) and horan/horama (see/view). (Name only recently made up and liable to change at any moment)
The gist of it is: a sort of time traveling google streetview of my own garden.
I’m currently working on a bit of hardware (because that’s fun). A motorised turntable, controlled by an Arduino, that can position a camera quickly and consistently. The x-axis turntable is almost ready to be sent away for laser cutting. The Y axis is going to be phase two and will be a bit trickier. It’, still in the mulling-over phase. My progress so far is now public and open source on bitbucket.
Phase three will be to get a raspberry pi to control both the turntable (via the Arduino) and the camera (via usb) to take a whole panorama automatically. Coincidentally, the same setup could probably serve as a gigapixel rig or a time-lapse setup.
Finally, once I’ve got a few panoramas, I plan to shove it all up on a website so you can pan and scroll around a virtual view of my garden (or anywhere else). The nifty thing is, there will also be a control to travel back in time to see the same panorama on a previous date.
I’ve got a new garden I don’t know very well and I often find myself trying to remember what was growing in a spot months earlier so that I know if I’m about to hide/enhance/kill it. If I can take seasonal panoramas, I can simply refer back to the website and see that nondiscript bush (A) was covered in flowers last summer, while non-descript bush (B) is a sucker that can get hacked, hoicked and composted with appropriate malice.
I’m not re-inventing the wheel, I’m merely re-implementing it. How else do you learn to be a wheelwright?
More accurately, it’s fun, it’s blog fodder and I want to.
]]>Anyway, it doesn’t come with a .desktop file for unity/ubuntu, so I knocked one up, which I published as a Github gist.
By default, qcad is installed by just unpacking into /opt/qcad[…]/ and run from the command line. If you drop the desktop file into either /usr/share/applications/ (for all users) or ~/.local/share/applications for the current user (create the folder if it doesn’t exist). You should then be able to find the icon/launcher in unity, and be able to pin it to the sidebar if you wish.
]]>So instead I went with cisco’s own anyconnect client and it seemed to work fine. First, just browse to the vpn address in a browser. Ours is something like:
1
|
|
If you have java enabled in browser the client should download, if not (like me) wait for it to time out and you’ll be presented with a link to a shell script which installs the cisco vpn client. Give the script execute permissions and run it with sudo*
1 2 |
|
Then I simply found the cisco anyconnect client in the launcher, type in the vpn url (without the https scheme), username and password in the box, hit connect, and it seemed to work fine.
Edit: I’ve since found some links to uninstall instructions on ubuntu forums and cisco’s site, the gist of which is, run another shell script:
1
|
|
*As this came from inside my trusted client’s domain behind valid ssl I assumed it was safe. On your own head be it if you go running random shell scripts on your machine as root and you end up getting a new mortgage in downtown Vladivostok.
]]>1 2 3 4 5 6 7 8 |
|
If the file isn’t found the full path is barfed out so you can figure out where you’re going wrong. No more randomly adding “../” into paths. I really wish something like this happened out of the box, but I guess you’d be leaking a lot of internal system info by default.
]]>In addition to using sudo, you need to edit the font preferences in the user’s preferences as opposed to default preferences (apparently the platform prefereces override the setting, and are between default and user in the heirarchy, but not listed in the menu for some reason).
I copied the font size property from the general preferences, and pasted it into the user prefs, which looks something like:
1 2 3 |
|
Feel free to comment if I’ve misunderstood this :)
PS – the same seems to be true of entering your license key – make sure you start sublime using sudo, or it wont persist.
]]>First, download the drivers. They come as a self extracting zip file (windows .exe) from the Xerox support website here.
Then you need to use Wine to unpack the zip, this turned out to be pretty easy.
1 2 3 |
|
That will unpack the zip, then you play hunt the files, the default location for me was ~/.wine/drive_c/Xerox/WC78XX_PPD_Driver
Then fire up the printers dialogue from System Settings, and add a new printer. At this client I then chose
1
|
|
The host and queue were provided to me by the client in the form:
1
|
|
In the Dialogue box, put just the ip address (not scheme or path) into the Host field, and the queue name into the queue box (duh).
Finally, for this client, they have a follow you printing system, so you have to get your id card registered with your computer username, so that your print jobs get delivered to you when you visit the printer.
]]>I’ve written a Ruby script (my first!) to convert the BlogML from Subtext into Disqus’ wordpress based custom XML import format.
BlogML to Disqus custom XML import Ruby script
Things to remember:
We’re calling it from a Dropwizard java service, which used Jersey’s client under the hood, but when we posted an event into Cube, we got a slightly weird error, a 400 (bad request) with the following message:
1
|
|
add the following to the httpClient section of your Dropwizard config,
1
|
|
What seems to happen is that Jersey’s client gzip encodes all requests by default, (and duly sets the Content-Encoding header to gzip).
We used Charles Proxy to look at the request – and noticed that the first character of the compressed request is “1f” in hex, which happens to be the hex representation of the offending unicode character “\u001f” (which is an obscure non-printing control character, and a big fat red herring.)
So either Cube, or node or something is unable to accept gzip encoded requests, and barfs out a bad request.
]]>1 2 3 4 5 |
|
The Alias is optional really, as a function in bash_profile can be invoked from the command line directly, but it let me have a descriptive name in the source and a very short name on the command line.
I also created another one that’s case insensitive and with a wildcard appended (in case I can’t event be bothered to type “*”)
1 2 3 4 5 |
|
rake generate
I got the following error:
1 2 3 |
|
Edit Following a comment from Josh below, I’ve tried his suggested fix of upgrading the version instead – delete your Gemfile.lock and edit the version of rake specified in your Gemfile to 10.1. Job done! It’s working fine as far as I can tell. /Edit
Not really understanding ruby, bundler, gemfiles et al, I hit the g**gles and figured out that this was probably because I built another unrelated project which had specified a higher version of rake in it’s gemfile, and by the magic of gems, the new version was installed. The local (to octopress) gemfile.lock specifies the lower version, and refuses to work with the higher version. (As far as I can figure out, Ruby and Gem versioning is the new, DLL-hell).
The work around mentioned in the error message (bundle exec) is to invoke rake as follows:
1
|
|
This works, I gather it causes bundler to dynamically find the version specified in the Gemfile.lock and use that for this one invocation, but it’s bit of a kludge.
You could paint-over-the-rust by adding a bash alias or something to reduce the keystrokes, but a slightly more fixy fix is to run the following (found in this blog post and it’s comments)
1
|
|
This gets all the gems, in the versions specified in your gemfile.lock, and puts them into a bin directory local to the project. From then onwards, for that folder, you don’t need to care and can just invoke rake as normal.
This didn’t actually work for me, probably because I use rbenv instead of rvm, so some more searching turned up a plugin, rbenv-binstubs that sorted it out: (it was super easy to install, just clone the github repo straight into a rbenv plugins folder).
Finally, add the following line to your .gitignore so that the bin folder doesn’t get checked in.
1
|
|