Meanwhile on the Isotoma blog

1v$ date
1v$ Wed Jul 28 10:45:45 GMT 2010

Threading tweets on Twitter with Thweddy

1v$ date
1v$ Mon Mar 1 16:10:44 GMT 2010

I built a new app, called Thweddy. From the FAQ:

It makes threads of tweets, so you can send a full conversation to someone else (or include it in another tweet) to people rather than copying and pasting half a dozen different URLs for each one.

Talk @ Brumcon9

1v$ date
1v$ Tue Dec 1 12:47:59 GMT 2009

I’m giving a talk at Brumcon9 this Saturday, titled “Friend me! – Data-mining the social web”, this is my outline (work in progress):

  • Who I am
  • The “social web”, what’s thattabout den?
  • Data mining, identity theft, social engineering, and digital forensics
  • The case of the missing tweet
  • Tools of the trade
  • APIs, apps, loopholes & exploits
  • Stalking Miss Daisy
  • Outro

New job, and a new project

1v$ date
1v$ Wed Sep 30 16:44:03 GMT 2009

Okay, after about 2.2 years of working for Sense Internet I finally left the wonderful folks there to persue a career as a Python web dev, for Isotoma in York.
I actually did this about a month ago, as ever I’m just crap at pushing out any kind of update. ;)

Anyhoo, my latest project was finally released this weekend, memorised, a Python decorator for caching function/method results in memcached with very little faffing about.
For a write up on memorised, take a gander at my post on the Isotoma blog.

Prototype.js Event keycode constants

1v$ date
1v$ Fri Jun 5 12:37:09 GMT 2009

A more human-readable table of the keycode constants listed in Prototype.js’s Event class:

Name Keycode Use
Backspace / Back delete KEY_BACKSPACE Event.KEY_BACKSPACE
Tab KEY_TAB Event.KEY_TAB
Return / Enter KEY_RETURN Event.KEY_RETURN
Escape / Esc KEY_ESC Event.KEY_ESC
Arrow left KEY_LEFT Event.KEY_LEFT
Arrow up KEY_UP Event.KEY_UP
Arrow right KEY_RIGHT Event.KEY_RIGHT
Arrow down KEY_DOWN Event.KEY_DOWN
Delete / Forward delete / Del KEY_DELETE Event.KEY_DELETE
Home KEY_HOME Event.KEY_HOME
Page up KEY_PAGEUP Event.KEY_PAGEUP
Page down KEY_PAGEDOWN Event.KEY_PAGEDOWN

Still Alive

1v$ date
1v$ Sun Apr 19 21:06:47 GMT 2009

I’ve just spent the last couple of weeks getting over chicken pox..yeah I know, kids illness blah blah, it can be quite
serious when you’re an adult believe it or not, and more so for a diabetic. Anyway I’m still here and ready to go back
to work on Tuesday.
Haven’t really got many projects done, other than rekitting my new Dell Mini Inspiron 9, the Vodafone version with
integrated HSDPA chipset and GPS, with Ubuntu 9.10 and getting the 3G working. I’ll post more on this
later, posting this on the Mini 9 from my in-laws over 3G, with them still being in the dark ages of wired dial-up.

My new email setup

1v$ date
1v$ Sun Mar 29 4:03:44 GMT 2009

After years of resisting using Gmail for email (I still have an original early beta account), the everyday use of my Android powered TMobile/HTC G1 has made the push-email integration with Gmail too tempting at last, and I’ve switched my email use from a dedicated IMAP account over to Gmail.
However I’m not trusting GOOG completely with my mail use, and to make sure absolute available of all my latest mail, and my back archive of emails in case I ever want to move this is my current setup:

  1. Email goes to my personal domains, in which the MX records point to my dedicated server.
  2. Postfix runs these emails through greylisting (using greyfix) and SpamAssassin just to stop any barbarians at the gate.
  3. Postfix then forwards these emails to various local dynamic maps, which in turn forward to both my Gmail account and an offsite backup IMAP account.
  4. A cron’d script on my server periodically deletes emails from the offsite backup IMAP account every 2 weeks, meaning I can get access to the last 2 weeks of email as well as send email out from my personal domains (I can also do this from my server, obviously, for outgoing) if there’s ever a Gmail problem.
  5. Larch is also run every week to synchronise any emails in my Gmail account with a local IMAP archive, for future portability.

The upshot of this is that I get perfect webmail, desktop IMAP and push-email on my G1 without worry of any reliability on the GOOG. w00t.

Final Fantasy XI tip: get out of being "stuck" targeting someone

1v$ date
1v$ Sat Mar 14 0:13:50 GMT 2009

It seems my wife has become addicted to playing MMORPGs. Well, just one to be precise: Final Fantasy XI.
I play it sometimes with her too, although FF isn’t really my thing it can be fun to play together. One annoying little game glitch that happens to us every now and again, mainly after a fight with a monster, is that one of us will become stuck on the other…or even on other people. By this I mean that the targeting cursor (that you use to perform most of the different type of actions with other players, objects and NPCs), and apart from this also forces your avatar to stare at the thing that’s targeted, and to always face that thing. It is impossible to cancel this targeting through any normal means at the point and the usual fix is to walk very slowly (because you’re actually walking backwards so your speed is limited by the game) away from the person you’re fixated on until you’re too far away for targeting to work and the cursor suddenly releases.

Obviously this is slow and very annoying. The other day someone informed us as to a quick fix for this using the Xbox 360 controls (the game is available, and indeed we both us it on each of, Xbox 360 and PC), we translated these actions into the equivalent PC keyboard controls and have verified that it works on before, instantly releasing the fixation after pressing the key combo.

If this ever happens to you, you can use for the 360:

Press both B and L3 (inward on the left analogue stick), together

The PC equivalent:
Press both * and Esc, together

HTH

Before I begin, let me state that I agree entirely with others who have said that lambda functions and closures aren’t meant to allow you to dynamically extend classes at runtime, what I disagree with is the assertion that there are other ways of doing this. Currently there is no other way of doing this, and while I don’t think I’d use this method in production, it is still an extremely fun hack to use!
You can do things like this inside Lisp-like languages such as Python and Ruby, but they’re naturally parts of the language itself, rather than exploiting the inner working of magic methods with the lambda language feature as I do here.

Returning to the to using some of PHP5.3’s more magic features, I realised that I was being a little short-sighted with my example. In fact you can expand it to include not only methods, but static methods, and not only modifying single objects at runtime but you can emulate modifying the actual class definition itself so that any instantiated objects will have the new methods.

This is made possible by using the new late static binding and __callStatic magic method features. By using late static binding we can call a static method in the base ancestor class which assigns the lamba function passed in to a static hash of methods, indexed by the descendant class you called it via, using the new get_calling_class() function to get it’s class name and use that as the index.
We can use a separate hash of static methods to add static methods (which are just lambdas again) to the class by defining an extra __callStatic() magic method, that works just like the __call() method, but obviously for static calls.


<?php
require ‘OneVersion/DynamicClass.php’;

class MyClass extends OneVersion\DynamicClass {
public $name = ‘Dis is my class’;

public function __construct() {
echo ‘Instantiating “’ . CLASS . ‘”’ . PHP_EOL;
}
}

class MyOtherClass extends OneVersion\DynamicClass {
public function __construct() {
echo ‘Instantiating “’ . CLASS . ‘”’ . PHP_EOL;
}
}

MyClass::addMethod(
‘test’,
function($this, $text=null) {
if ($text === null) {
echo ‘default test’ . PHP_EOL;
} else {
echo $text . ‘ test’ . PHP_EOL;
}
}
);

MyOtherClass::addMethod(
‘test’,
function($this, $text=null) {
if ($text === null) {
echo ‘default test2’ . PHP_EOL;
} else {
echo $text . ‘ test2’ . PHP_EOL;
}
}
);

$object = new MyClass();
// Should output:
// Instantiating “MyClass”

echo ’1: ‘;
$object->test();
// Should output:
// default test

echo ’2: ‘;
$object->test(‘monkeys’);
// Should output: monkeys test

echo ’3: ‘;
$object->test(‘chimps’);
// Should output: chimps test

echo ’4: ‘;
$object2 = new MyOtherClass();
// Should output: Instantiating “MyOtherClass”

echo ’5: ‘;
$object2->test();
// Should output: default test2

echo ’6: ‘;
$object2->test(‘chimps’);
// Should output: chimps test2

echo ’7: ‘;
$object2->test(‘conan’);
// Should output: conan test2

echo ’8: ‘;
$object->test(‘conan’);
// Should output: conan test
?>

I’ve released OneVersion\DyanmicClass 1.0 out into the wild under the LGPL v2.1, so download and play at your own peril. ;-)

Leeds2600

1v$ date
1v$ Fri Feb 13 7:52:14 GMT 2009


Subscribe to Feed

Navigation

Asides

  • January 9 - Fixed textitle usage in atom feed

    I’ve started using Textile) for markup in my posts, but it wasn’t getting parsed in my Atom feed..now fixed!

  • January 2 - No xmlrpc to Habari from G1

    The Android Market place doesn’t have any xmlrpc apps to work with Habari, just one that should work but doesn’t as it’s doing something only Wordpress seems to understand. FAIL.

More Posts

Recent Comments

Links

Latest tweet on Twitter

User Login