Sunday, September 01, 2013

Pigeons

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

Rails DATABASE_URL

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.

Monday, April 13, 2009

Rails 2.2.2 to Rails 2.3.2 upgrade is incomplete!

So I was happily chugging away with Rails 2.2.2, waiting for Rails 2.3 to be released so that I could drop attribute_fu and use cool native multi-model mass assignment support.

So I 'rake rails:updated' and my test/unit tests stopped working (rspec tests worked fine, after I upgraded rspec).

I was getting the error:

./test/test_helper.rb:22: undefined method `use_transactional_fixtures=' for Test::Unit::TestCase:Class (NoMethodError)


Googling for this error message was a red herring, bringing back posts relating to an old, now fixed, bug to do with missing gems.

The actual problem is that rake rails:update did not change the usage of class Test::Unit::TestCase to ActiveSupport::TestCase in test/test_helper.rb

Once I did that, the problem was fixed. (Actually, that's a lie. I've simply assumed that the problem will be fixed once I make the edit.)

Tuesday, March 03, 2009

Rails page caching - or - getting Rails to generate your HTML for you on-the-fly

So I want some static pages. But I love how Rails helps me generate HTML (layouts, etc.)

So how about Rails generates the web page for you, then stores it to let the web server serve it statically later?

These posts show how:

http://www.3spoken.co.uk/2007/09/creating-static-home-pages-in-rails.html

http://www.railsenvy.com/2007/2/28/rails-caching-tutorial

The placement of the cached files in a different location is what I was most interested in.

However, they don't work for passenger. For that, one must look at this: http://pgrs.net/2008/12/22/mephisto-with-phusion-passenger

Monday, February 09, 2009

Select element by class in Selenium

Here's a great post:
Shows how to select an element by class for use in Selenium. Just to make sure I never lose it, I'm duplicating it here.


"Today I was writing some Selenium unit tests for our
PHPUnit test suite and needed to check if a certain navigational
tab was active. Situation in HTML:

<span class="navbutton active">
<input name="someId" value="Button 1" type="submit">
<input name="someOtherId" value="Button 2" type="submit">
</span>

I needed to check if Button 1 was active. The problem was that
with simple xpath constructs like
//span[@class='active']/input

do not work since the class may have multiple values.

The rescue was the contains function:
//span[contains(@class, 'active')]/input[@id='someId']

as parameter to assertElementPresent()."

Monday, December 15, 2008

Sub-pixel anti-aliasing in NetBeans

I have been searching for this for AGES, and have finally found the solution. NetBeans is now almost perfectly conforming to my needs.


Open up [NETBEANS HOME]/etc/netbeans.conf, and find the line that defines the 'netbeans_default_options' variable. On to the end of that variable, append the following:

netbeans_default_options=" .... -J-Dswing.aatext=true
                                -J-Dawt.useSystemAAFontSettings=lcd"


Hope it works for you!


Reference: http://ubuntuforums.org/showthread.php?t=909327

Thursday, September 18, 2008

if_not_nil

I had the idea for this, and was disappointed when I thought someone had already done this here http://blog.teksol.info/2007/11/23/a-little-smalltalk-in-ruby-if_nil-and-if_not_nil and here http://recursive.ca/hutch/2007/11/22/a-little-unnecessary-smalltalk-envy/ but was sooooooo happy when I realised they'd done it the slightly harder way.

The first line below is what I want to do (when using, in this example, Rails). The second line is how I'd have to do it with the above implementations:


User.find_by_username("ali").if_not_nil.destroy
User.find_by_username("ali").if_not_nil {|i| i.destroy}


You tell me which is nicer :-)

Here's the code:

class Object

def if_not_nil
return self
end

end

class NilClass
def if_not_nil
o = Object.new

class << o
def method_missing(sym, *args)
# ignore everything
end
end

return o
end
end

Note how we create, for the nils, a 'proxy' object that lets any method be called on it, and does nothing by defining a singleton 'method_missing' on it

You can do it!

Exception#as

How many times have we had to do the following:

begin
do_something_dangerous
rescue Exception => e
raise SomeSpecificError, e.message
end

However, then we lose the backtrace from `e'. What we really want to do is this:

begin
do_something_dangerous
rescue Exception => e
e2 = SomeSpecificError.new(e.message)
e2.set_backtrace(e.backtrace)
raise e2
end

But instead of:

e2.set_backtrace(e.backtrace)

lets use:

e2.steal_back_trace_from(e)

But hang on, how about we combine those 3 lines into 1:

begin
do_something_dangerous
rescue Exception => e
raise e.as(SomeSpecificError)
end

Consider the implementation of Exception#steal_backtrace_from and Exception#as:

class Exception

def as(other_one_class)
other_one = other_one_class.new(self.message)
other_one.steal_backtrace(self)
return other_one
end

def steal_backtrace_from(other_one)
# important to clone, otherwise the two exceptions
# start playing with each others backtraces!
self.set_backtrace other_one.backtrace.clone
end

end