“Order By” for Zend Db findDependentRowset()
Posted by Bricky in Programming on November 9, 2011
This is another one of those note-to-self style posts.
Design decisions on Zend Db’s “Zend_Db_Table_Row_Abstract” class prevent the inclusion of an ‘order by’ clause directly in the (incredibly useful) “findDependentRowset” function.
But you can pass in the order by clause indirectly through a select statement as follows.
What you want would be something like:
$depRows = $row->findDependentRowset('DEP_TABLE_NAME', /*order by=*/'SORT_ORDER ASC');
and you get this by doing the following:
$depTable = new DEP_TABLE_NAME();
$depRows = $row->findDependentRowset($depTable, null, $depTable->select()->order('SORT_ORDER ASC'));
Popularity: 1% [?]
AppleScript desktop dialer for Asterisk
Posted by Bricky in Mac, Programming, VOIP on February 12, 2011

Asterisk Desktop Dialer
You’ll need a mac (obviously), a desktop phone (even more obviously), and an asterisk server (most obviously), preferably on your lan, which you can configure to allow network access to the AMI (Asterisk Manager Interface).
Read the rest of this entry »
Popularity: 3% [?]
Install python lxml 64 bit on OSX 10.5
Posted by Bricky in Mac, Programming on February 11, 2011
This is one of those note-to-self style posts again.
I’m not really clear on why this has to be so damned complicated: every time I mess with lxml on OSX it costs me half a day!
The second-last time I had to do this, I actually stripped everything but the 32 bit executable out of apache to force it into 32 bit mode, so that I wouldn’t have to compile a 64bit lxml! (and yes, that’s just stupid, don’t do it).
Anyway, this is how I managed to get it to compile this time:
mkdir /tmp/lxml-build
cd /tmp/lxml-build
curl -O http://codespeak.net/lxml/lxml-2.3.tgz
tar -zxf lxml-2.3.tgz
cd lxml-2.3
mkdir libs
cd libs
curl -O ftp://xmlsoft.org/libxml2/libxml2-2.7.3.tar.gz
curl -O ftp://xmlsoft.org/libxml2/libxslt-1.1.24.tar.gz
cd ..
Here we need to modify the build code for lxml. (Yes, I know this shouldn’t be the case, but the arch is hardcoded in there for 10.5 as i386, and we simply have to change it).
Open the file buildlibxml.py, and, at around line 284, find the following lines:
if minor_version < 6:
env.update({
'CFLAGS' : "-arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -O2",
'LDFLAGS' : "-arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk",
'MACOSX_DEPLOYMENT_TARGET' : "10.3"
})
else:
… changing them to the following …
if minor_version < 5:
env.update({
'CFLAGS' : "-arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -O2",
'LDFLAGS' : "-arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk",
'MACOSX_DEPLOYMENT_TARGET' : "10.3"
})
elif minor_version < 6:
env.update({
'CFLAGS' : "-arch x86_64 -arch i386 -O2",
'LDFLAGS' : "-arch x86_64 -arch i386",
'MACOSX_DEPLOYMENT_TARGET' : "10.5"
})
else:
i.e. we change the first case to 10.4 and earlier, and add a case for 10.5 (the minor_version < 6 stuff).
We can now continue with the compilation as follows:
ARCHFLAGS='-arch x86_64' python setup.py build --static-deps --libxml2-version=2.7.3 --libxslt-version=1.1.24
ARCHFLAGS='-arch x86_64' sudo python setup.py install
And that should be it.
If something goes wrong, do a make clean before changing the build options. And note that you’ll probably need to restart apache (sudo apachectl restart) to pick up on changes.
References: here, here, and here.
Popularity: 2% [?]
HTML vertical text (Safari, Firefox, Chrome, and Opera)
Posted by Bricky in Programming on September 15, 2010
I recently had a requirement to display a large amount of tabular data in a small space – and to get it looking right, some of the text simply had to be vertical. My first solution was to use javascript on page load to replace the text with svg code, which essentially drew an svg image of the vertical text in place. While this looked fine, it resulted in quite a bit of client-side code running at page load, which resulted in a noticeable delay when the page got large.
My second solution was considerably neater however: css transforms.
Examples above. The first block is an image (screenshot of this in Safari), the second block is the real thing. If your browser supports this, the two should look broadly similar. The CSS for this is as follows:
.vText {
-moz-transform: rotate(-90deg) translate(0, 100%);
-moz-transform-origin: 0% 100%;
-o-transform: rotate(-90deg) translate(0, 100%);
-o-transform-origin: 0% 100%;
-webkit-transform: rotate(-90deg) translate(0, 100%);
-webkit-transform-origin: 0% 100%;
transform: rotate(-90deg) translate(0, 100%);
transform-origin: 0% 100%;
}
The first two lines (the -moz lines) are for current versions of firefox, the next two (the -o lines) are for recent versions of opera, the next two (the -webkit lines) are for Safari & Chrome, and the last two are for the future (assuming this gets beyond a working draft).
And no, this CSS doesn’t work with IE at present.
So how does it work?
transform-originsets the, wait for it, origin, at the bottom-left corner. This will be the centre of the rotation when we rotate.translate(0, 100%)moves the block vertically down by its own height (i.e. y = 100%), so that its top border is where its bottom border was.rotate(-90deg)rotates the text 90° counter-clockwise.
The big caveat here is that the transforms do not change the original element dimensions (e.g. if it’s 100px wide before the transform, it will still take up 100px width after the transform), so you will generally need to put your vText element in a containing block which has the required width and height (i.e. after the transform) set.
Popularity: 23% [?]
iPhone gets Delivery Reports – finally!
Thanks to the incredible efforts of francois.guilleme, the iPhone finally has delivery reports!
By intercepting calls to/from CommCenter, his library modifies outgoing SMS headers (adding the delivery report flag), and captures incoming SMS reports (displaying them either as a flash message, a regular sms message, or a simple ‘tick’ mark).
All the details (including source) are up on the google code site. Installation is simple, just add http://iphonedelivery.advinux.com/cydia or http://iphonedelivery.advinux.fr/cydia as a cydia source, install the iPhoneDelivery package, and robert is your relative.
Popularity: 100% [?]
OS X: Fix Argentina DST October 2009
Well, at almost the last minute, DST was cancelled in Argentina this year. And this broke things, mostly computers. (Not for the first time either, the same thing happened two years ago here).
The debian folk came out with a fix at the last minute: so that fixed the linux machines, but OS X is a slower beast to move, so it’ll be a while before any change works its way through. In the meantime, Mac users in Argentina are left with broken clocks.
Argentina_DST_Update_2.pkg – for 10.6.x only!
(Updated 2010-03-15)
I am no Mac expert, and this isn’t entirely tested, so be warned.
Anywho, this is how to update the tz data (aka zoneinfo), which should, in theory, fix the problem:
mkdir tzfix
cd tzfix/
curl ftp://elsie.nci.nih.gov/pub/tzdata2009n.tar.gz | tar -zxvf -
vi +219 southamerica
Change the two lines:
Rule Arg 2008 max - Mar Sun>=15 0:00 0 -
Rule Arg 2008 max - Oct Sun>=15 0:00 1:00 S
to the following
Rule Arg 2008 2009 - Mar Sun>=15 0:00 0 -
Rule Arg 2008 only - Oct Sun>=15 0:00 1:00 S
(i.e. just two words to change). If it makes you feel better, here’s a diff.
Ok, save & close, and then compile it as follows:
sudo zic southamerica
sudo cp /usr/share/zoneinfo/America/Argentina/Buenos_Aires /usr/share/zoneinfo/America/Buenos_Aires
The sudo is necessary because you’re changing /usr/share/zoneinfo.
And that’s mostly it. Verify that it worked as follows:
zdump America/Argentina/Buenos_Aires
America/Argentina/Buenos_Aires Sun Oct 18 20:43:42 2009 ART
(note that the timezone is now ART, not ARST as previously).
So that fixes things for most of the command-line stuff. But you’ll notice that the clock on your desktop, iCal, and others, are still incorrect. We need to fix the ICU database also. Thankfully the latest sources are available for this from apple itself:
curl -O http://www.opensource.apple.com/tarballs/ICU/ICU-400.37.tar.gz
tar -zxf ICU-400.37.tar.gz
cd ICU-400.37/icuSources
ICU doesn’t come with the tzdata, but the readme in tzcode helpfully notes that if we place the tzdata*.tar.gz file in tools/tzcode/ it will be compiled automatically. You can pack up your own tzdata2009n.tar.gz that we used earlier if you wish, or use the one I prepared here:
cd tools/tzcode/
curl -o tzdata2009o.tar.gz http://brickybox.com/wp-content/uploads/2009/10/tzdata2009otar.gz
cd ../../
./runConfigureICU MacOSX --with-data-packaging=archive
gnumake
sudo install -o root -g wheel -m 0644 -Sp data/out/icudt40l.dat /usr/share/icu/icudt40l.dat
And that’s it. We have a new ICU database. Reboot to see the changes.
Update (21st October):
This technique works on the iPhone too. The iPhone already has zic (well, at least my one has), so you can simply copy your modified southamerica file onto the phone somewhere, and run (as root):
zic southamerica
cp /usr/share/zoneinfo/America/Argentina/Buenos_Aires /usr/share/zoneinfo/America/Buenos_Aires
And you can simply copy the data/out/icudt40l.dat you created for OS X into /usr/share/icu/icudt40l.dat on the iPhone. It causes Springboard to crash, but after a reboot everything works perfectly.
Update (10th November): I can’t believe it, today 10.6.2 update broke the damn icu stuff again.
mkdir 10_6_2_fix
cd 10_6_2_fix/
curl -O http://www.opensource.apple.com/tarballs/ICU/ICU-400.37.tar.gz
tar -zxf ICU-400.37.tar.gz
cd ICU-400.37/icuSources/tools/tzcode/
curl -O ftp://elsie.nci.nih.gov/pub/tzdata2009r.tar.gz
cd ../../
gnumake
sudo install -o root -g wheel -m 0644 -Sp data/out/icudt40l.dat /usr/share/icu/icudt40l.dat
Thanks to Jonathan Tapicer for pointing out that the tzdata file name has been updated (now at version R).
Update (5th February): I’ve had several requests to package this up in an installer, so here goes:
Argentina_DST_Update.pkg – for 10.6.x only!
(I don’t have a 10.5.8 any longer, so I can’t compile for it, sorry)
Update (15th March 2010): Yes, the ICU fix is broken again today. The problem seems to be more to do with automatic timezone detection (which OS X is now seeing as GMT -4) than anything to do with zoneinfo. For now, to fix it:
- Download and install the new Argentina_DST_Update_2.pkg – for 10.6.x only!
- Open a terminal and type:
systemsetup -setusingnetworktime off
systemsetup -settimezone America/Argentina/Buenos_Aires
This is fairly straightforward: it disables automatic timezone detection, and sets the timezone manually (you can use the -listtimezones switch to see a list of available timezones). If anyone knows how to update DateAndTime.prefPane (which appears to use GeoKit) please let me know.
Update (4th April 2010): I’m pleased to announce that 10.6.3 includes updated tzdata for Argentina (and elsewhere) that fixes all this silliness. Get it now (via software update) to make this problem go away.
Popularity: 16% [?]
Mika – Grace Kelly
“You only want what everybody else says you should want” – my sentiments exactly.
There aren’t many people in the world who could pull off an act like this.
Popularity: 2% [?]
Ireland: A Country of Sheep
Posted by Bricky in Uncategorized on October 3, 2009

Voters in the Lisbon Treaty Referendum 2009
Popularity: 2% [?]
Ricky Stone’s Two Fingers to DJ Mag
Ricky stone has extended a 2 finger salute to the DJ Mag poll. The spot says it all I think:

Popularity: 4% [?]
Copy mysql table between servers/databases
Posted by Bricky in Programming on July 20, 2009
This is one of those reminder-to-self style posts.
To copy mysql table tablename from database1 on server1 to database2 on server2, issue the following command (on either server)
mysqldump -h server1 -u user1 -ppassword1 database1 tablename | mysql -h server2 -u user2 -ppassword2 database2
user1, password1, user2, and password2 are the respective usernames and passwords to use on server1 and server2, respectively. Note that there is no space between the -p and password (unlike the other switches).
Popularity: 7% [?]