Tuesday, 22 February 2011

No Such Number, No Such Tailor

In the film Die Hard, the bad guy says he has 2 suits from "John Phillips, London". But a Google search reveals there is no such tailor. It doesn't exist!

Still, we can forgive writer Steven E. de Souza this minor detail.

Thursday, 6 January 2011

First version of my custom-written C++ string replacement function to be more like Perl's

Here's the code. Use it how you like.

I don't know what'll happen with any inputs a blank string, but try not to pass blank strings in.

string myreplaceall(string input,string match,string replace)
{
//first find out how many matches in input
long i;
long mysize = 0;
for (i = 0; i < input.size(); i++)
{
if (!strncmp(input.c_str()+i,match.c_str(),match.size()))
{
i += match.size()-1;
mysize++;
}
}

//mysize tells us how many matches there are

//first deduct the match strings * mysize
long finallen = input.size() - mysize * (match.size());
//add on the replace strings * mysize
finallen += mysize * (replace.size());

//allocate a string of finallen
char *outbuffer;
outbuffer = (char *)malloc(finallen+1);

string retval;

long ptr = 0;

//copy text into outbuffer
//either a single letter, or replace the 'match' string with the 'replace' string
for (i = 0; i < input.size(); i++)
{
if (!strncmp(input.c_str()+i,match.c_str(),match.size()))
{
i += match.size()-1;
long j;
for (j = 0; j < replace.size(); j++)
{
outbuffer[ptr+j] = replace[j];
}
ptr += replace.size();
}
else
{
outbuffer[ptr] = input[i];
ptr++;
}
}

//terminate string
outbuffer[ptr] = 0;
//make string of return value
retval = outbuffer;
//free outbuffer memory
free(outbuffer);

//return replaced string
return retval;
}

Saturday, 4 September 2010

A Decent USB Joystick for MAME

MAME emulates old arcade machines. The tricky part is you have to use the PC keyboard if you don't have a joystick. But any joystick has to have at least 2 separate buttons AND be USB compatible.

The cheapest solution is to get a Speedlink Competition Pro USB Joystick. It comes with 99 pirated Commodore 64 games, but you can ignore them.

In MAME, hit Tab, 'Input (This Game)'. Move up and down the list and hit Enter, then wiggle the joystick or press a button on it. Then go back into the game.

You've now configured that game for your new Competition Pro!

Click here to get it.

Saturday, 28 August 2010

Making a Dell M70 Precision quieter

Simple, get a Western Digital Scorpio 40GB drive, WD400UEDTL (or WD400UE) (not a newer 80GB one, the M70 BIOS doesn't like them) off Ebay, make sure it's EIDE not SATA, slot it into an M70 hard drive caddy, and put it inside the M70. Not sure how to remove the existing drive from the hard-disk caddy - I had to buy a new caddy from Ebay, and put the Scorpio in the caddy. Then you install Windows/Linux/whatever from a boot CD.

If the CPU is noisy, get http://www.diefer.de/i8kfan/ and set Main Operating Mode to Automatic temperature control.

You'll now have a laptop quiet as a whisper!

Saturday, 7 August 2010

Movie cliche: The Bad Guys' Secret Code

In films from all ages, we have the classic cliche.

Basically, the bad guy, with the good guy (in captivity), and some henchmen (say, 2 of them) are in a room at the bad guy's base.

Now, pay close attention: The good guy makes a wisecrack, and the bad guy nods to a henchman, who punches the good guy.

Do you see the problem here? How do the henchmen know what a nod means? Or a finger click. Or a summoning finger? Simple: The screenwriter couldn't be bothered to have the bad guy say "Punch him" - or for that matter, to pay the cab driver after a long cab ride (another cliche).

Now, examples of this:

*Casino - They're about to do something nasty in a casino backroom. De Niro nods to a guy and he stops.

I can't think of any right now, but you heard it here first.

Thursday, 17 June 2010

*£%$ Gibson-esque Cyberpunk novels

I'm reading Lethal Interface by Mel Odom, written in 1991.

It robs a lot from Gibson's Neuromancer.

However, I just don't get how you fly around this stupid networked world of graphics, with a headset on and - this is my basic point - instead of passwords they have silly games to play to let you in. Which is less secure than passwords.

It's sad, because this book is quite readable. It's 50/50 whether I read any more.

Obviously Mel never saw the web coming when he wrote this in 1991, but who did? A world of text (not wireframe graphics) to display information, and IP and domain addresses to avoid 'flying around' looking for a destination.

Monday, 24 May 2010

Most Overproduced Record of All Time Award

I hereby nominate and vote for Pat Benetar's Love is a Battlefield from 1983. More like the production is a minefield. Strange chunking guitars, melancholy synths swooshing and swarming through the mix. Echoing vocals, And the Wikipedia page is hilarious: "We asked these guys to write us a hit song and they did". Wow, it's that easy? Just ask someone and you sell millions of records? If this story is true, then anyone can have a hit. Just ask some guy.

Michael Jackson's Beat It comes 2nd in this award. There is no 3rd place.