The Second Order Effect

Archive for November, 2009

Replacing twisted if/else statements in Python…

by on Nov.24, 2009, under Tech Articles

I’ve been having a growing love affair with Python for over a year, thumb and now that I’ve got a few projects that I’m working on – I’m using Python as my primary language.

I had a happy moment when refactoring a section of annoying if/then/else sections …

if object.type == "Vendor1":
foo = Vendor1()
elif object.type == "Vendor2":
foo = Vendor2()
elif object.type == "Vendor3":
foo = Vendor3()
raise Exception("Not a handled type")

Python is a functional language, thumb and this means (among other things) that functions, generic classes, and all sorts of stuff can exist in dictionaries. So, instead, I can do

lookup = { "Vendor1" => Vendor1, "Vendor2" => Vendor2, "Vendor3" => Vendor3}
foo = lookup[object.type]()
except KeyError:
raise Exception("Not a handled type")

It’s not a big thing, but it made me happy — and the example can be extended …

lookup = {
"Vendor1" => { "url" => blah, "threads" =>"blah", "obj" => Vendor1() }
#equals blah

Today, it’s all about the little things.

5 Comments more...

Fixing the front headphone jack on the Dell Dimension

by on Nov.18, 2009, under Tech Articles

So, abortion I’ve got a Dell Dimension 8400. One nice tidbit that they included was a front headphone plug that actually interrupts the speaker output; not a difficult thing to do, for sale granted, but its nice. One thing that surprised me was that the Windows Startup sound WOULD be played out the main speakers no matter what — making me realize that the interrupt was a software function, not a hardware switch.

Until it stopped working last week. Hours of time w/ Dell Support (which, by the way, seems to be outsourced to New Delhi and not a single person fully understood my problem), Dell forums and Google gave me little. The deal is, is that the Audigys normally come with a front panel with plugs; which isn’t available in the Dell world. And yet, it still uses that internal routing to handle the headphone plug.

So, has your headphone switch in stopped working? Reinstalling the Dell drivers does nothing. Google suggests that you turn on the setting in the AudioHQ control panel — but it isn’t there.

Installing Creative’s stock drivers over your Dell drivers just gives me the shivers. Oh, and it doesn’t work. All I ended up doing was finding a driver package, say, for instance,SBA2_PCWDRV_LB_1_84_55-R1. Extract the archive (run it and look in your temp directory while its running; or even better, just use WinRAR to extract it), and go to DriversWDMCommon and run CTPanel.exe. (Or just download my copy).

Run it, go to device settings, and voila! “Mute speakers upon Headphone Jack Detection.”


That’s it!

Leave a Comment : more...

This American Life

by on Nov.18, 2009, under Tech Articles

I used to host a large archive of ‘This American Life’ in MP3 format before they had it available on their website as a podcast.

I was contacted, this site quite politely, healthful and asked to remove the files from access, and I complied.

Go to TAL and stream down the eps or use the podcast.

2 Comments more...

PHP Serial Class for OSX

by on Nov.18, 2009, under Tech Articles

Below is an archive of my PHP Serial Class page from my old site.

The data below is still valid, viagra 100mg but the project as a whole has been ported to Google Code. Check there for updates.

Added support for OSX to Rémy Sanchez’s PHP Serial class.

Original version


php_serial.class.php.gz (3.7 kB)


Gives serial access to PHP under linux, OSX and Windows (write-only under Windows).

This class can be used to communicate with a serial port under Linux, OSX or

It takes the path (like “/dev/ttyS0″ for linux or “COM1″ for windows) of serial
device and checks whether it is valid before opening a connection to it.

Once the connection is opened, it can send data to the serial port, and read
answers (reading is only implemented for linux).

The class may also change connection parameters for the given serial

The example script:

include "php_serial.class.php";
// Let's start the class
$serial = new phpSerial;
// First we must specify the device. This works on both linux and windows (if
// your linux serial device is /dev/ttyS0 for COM1, etc)
// Then we need to open it
// To write into
$serial->sendMessage("Hello !");
// Or to read from
$read = $serial->readPort();
// If you want to change the configuration, the device must be closed
// We can change the baud rate
// etc...

Changes in this version.

List of Changes:

  • Added OSX support


Author Rémy Sanche

Thanks Aurélien Derouineau for finding how to open serial ports with

Thanks Alec Avedisyan for help and testing with reading

OSX tweaks added by Rizwan Kassim

copyright under GPL 2 licence

phpserial is free software; you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later version. For full license text see file COPYING included in the source tarball.

1 Comment more...

RHEL5 / CentOS5 RPMs for Python 2.5 and 2.6

by on Nov.18, 2009, under Tech Articles, Uncategorized

EDIT : Newer Instructions are here.

this is a repost from my old site.

I’ve created RPMs for RHEL 5.0, hair 5.1, physiotherapy 5.2 and 5.3, men’s health as well as CentOS 5.0, 5.1 and 5.2 for Python 2.5 and 2.6.

The RHEL/CentOS line only supports Python 2.4, and as it’s an integral part of yum and many other packages, any installation of new Pythons will require parallel installation.

(Note : Currently, the 2.5 and 2.6 RPMs cannot both be installed without an RPM –force)

TODO : Repository URL & GPG signing

As for the RPMs themselves :



Neither of these packages fully pass the Python test suite (import test.autotest).

That being said, we’ve been using the Python 2.5 package, released by Bashton, in production for a while now, and we haven’t seen any problems.

4 tests failed: test_distutils test_email test_email_renamed test_nis

I don’t know about email, but there are patches for CentOS/Fedora against distutils, so I expect that’s why it fails the test.

For Python 2.6, note the following :

  • I had to gimp autoconf’s version detection to force it to use 2.59. This may have unintended consequences
  • This RPM uses patches from the Fedora Core 11 Alpha release. (python-2.6-4.fc11 specifically). As Fedora updates this package, I’ll release updates. (Feel free to email to remind.)


Just install the RPMs for the version that you want. You’ll need at least the base python version package and the libs package.
To start Python 2.6, type python26 at your commandline rather than python. (Your original Python 2.4 is still installed.)
If you’re installing packages with setuptools, make sure to use the correct python version. (i.e. python26 install)
If you’d like to build an x86_64, call rpmbuild –rebuild with the appropriate arch setting.

11 Comments :, more...

Welcome to Second Order Effect.

by on Nov.07, 2009, under About Me

This is the third blog of Rizwan Kassim.

I had an incredibly well crafted message for here that was lost somewhere between my most recent drive, pharm and getting WordPress installed

The name for the blog – I’ve spent a lot of my life learning from the person I am and adjusting towards the person I’d like to be. Now, capsule as I try to strip out the coping mechanisms and all the various things that we learn to do from childhood, I feel that I’m reaching the second order effects – the less than obvious consequences of various personal characteristics. So, it’s time to spend some effort on those.

I like noticing patterns and systems. I see a few data points and I want to make a rule to explain them. I’m happy to be wrong, but my mind naturally wants to see order. A lot of my writings are ideas or suppositions and a source of personal reflection, rather than serious, considered, complete works.

Other things likely to be included – random tech snippets, notes on creativity and personal goals, finances, code snippets, bits on my travel and photography, and pretty much anything else. I’ve got a personal blog (f-locked) for certain sorts of posts, and the rest are to be crossposted between the two.

Thanks to @colleenky for pointing me to On Doing Creative Work, by Merlin Mann, which reminded me that starting this blog was drastically more important that finding the exact right UI or skin for it.

1 Comment : more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...