Live a good life. If there are gods and they are just, then they will not care how devout you have been, but will welcome you based on the virtues you have lived by. If there are gods, but unjust, then you should not want to worship them. If there are no gods, then you will be gone, but will have lived a noble life that will live on in the memories of your loved ones. — Marcus Aurelius
June 06, 2011
MYOB Not Printing Chinese Characters in Invoices
Cheers,
Steve
February 25, 2011
Endianess, Thy art Sneaky
So, for the record: Linksys WUSB600N V2 runs just fine on OS X 10.5.8 running on G4. It does 5GHz and successfully authenticates with my airport express, which the Monoprice USB 2.0 Wireless N it replaced didn't.
Cheers,
Steve
February 21, 2011
Broken OS X Installers and How to Fix Them
This means on a new machine, or one that never had the kext installed, you can't install their driver.
Fail.
It used to be that pkg installers were just directories, and fixing something like this is easy: find the offending line and comment it out. But OS X 10.5 onwards introduced flat pkgs. These don't give up their secrets so easily.
An article on cnet tipped me off to pkgutil, a program that is installed by default. It lets you expand a flat pkg into a directory, and more importantly, allows to repackage it as a flat pkg after you have excised the cause of your troubles. This last step is important because a flat pkg when unpacked has a different directory structure to a "normal" pkg and thus can not simply be open'd.
Here is what I did to fix Ralink's installer:
- pkgutil --expand installer.pkg ~/Desktop/installer-expanded.pkg
- cd ~/Desktop/installer-expanded.pkg/installroot.pkg/Scripts/
- vim preinstall #alternatively, for ppl unfamilar with vim:
- open .
- right click on preinstall, open in TextEdit.app
- comment out the offending line which is trying to remove the kext
- save and exit your editor
- cd ~/Desktop
- pkgutil --flatten installer-expanded.pkg installer.pkg
- open ./installer.pkg
Cheers,
Steve
January 27, 2011
iPhone 4 layer export script for Gimp
Exporting layers by hand gets old real quick. Thankfully the Gimp supports scripting in my favourite language: python. Even better, Chris Mohler had already written a script to do something very similar, so all I needed to do was make some simple adjustments:
#!/usr/bin/env python
# -*- coding: <utf-8> -*-
# Author: Chris Mohler <cr33dog@gmail.com>
# Copyright 2009 Chris Mohler
# "Only Visible" and filename formatting introduced by mh
# License: GPL v3+
# Version 0.4
# GIMP plugin to export layers as PNGs
# modified by Shuning Bian 2011
from gimpfu import *
import os, re
gettext.install("gimp20-python", gimp.locale_directory, unicode=True)
def format_filename(layer):
layername = layer.name.decode('utf-8')
filename1 = layername + "@2x.png"
filename2 = layername + ".png"
return filename1,filename2
def get_layers_to_export(img):
layers = []
for layer in img.layers:
if layer.visible:
layers.append(layer)
return layers
def export_layers(img, path):
dupe = img.duplicate()
savelayers = get_layers_to_export(dupe)
for layer in dupe.layers:
layer.visible = 0
for layer in dupe.layers:
if layer in savelayers:
layer.visible = 1
if layer.mask:
pdb.gimp_layer_remove_mask(layer, 0)
filename1,filename2 = format_filename(layer)
fullpath = os.path.join(path, filename1);
tmp = dupe.duplicate()
pdb.file_png_save(tmp, tmp.layers[0], fullpath, filename1, 0, 9, 1, 1, 1, 1, 1)
imgwidth = pdb.gimp_image_width(img)
imgheight = pdb.gimp_image_height(img)
pdb.gimp_image_scale_full(tmp, imgwidth/2, imgheight/2, 2)
fullpath = os.path.join(path, filename2)
pdb.file_png_save(tmp, tmp.layers[0], fullpath, filename2, 0, 9, 1, 1, 1, 1, 1)
dupe.remove_layer(layer)
register(
proc_name=("python-fu-export-layers-iphone4"),
blurb=("Export visible layers as PNG"),
help=("Export all visible layers as individual PNG files."),
author=("Chris Mohler <cr33dog@gmail.com> + sbian"),
copyright=("Chris Mohler"),
date=("2009"),
label=("as _PNG"),
imagetypes=("*"),
params=[
(PF_IMAGE, "img", "Image", None),
(PF_DIRNAME, "path", "Save PNGs here", os.getcwd()),
],
results=[],
function=(export_layers),
menu=("<Image>/File/E_xport Layers"),
domain=("gimp20-python", gimp.locale_directory)
)
main()
Cheers,Steve
June 15, 2010
Ben NanoNote First Impressions
Recently unboxed my Ben NanoNote, and I am impressed. The packaging was top-notch and classy as hell. I would not hesitate to put my name to it.
The NanoNote itself is tiny, and feels fairly solid despite the shiny-appearance which I have come to associate with cheapo devices. It's a nice little package, the only issue being the lack of cover of some sort for the micro-SD card slot, which is odd considering the USB port does.
For those wondering, the keyboard has good tactile feedback, though there is no way you are touch typing on this.
There is a microphone opening and a speaker grill, though I have no at this time exercised any of those functions.If you are wondering what the Ben NanoNote is, here is a little background:
Ben NanoNote is a $99 device which runs OpenWRT. In and of itself this is nothing special. What is special is the copyleft hardware - you can download the schematics off qi-hardware. For hardware meddlers like myself, this is a boon: we can do many interesting things when we know exactly what is available to us and how.
The copyleft nature of the NanoNote hardware is that anyone else can build their own 100% compatible NanoNote variant. This allows immediately opens the platform to competition, and it also gives product developers peace-of-mind: you can always make your own Ben NanoNote, even if qi-hardware stops making them.
In many ways, the Ben NanoNote is like the arduino: here is some hardware and schematics along with a software platform/SDK with source. Now go wild.
Cheers,
Steve
May 08, 2010
Discouraging File Sharers at LANs
My friend laments that he hasn't found a nice way to deal with file sharers such gamers aren't impacted, since some file sharing is required for games installers, updaters, drivers, etc. Any kind of port blocking, packet inspection, real-life-what-are-you-doing inspection are right out for the reasons of impotency, latency, and privacy.
After some discussion, we came up on the following idea to discourage, not ban, file sharers: limit upload rate of all ports. This won't affect 99.99% of gamers since games use very little bandwidth, and it still lets you download at full speed. This however impacts significantly on file sharers: the theoretical maximum downstream a file sharer can achieve is n-1 * upload_rate, which assumes everyone else is giving him their upstream bandwidth. Make this theoretical maximum low enough, and file sharers are better off using sneaker net.
There is an elegance to this that appeals to me - it exploits the fact gaming prioritise latency over bandwidth, and file sharing bandwidth over latency. It is also resistant to circumvention - because this can be implemented on the data link layer, it isn't something file sharers can get around by changing ports or using encryption.
If you know of any LANs that implement this policy, or run a LAN implementing this policy, I would love to know how well this idea performs in the real world.
Cheers,
Steve
December 17, 2009
Nice Work Australia Computer Society
You came to me during my first year in university, and sold yourself as the paragon of virtue and integrity - the kind organisation I would be foolish not to be associated with if I want to get anywhere in Australia doing software, or "Information Technology" as they call it now days.
I didn't join then, because I didn't have the money. I didn't join later because my career focus shifted away from software. I won't join now ever, because you have sold out.
I am referring to the honorary membership you awarded to none other than one Stephen Conroy, Internet Villain of the Year, 2009.
You had such nice things to say about him too:
“We are very pleased to honour Senator Conroy’s contribution and support of the significance of ICT to the economy and the key role of ICT professionals in Australia’s future,” said Mr Wells.
If I am so inclined as to read between the lines, I can't help but get the feeling you are thanking Mr. Conroy for pushing the Internet filter scheme, and in the process provided jobs for the programmers and technicians involved in the various trials and consultations.
“Senator Conroy has always encouraged the ACS in its role as the independent voice of the ICT profession, welcoming our input to various enquiries and working groups, and regularly attending key ACS events. We are grateful for his on-going support,” Mr Wells said.
I don't think Mr. Conroy is listening to your input, or learning from your events - he continues to believe filtering the Internet is doable, and not a waste of time and resources.
I reject you, Australia Computer Society, as "voice of the ICT profession". Your actions are deplorable and shows a lack of integrity. If I was a member, I would be ashamed.
Cheers,
Steve
June 04, 2009
microbric viper review
The microbric viper is neat. Good quality parts and unique idea. Makes a decent robotics platform if you get the wheel add-on. However, you gotta have small fingers to get some of the parts in place. Despite this, the hardware is solid, I like it. The one thing I would ask for however is more short-nuts and a printed manual, not a CDROM with a PDF. Take a leaf from LEGO and their construction manuals.
While the hardware is decent, the microbric viper is sadly let down by the software.
The microbric viper uses the basicAtom (by basicmicro), a PIC 16F87{6,7} with a custom bootloader. Now there is nothing wrong with this - arduino uses a custom bootloader too. However the custom bootloader uses a proprietary programming protocol. This is pretty fail, but what really fails is the programming software only runs under windows (or wine under ubuntu, but only for now).
IMHO the basic-esque language used by basicAtom is no better than what picaxe offers. I am completely at a lost as to why companies would use the basicmicro's products and lock themselves to a single supplier. Think about it: if basicmicro goes bust, your products using the basicAtom will not longer have a supported development environment.
Robotics companies need to seriously consider how their selection of controller will affect their customers - specifically those customers who aren't going to be running windows and staying with in the limits of whatever custom language designed by the controller vendors.
Arduino would be the best choice IMHO. Open hardware, open software. You don't have to pay premiums for the bootloader, and the number of people who will consider your product increases to include people like me.
I bought the microbric viper because it was on sale: reduced to $29 from $199. If I had known I could only program it under windows or that it used such a closed platform, I won't have bought it, even for that price.
Cheers,
Steve
April 29, 2009
Stripping trailing whitespace from XCode

Firstly, my usual approach of s/\s+$//g doesn't work since it eats up the newline too. s/\s+$/\n/g doesn't work either because the Replace: field in the find dialogue doesn't escape the \n.
Final solution is as shown: s/[ \t]+$//g
Cheers,
Steve
October 15, 2008
Dear Steve Conroy,
You can’t be serious.
You wants to filter all Internet connections now, without the option of opting out?! You want every Australian to be on a list so you can see who is “naughty” and who isn’t?!
You can’t be serious.
You wants to filter all illegal material on the Internet?!
You can’t be serious.
How on earth do you propose to classify the contents of more than 181,000,000 websites (Sept. 2008, Netcraft)!? Assuming a government worker can classify a site as illegal or legal in 1 minute, that person will have to work non-stop every day for 344 years to classify 181,000,000 websites.
You can’t be serious.
How on earth do you propose to even filter that many sites without rendering the Internet useless?!
You can’t be serious.
How can we be sure the site blocked really is illegal, when we can’t access it!? How do you stop the system from abused? How do you correct the system’s mistakes? Why isn’t any of these described in detail?!
You can’t be serious.
How on earth are you planning on preventing people from circumventing your flitters using encryption?!
You can’t be serious.
Get a fucking clue Steve Conroy. The Internet doesn’t work like that. You have a background in the broadcast industry, and the Internet is nothing like it. You should leave technical decisions to people who know what they are talking about and stop pissing off every Internet literate Australian.
DIAF,
Steve
October 09, 2008
Some people are going to hate me for this
But you can get the current function's name by using:
sys._getframe().f_code.co_name
Seems to work alright for debugging purposes. See the link embedded in the title for the origins and 3 other methods.
Cheers,
Steve
September 20, 2008
A relatively pain free Linux/OS X VNC setup
Ever since I got my 2nd monitor, I been using VNC to work on my laptop. Leopard's inbuilt VNC server isn't really VNC compliant, and has many issues when used with a normal VNC client. I have found Vine server to be an excellent replacement. The client side is a little interesting. RealVNC didn't work too well for me, in that often the screen would stop responding, or it would not receive key events. The best setup I have found is to use tightvnc with the following Vine server settings:
- Devices
- Keyboard Layout: US
- Keyboard Events: User Session Events
The client and server will happily share the clipboard if you enable it. Settings are accessed via F8 in the client, and via Preferences in the server. The client is smart enough to synchronise clipboards only when it loses focus - which would be you switching away to say, paste a url into firefox. All in all it is a fairly painless experience.
Cheers,
Steve
July 31, 2008
iwconfig not setting essid?
If iwconfig wlan0 essid blah is seemingly not working when connecting to a open wireless network, then try
iwconfig wlan0 essid blahiwconfig wlan0 key openiwconfig wlan0 enc off
The above seems to work for me by turning off encryption. It would appear with encryption enabled, iwconfig won't work for a open network because of some magic or other. If it still doesn't work, then try stick the above in your /etc/network/interfaces and prefix the commands with "wireless-", like so:
allow-hotplug wlan0
iface wlan0 inet dhcp
wireless-essid blah
wireless-key open
wireless-enc off
Hope this help some people, it drove me nuts!
Cheers,
Steve
July 24, 2008
grub, xfs, debian
Running grub-install with a XFS partition will likely fail - there is a reason lilo is used when XFS is root! The issue is grub-install creates the stage files in /boot/grub, which grub then expects to find when it accesses the disk directly using its own file system drivers. For most file systems sync is sufficient to force this to be true, but not with XFS - unless grubs's XFS drivers replays the journal, grub won't find the files. The detailed why of this is covered in this thread. To get around this, one needs to effectively replace sync with mount -r -o remount /; mount -w -o remount /. A quick a nasty way to get grub going with XFS partition is as follows:
- init 1 # need single user mode to be able to remount root
- cp /usr/sbin/grub-install /tmp # make a copy of grub-install to butcher
- vim /tmp/grub-install
- # now butcher grub-install as follows:
- # 1. find the line that says "Sync to prevent GRUB from not finding stage files
- # 2. deleted everything after sync
- # 3. add exit 0 after sync for good measures
- /tmp/grub-install # invoke our amputated grub-install to just produce the stage files
- mount -r -o remount / # flush everything by mount as read only
- mount -w -o remount / # remount since grub needs it to be rw
- grub # invoke the grub shell
- root (hdx,y) # manually specify the disk x partition y where /boot/grub/* is located
- setup (hdx) # install grub into the disk x's MBR. DO NOT specify a partition number, XFS's sector 0 is NOT reserved for boot loaders!!
- quit # exit grub
- reboot # should work now
Cheers,
Steve
July 16, 2008
unoffical libfg repository
I have set up an unofficial git respository for libfg patches and new swig generated python interface, as Gavin Baker (the author) appears to be busy with other things. This is a maintance only repository as far as libfg goes - I don't plan on adding any more features (since all the ones I need are there already). I will however work to produce a more pythonic interface to libfg, as the swig generated interface is a straight port of C api into Python.
Currently the repository contains the following fixes and enhancements:
- RGB565 and RGB555 patch by Adalbert Prokop
- fg_new_compatible_frame patch by echoline
- mmap fix by me
- swig generated Python interface by me
If you have a patch against libfg, please post it at the libfg project's page first, and then to me if Gavin does not respond. I do not intend to take over development of libfg, and it is my hope Gavin will in the future make this obselete/redundant.
Cheers,
Steve
June 18, 2008
Personification of Programming languages 2
An follow up on the last round of language personifications, this time contributed by brett.
PHP
The crazy party girl you meet at Uni; she's easy to get along with at the beginning; she reminds you of other girls you've known before and hey, its a bit of fun; you're only young once. But after knowing her a few months the cracks begin to show; she's pretty inconsistent and while she tries to do favours for you and help you out, she ends up making it more complicated than it needed to be. The whole time you're with her, you have this sneaking suspicion that maybe you'd be better off with Perl, even if she's harder to speak to.
Javascript
The late bloomer; in high school she was pretty dorky; she couldn't do very much and while she might have spent time in different social circles, she could never really fit in. But now the puppy fat has dropped away and she's revealed herself to be one hell of a girl. She can do things you never would have expected a few years ago and suddenly she's the life of the party, appearing in places you never would have expected and doing things that make your jaw drop.
bash
The fat chick you picked up at that party, only because you were drunk and horny. You'd never tell your friends about it, but it got the job done, so to speak.
QBasic
Your first girlfriend in highschool. You were so nervous you didn't even end up kissing.
Many thanks again to brett for sharing these with us :-D
Cheers,
Steve
May 05, 2008
April 28, 2008
{} I <3 thee
Firstly, I am the kind of guy who likes tabs over spaces, because I don't like forcing my particular preferences on to other people. To wax poetic, I like to give other people the freedom of choosing how they want their code indented. This of course brings me into the firing line of python programmers, for whom the 4-spaces-per-indentation-level is equivalent to the Ten Commandments handed down from Mount Sinai. Officially, python doesn't care, but thats like saying officially the Church accepts evolution.
I was editing a working python file written by some one else today, and wanted to convert it to tabs (yes yes, I know all about leaving files as I found them etc. Silence). So I ran unexpand -t 4 on the file. This simply replaces 4 spaces with one tab. This should have given me a working and correct python file though now indented with tabs. Naturally (Moore's law and all) this is not happened. The newly tab-indented file was riddled with errors because the original file was not indented properly so the simple conversion did not work. And as I go about fixing the errors python threw at me, I realised to my horror that information about the structure of the code was corrupted. Because python interprets code structure based on indentation, if your indentation is incorrect, your code is incorrect.
In comparison, a brace using language like C would have made the corrections trivial, because the braces explicitly specify the code structure. Python's argument that everyone indents anyway and thus braces are redundant is flawed - braces are not redundant because braces represent the separation of content from presentation, something that has been hammered into developers. In ignoring this, python has allowed a new class of errors - changing the appearance of code will now change the function of the code. I really can't see how this is a good thing.
If nothing else, python's integration of presentation and content, and thus presentation and program correctness makes it a far less robust language than brace using languages. Less robust in that a mangled python file is unrecoverable unless you actually read the code to figure out its structure, and that incorrectly transcribed python will likely run anyway with no syntactic or runtime errors.
Consider for example, the following code:
for n in names:
foo(n)
bar(n)
If you were transcribing the code and accidentally did not indent bar(n), the code now does something complete different yet no syntax or runtime error will be thrown. Now if the above code used braces, then it would have no effect. And if you forgot the brace, a syntax error will be thrown.
To be fair, python is a lovely language, and I do love it and use it extensively. Whitespace-as-syntax stance appeared at first to be a great idea, and one which now appears to be short sighted and naive. If nothing else, at least an interpreter which disallows incorrect space-indent files, that way tab->space and space->tab conversions would work correctly all the time.
Let me now put on my flame retardant undies, and you can flame away
Cheers,
Steve
March 28, 2008
eeepc, likes and dislikes
Likes:
- nice and small
- all the hardware works, including sleep/suspend
- runs debian based OS by default
- can run an external monitor at decent resolution
Dislikes:
- uses fastinit which only boots into single user mode, so user "user" is always logged in. Endless frustration playing with X11 startup in vain to get a multiuser login screen
- when kmixer shows a speaker with a cross on top, it means built in speakers will be used. When it is a speaker with no cross on top, it means headphone jack will be used. Talk about counter-intuitive.
- keyboard truly sucks
Cheers,
Steve
March 18, 2006
Fourier fitting with gnuplot
gnuplot can be used to fit a fourier series to a series of data points. In my case it was an observation log for the star BE Lyncis from the Bossom Observatory, curtsey of Geir Klingenberg.
Firstly one needs to define a time function t(x) such that as x progresses from its minimum value to its maximum value t(x) ranges from 0 to 2PI. In my case minimum value of x was 2453416.20172 and maximum value was 2453416.42447. So my t(x) was constructed as follows:
We now need to define a fourier series, f(x). It takes the generic form of:
...+{a#*cos((#+1)*t)+a(#+1)*sin((#+1)*t)}
Where #=0,1,2,3... infinity, and is the degree of the fourier series. Now we can use gnuplot's fit function to determine the values of all co-efficients and the constant c:
A quick explanation: we are trying to fit f(t) where t=t(x) using data from the file be_lyn-2005.txt with data from the first and second column. The order of 1:2 is significant as it is in the form of x:y. Thus 2:1 means the first column is y value, second column is x value. (This is from experience, if any one knows better, tell me!)
Co-efficient values and the constant will be computed and shown, along with various statistic data. An plot of the fourier series and the observed data is shown below.

The plain text file be_lyn-2005.txt has 3 columns: JD, instrumental magnitude, and error estimate, the later of which was not used.
Cheers,
Steve

