Author Archives: tomblench

Array equality in JavaScript – functional style

So it turns out there is no built-in test for array equality in JavaScript. There are some suggestions here on StackOverflow, but I wanted to see if there was a simple answer using Functional Javascript.

Here’s my attempt:

ArrayEq: function(a1,a2) {
    return reduce("x && y",true,map("x[0]==x[1]",zip(a1,a2)));
}

Reading from right to left, the zip transforms them into an array of pairs, then each pair is compared, and then the reduce applies the && operator to each boolean result in turn.

Posted in Uncategorized | 1 Comment

Quick random passwords

I’m sure there are lots of password generators out there, but a quick way of achieving this at the command line is something like


cat /dev/urandom | dd count=1 2> /dev/null | base64

Then copy and paste as much as you need. The result will be fairly unmemorable, but apart from OS login passwords which need to be typed, most logins can be automated, eg by using user:pass@host style URLs.

Posted in Uncategorized | Leave a comment

Twitch Mix #4

50 Min Indie Disco/Noise/Electro

Tracklisting

The Presets: This Boy’s in Love (Lifelike Remix)
Pryda: Rakfunk (Original Mix)
Alex Metric: Deadly on a Mission (Alex Metrix Remix)
The Presets: My People (D.I.M. Remix)
Bonsai Kat: Bla Bla (Original Mix)
Shirley Lites: Heat You Up (Melt You Down) (Gard’s 4lux Edit)
Parsa Vahid: Morning Sun (Original Mix)
Ali Wilson, Lee Osborne: Armageddon (Original Mix)
Boys Noize, Erol Alkan: Lemonade (Justin Robertson’s Deadstocks 33′s Remix)
Punks Jump Up: Get Down (Alex Gopher Remix)

Posted in Music | Leave a comment

How do I store long strings with Firebird, NHibernate and NHibernate.Mapping.Attributes?

Yes, I know, it’s the hot question of the moment which everyone is asking.

Anyway, I figured that someone else might want to know this, since Firebird is a supported database for NHibernate, and the embedded version is very handy.

This is what the declaration for a member called “Detail” should look like (I think you can omit the “Name” attribute if you want):

[Property(0, Type="StringClob")]
[Column(1, Name="Detail", SqlType = "BLOB SUB_TYPE 1")]
public virtual string Detail { get; set; }

So the SqlType bit is Firebird-specific, and I don’t think it was very obviously documented anywhere in the Firebird docs. It feels a bit nasty to write code like this because it means I’m locked in to one database backend FOREVER.

For a fun bonus rant, the NHibernate page seems to be down at the moment. You can say what you want about Java, but the open-source tools and community are so much richer for Java than they are for C#. In fact, I’d say that C# is at around the Java 1.2 level on this basis.

Posted in Uncategorized | Tagged , | Leave a comment

Twitch Mix #3

One Hour Eclectic Mix

Tracklisting

Metronomy: The Bay (2 Bears Mix)
Gossip: Standing In The Way Of Control (Tronik Youth Remix)
Dave Clarke: No One’s Driving (Chemical Brothers Remix)
DJ Sneak: You Can’t Hide From Your Bud
Fedde Le Grand: So Much Love (Original Club Mix)
Paolo Mojo: Wasted Youth (Original Mix)
Booka Shade: Scaramanga (Dusty Kid Remix)
Michael Calfan: Resurrection (Axwell’s Recut Club Version)
Sarah Vaughan: Fever (Adam Freeland Remix)
Fatboy Slim: Tweaker’s Delight
Faithless featuring Blancmange: Feel Me
Oliver Koletzki: Music From The Heart (Original Mix)
Felix da Housecat: What Does It Feel Like? (Röyksopp Return To The Sun Remix)
Crystal Castles featuring Robert Smith: Not In Love

Posted in Music | Leave a comment

Twitch Mix #2

How’s Your Evening So Far?

Indie Disco / Electro Mix (tracklisting below)

Tracklisting

Wink: How’s Your Evening So Far (Filtered Mix) [Intro]
Metronomy: The Look (Fred Falke Remix)
Chris Lake: Changes (Main Mix)
Felix da Housecat: Silver Screen Shower Scene (Chuckie & Silvio Ecomo Dirty Acid Remix)
Yeah Yeah Yeahs: Heads Will Roll (A-Trak Club Mix)
Basement Jaxx: Where’s Your Head At?
Röyksopp: The Girl And The Robot
DJ Tiësto & Ferry Corsten: Gouryella (Rawdirt Remix) [Outro]

Posted in Music | Leave a comment

Twitch Mix #1

The first in a series of my Twitch Mixes, 50 minutes of progressive house and trance, on my Novation Twitch with Serato Itch.

Some of these mixes are hosted on SoundCloud, but I’ve only got limited space on there, so the complete lot are hosted here.

Tracklisting

Nick Warren: Buenos Aires (Original Mix)
Way Out West: The Gift (Michael Woods Remix)
Tom Blench: Third Interval (WIP)
Simian Mobile Disco & Beth Ditto: Cruel Intentions (DJ Pierre Remix)
Adam Freeland: We Want Your Soul (Infusion Mix)
Jerome Isma-Ae / OT Quartet: Hold That Sucker Down (Instrumental)
Inner City: Big Fun (Simian Mobile Disco Remix)
Adonis: No Way Back
The Temper Trap: Sweet Disposition (Evil Nine Mix)

Posted in Music | Leave a comment

Richard Stallman’s Rider

Thanks to The Register, whose story linked to an email which details RMS’ rider and requirements for making speeches in tedious detail.

Honestly, this stuff makes “a bowl of blue M&Ms” look trivial. We learn that he doesn’t like dogs, can’t sleep if the temperature is higher than 22°C, and that “I like some wines…but I don’t remember the names of wines I have liked”.

Even if I thought this guy was the messiah of free software (I am an avid emacs user), I don’t think I would want to host such a fussy and childish person.

Posted in Uncategorized | Leave a comment

Small change: the economics of charging for trivial things

I got thinking about this subject because Fred Baker Cycles had the temerity to charge me 50p for the use of their bike pump.

This was definitely adding insult to injury as I was confronted with a flat tyre after having visited the dentist. No problem, I thought, I’ll just go to a local friendly bike shop and at least be able to ride the damn thing home.

Maybe I’m too sensitive to petty things, but charging 50p for this service (I grudgingly handed over my equilateral curve heptagon – I had no other choice) generated a huge amount of badwill (the opposite of goodwill) towards this shop.

Contrast this approach with Orange retail stores (disclaimer, I once worked for them), who will charge your mobile phone, gratis – you don’t even have to be a customer.

Maybe it’s something specific to bike shops. So many of them have a reputation for being rude and unhelpful, and if these Google reviews are anything to go by, this one is no different.

Posted in Uncategorized | 1 Comment

Emacs: how to search and replace newlines

I can’t remember where I learnt this, but I use it all the time and it’s not at all obvious.

When in the minibuffer (at the prompt for replace-string or replace-regexp, for example), enter C-q C-j for a newline (0x0D, NL).

Depending on the coding system for the buffer (DOS mode for example), you may also need to use C-q C-m for carriage return (0x0D, CR) – suddenly it makes sense where all those ^Ms come from!

Posted in Uncategorized | 3 Comments