Author Archives: tomblench

Alt-J – Greasemonkey script to replace Wingdings

Here’s a Greasemonkey script to get rid of those horrible “J” characters we see when an Outlook user tries to send you a smiley.

(Thanks to Abhinay Omkar’s “J for Smile” script which was the inspiration here.)

I don’t really use Greasemonkey but it seems that most people put their scripts on userscripts.org – however this seems to be a repository for Chinese spam and other garbage. So here it is:

// ==UserScript==
// @name        Alt J
// @namespace   http://blench.org
// @description Replace J with smiley etc
// @include     https://outlook.hslive.net/*
// @grant       none
// @version     1
// ==/UserScript==

function makeSmiley(sm)
{
    switch(sm)
    {
        case "J":
        return "☺";
        case "K":
        return "😐";
        case "L":
        return "☹";
        default:
        return sm;
    }
}

function makeSmileys(){

    var fonts = document.getElementsByTagName('font');
    for (var key in fonts)
    {
        var font = fonts[key];
        if (font != null) 
        {
            var face = font.face;
            if (face != null && face.indexOf('Wingdings') != -1)
            {
                font.innerHTML = makeSmiley(font.innerHTML);
            }
        }
    }

    var spans = document.getElementsByTagName('span');
    for (var key in spans)
    {
        var span = spans[key];
        if (span != null) 
        {
            var style = span.style.cssText;
            if (style != null && style.indexOf('Wingdings') != -1)
            {
                span.innerHTML = makeSmiley(span.innerHTML);
            }
        }
    }
}
		

makeSmileys();
Posted in Uncategorized | Leave a comment

C stdio – disable buffering

Sometimes it’s useful to disable buffering for printf/fprintf etc. This is especially the case when you’re trying to debug a program and you’re not sure if it’s going to exit prematurely, before the output buffer gets flushed.

It’s a pain to stick fflush() after every fprintf. The proper way to do it is:

setbuf(stream, NULL);

The manpage assures us this is equivalent to the more verbose

setvbuf(stream, NULL, _IONBF, BUFSIZ);
Posted in Uncategorized | Leave a comment

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