Tuesday, September 01, 2015

N-key rollover works in Linux! Sort of....

Update: As of Ubuntu 15.10 (and I assume other more current flavours of Linux) N-key rollover now fully works, AND the capslock/numlock keys correctly turn on too.

N-key rollover is a feature-set of productivity keyboards (which the market for some reason calls "gaming keyboards") that allows more than 6 keys to be pressed and registered at the same time - this has become a selling point of productivity (i.e. "gaming") keyboards because the usual USB keyboard protocol does not allow more than 6 keys to be pressed at the same time.
I purchased a Coolermaster Quickfire TK with Cherry-MX Brown switches from Amazon (who, because of their use of private delivery contractors, ended up delivering to me at 9pm on a bank holiday Monday, for some strange reason...)
I used it in Windows 7 first. I pressed the hotkey combo that switches to N-key rollover, and had great deal of trouble getting it working thanks to Windows Update being a total piece of scum and trying to download the latest drivers from the Internet. But eventually it all worked just fine.
Then I fired up Linux when I started work, and was expecting to have to switch it back to 6-key rollover. But lo and behold - it worked! Almost... Of course, being Linux, it did not need to do the stupid "re-install each device's driver whenever you plug it into a USB port it was not plugged into before" nonsense.
I say it almost worked because, unfortunately, in N-key rollover mode in Linux, the capslock light does not ever turn on even when caps lock is on.
How do keyboards override the USB protocol's 6-key rollover limitation, I wonder? I am considering the possibility that it is presenting the keyboard as a PS/2 device being used through a PS/2-to-USB converter, as the PS/2 protocol does not have the 6-key rollover limitation.
Anyway, I now expect a 4.777777777777% (recurring) increase in productivity at work due to using a mechanical keyboard, so money well-spent.

Tuesday, June 30, 2015

Guilt trip pets


Friday, February 27, 2015

Setting up postfix to redirect all email to one local address

I looked everywhere for this solution, and finally found it at: https://www.euperia.com/development/how-to-configure-postfix-to-deliver-all-mail-to-one-mailbox/1132

In a nutshell, assuming you want the mail delivered to a user called "blackhole":

# Not really part of the solution, but you should really be doing it
sudo postconf -e "home_mailbox = Maildir/"

sudo postconf -e "canonical_maps = regexp:/etc/postfix/canonical_maps"
/^.*$/ blackhole

sudo service postfix restart

Hope it works!

Wednesday, February 25, 2015

Which ActiveJob queue does Rails 4.2's ActionMailer use?

So Rails 4.2 has something called ActiveJob - a standard adapter interface to access any queuing and background task running system like Delayed Job or Resque. And ActionMailer can, with the help of a magic method called #deliver_later, use Active Job to send emails in the background, so the controller does not get held up. Which is great!

However, reading the docs, we find that ActiveJob can have multiple queues, which can be given different priorities, for example. But which queue does ActionMailer use by default?

After much looking, the Sidekiq wiki page came to the rescue (if you'll excuse the pun). It states:

Mailers are queued in the queue mailers. Remember to start sidekiq processing that queue: bundle exec sidekiq -q default -q mailers.
The "mailers" queue! Thank you.

Friday, February 20, 2015

How to get a perfectly centered label in a row with other elements (like buttons) on the end

Setting width to 100% on left-most table cell magically makes it take up remaining space and look perfect... https://jsfiddle.net/ayqazi/0c74serz/

The text stays magically centered even when the table resizes.. try resizing the HTML box or the window.

I being a CSS expert didn't involve just knowing all the stupid little hacks that end up making it do what you want.

Thursday, August 07, 2014

Using more than one fixture function in clojure.test fixtures by combining them

I was working on a Clojure project the other day, and I encountered an issue that was something like this in one of the tests:

(ns blah
 (:use clojure.test))

(use-fixtures :each wipe-db)

I wanted another fixture function to be invoked before each test, so I added the following:

(use-fixtures :each wipe-db)
(use-fixtures :each add-some-test-data)

It turns out that doesn't work!  After banging my head against the wall for ages, I figured out that you actually had to do the following:

(use-fixtures :each (join-fixtures [wipe-db add-some-test-data]))

I could not find any usage instructions for that anywhere, so thought I would post something in the hopes of helping anyone else out.

There is also the clojure.test/compose-fixtures function, but that is more primitive and is used under the hood by join-fixtures.

If course, one could simply use midje which (IMHO) gives a better experience all round, but if you have to deal with legacy code, it's nice to understand what is going on.

Sunday, September 01, 2013


They're obviously chilling out at the coffee shop before getting their train....

Halal pork... awesome

A mistake, surely?

Tuesday, August 20, 2013

Benchmarking the Sharktoon Flexi-Drive Go Faster 8GB USB 3.0 flash drive (memory stick)

I thought I would review this drive as nobody else seems to have.

So I got this drive for use in my job as a software developer for Property Detective.  I got this drive from http://www.scan.co.uk/ because it was  USB 3.0 flash drive that rivalled the price of USB 2.0 flash drives, offering potentially superior read performance.  It is advertised by the manufacturers and the retailer as having an 80MB/s read time, and 5MB/s write time.

Here are the CrystalMark results for the drive plugged in over USB 3.0:

As you can see, the read speeds are half those advertised, and are the sequential ones.  Write speeds, especially random writes, are abysmal, but spot-on the advertised figures for sequential ones.

Since I'll be using this mainly for installing OSes on machines, it serves my purposes just fine - upload some files and then use it in place of an optical drive - the fast read speeds come in really useful there.  If you want a general purpose drive, I suggest looking elsewhere.  The write times aren't worth it.

Thursday, August 15, 2013

It's Mario... but not as we know him

A guy turned up to work at our house.  His name was Mario.  Here is a picture of him:

It's Mario!  But not as we know him.

YES, his name was really Mario.  Yes, I'm telling you, it was, no joke.

Best. Doorbell. Ever.

Best. Doorbell. Ever.

For reference (for non Brits): http://en.wikipedia.org/wiki/Pelican_crossing

Thursday, July 11, 2013


Sometimes on Rails apps, I find it convenient to connect to the staging database but stay in the development environment (so auto-reloading works, and annoying gems that behave differently on a development environment that is not exactly called "development" do not make my life difficult).  I wanted an easy way to do this rather than keep editing my config/database.yml.

I found out about a DATABASE_URL, but could not find an example of it's use for the life of me.  With enough hunting, I figured out how it is used:

DATABASE_URL='postgres://postgres_username:password@hostname:port/database_name?encoding=unicode&pool=5' rails s

Put that in a script, and invoke it when you want, and you get lovely to connect to other databases without messing with any environment or yaml config files.

Posted during employment at Property Detective - because smart buyers check the facts.

Friday, February 01, 2013

XOrg Synaptics driver for laptop clickpads

What are clickpads?   They are those stupid inventions where there are no physical buttons below the laptop's trackpad, but rather the pad itself (or at least the lower edge of it) can be clicked.  Thank Apple for that.

Well I hate them, but I'm stuck with one.  Unfortunately, there is not yet full support for them in Linux - for example, when click-and-dragging, i.e. holding down the 'button' on the clickpad with the finger on one hand and moving the finger from the other hand on the top section to drag, the clickpad notices movements from BOTH fingers when affecting the mouse.  This means that the slightest movement from the bottom finger (the one holding down the clickpad button) will affect your click-and-drag AS WELL as your top finger (the one you actually want to do the moving with).

Peter Hutterer explained this to me in the following email response:

"The problem with clickpads is that we don't know which finger triggered the click. if you have two fingers on the pad and a click is generated, we don't know which one is the clicking one. we could work around this - at least in the single-finger case - but we don't have code for that yet.
In the meantime try synaptics 1.6.3 (fresh of the release) and set AreaBottomEdge to 80% (i.e. same as your button area)."
So there should be some solace coming in the future.  However, I will still be trying to avoid clickpads on my next laptop (which unfortunately really reduces my choices).

Thursday, October 04, 2012

Scrum poker - a solution to the problem of "informational conformity"

Informational Conformity is the name given to the phenomenon whereby human beings will conform to the opinions of the outspoken majority, regardless of how a person themselves think. More can be read about it here.

The whole POINT of Scrum poker - members of a team holding up a card or a number of fingers representing their estimates of the story under discussion - is to negate this effect. If I don't know what the other guy is going to estimate, I'm FORCED to give my own opinion. In teams where I have used this technique, it has often occurred that a sole member of the group has held up an estimate that is different from everyone elses, and after discussing the reasons why, his estimate seemed the more accurate one and was adopted.

So if you get people telling you it's not needed and you can just go around asking everyone their estimates one by one, because Scrum poker seems "immature", tell them about informational conformity. Then if they don't agree, get EVERYONE else to voice their opinion in defense of Scrum poker - you'll see how quickly their opinion will change to come into line with the majority's :)

Thursday, March 22, 2012

Sunday, January 29, 2012

Vista caches files that you copy over a network - including DVD images!

So I want to transfer some DVD images (legit!) of games I own to install on a computer without a DVD drive... so I ripped them from the DVDs on one machine, and plonked them in a network share and transferred....

and noticed Vista had filled my 8GB of RAM totally up! Finally, this post illuminated me as to why: it caches the WHOLE file to memory and swap, even if it is Gigabytes large! Idiotic pile of junk.

I wish I didn't have to use Windoze to feed my gaming habit.

Edit: the "fix" from the blog post didn't work... so I downloaded netcat for Windows on both machines, and, using a Cygwin shell and the tar command transferred the files I wanted over. Microsoft messes up again, but saved by the open-source community!

Friday, July 01, 2011

URL helpers in Rails 3

I needed to access the URL helpers from somewhere that they were not available by default. You know, the users_path/edit_user_path/etc. things.

The new Rails 3 way of doing it is to:

include Rails.application.routes.url_helpers

This will NOT work if you use Rack magic to mount your app under a path, but for some reason, the normal URL helpers accessible via views or controllers will in that situation.

Saturday, April 03, 2010

Disabling Java Update on Windows

So I got this laptop for my mum.... it had to be super-simple to use, because she is not tech savvy at all.

So I disabled loads of stupid auto-update messages, disabled as much of the cruft that came with it as possible.... but could not disable the stupid Java update crap that pops up regularly. Only administrators can change auto-update settings, and if the user is not one, tough! Ridiculous..

However, Linux h4xx0rz find a way. I ran the update utility... used task manager to find out the binary executable it was.... and renamed it.

Problem solved.

The executable in question is this one: C:\Program Files\Java\jre6\bin\jucheck.exe

Right... off to have eggs and toast.

Monday, July 13, 2009

Netbeans with RSpec 1.2.7

Another RSpec upgrade, another broken NetBeans RSpec bug...

The latest netbeans nb_rspec_mediator.rb (that comes with NetBeans 6.7, or can be downloaded separately from the NetBeans code repo for NetBeans 6.5) does not work with rspec 1.2.7

Here is a fix (ymmv): http://www.nabble.com/Using-netbeans-with-rspec-1.2.7-td24390115.html

Running specs by line number still does not yet work for Rails apps (although strangely works for non-Rails apps)

Thursday, April 16, 2009

restful_authentication vs. nifty_authentication

Update 2: even my last update is obsolete: I now prefer to use either Devise, or roll my own authentication.  I might go back to authlogic as I like the idea of a system that lets me do my own routing/controller stuff while taking care of the signing in / password checking / etc. for me.

Update: this is all now obsolete. I am using authlogic now, as it seems much more flexible - it follows the trail blazed by restful_authentication, but just seems less unobtrusive, and seems to have a very nice, clean design.

So searching for the above does not really reveal anything useful, apart from a commit message from a bloke on github. So I asked him to clarify the differences between restful_authentication and nifty_authentication plugins for Rails.

Here's what he said:

The reason I chose nifty_authentication over restful_authentication is because restful_auth adds a bit too much code. Making nifty easier to add on your own code. So it basically boils down to what do you really need, if you only need user registration/login I prefer nifty. But if you want some of the more advanced features I’d go with restful_auth, like aasm-support, email class, OpenID and activation links which are all built in.

Very useful. The game plan is now to use nifty_authentication, then switch to restul_authentication if I need any advanced features.