Please send us your complete address and phone number so we can send you a
XO B2 machine.
If I said I hadn't been repeatedly refreshing the package tracker page ever since i'd be lying. :-) Unfortunately while I know the package left Auckland late this morning I won't be getting it until tomorrow at the earliest as today is a public holiday. :-(
Now I just have to come up with something to do with the OLPC laptop to make their investment in sending me one worthwhile:
(The delivery is the result of a submission I made at linux.conf.au in January where Jim Gettys invited people to email development ideas for a chance to get a OLPC laptop to develop on.)
But remember: "It's an education project, not a laptop project."—Nicholas Negroponte
You didn't think I was going to leave you without a dope beat to step to... I mean, having to use ming from C, did you? Of course not, I wouldn't be so cruel...
So, ming has a Python binding available as a separate download or from CVS but it's based on SWIG and not exactly actively maintained (for example no SWFVideoStream support). In fact, I did try to bring the SWIG binding up to date but it wasn't even clear what parameters were used to produce it in the first case...
Since any potential speed benefit from having a compiled C extension is probably not a major factor for ming and because I've had experience with ctypes before I decided I'd try using ctypes to create a Python binding for ming.
The cool thing about ctypes is that in the simplest cases once you've compiled the target library in the usual way you're ready to go. In addition, it's relatively straightforward to convert a chunk of C to the equivalent Python—it won't be pretty or Pythonic but will probably be functional.
A basic example
By way of a simple example based on test/Movie/new/test01.c: (Note: Change library name as appropriate.)
#!/usr/bin/python
#
# Requires `libming.0.4.0.dylib` in the current directory
# or in the search path.
#
from ctypes import *
libming = cdll.load("libming.0.4.0.dylib")
if __name__ == "__main__":
if libming.Ming_init() != 0:
raise Exception("Ming_init failed.");
movie = libming.newSWFMovie();
bytesout = libming.SWFMovie_save(movie, "test01.swf");
print "Bytes written:", bytesout
The result will be a valid, but boring .swf file.
More complicated stuff
Once we get much deeper into ming usage we start needing to do things like casting values and it gets somewhat unpleasant. Fortunately, there's a way of making that easier too—my intention is to return to that topic in a later post.
Compile ming Flash generation library on OS X (ming 0.4.0 beta 4)
libming is "a library for generating Macromedia Flash files (.swf), written in C". As of the current beta (0.4.0.beta4) it does not compile out of the box for me (OS X 10.4 PPC) so I thought I'd write up what worked for me.
For future reference, when trying to compile out of the box the following error occurs when trying to generate libming.0.4.0.dylib:
ld: Undefined symbols:
_yylex
/usr/bin/libtool: internal link edit command failed
The problem seems to occur when linking against libfl, I'm not entirely clear why it happens but if you remove the library from the link process the problem "goes away"—seemingly with no ill effects—the small patch below implements this work around.
How to compile
It seems I had the necessary dependencies (such as libpng) already installed but if you don't you might want to follow the existing ming OS X installation instructions for that.
Okay, here's what you need to do:
wget http://dl.sourceforge.net/sourceforge/ming/ming-0.4.0.beta4.tar.bz2
tar xjvf ming-0.4.0.beta4.tar.bz2
cd ming-0.4.0.beta4
You can install the library now or run a quick test:
cd test/Movie/new/
make test01
./test01
../../../util/listswf test01.swf | diff -u test01.ref -
The last command should result in no output—if there are any differences things didn't go as planned...
Hopefully things did go as planned however and you can now start playing with ming on OS X...
The future
I've been working with the ming people on #gnash and hopefully the fixes will be included before the next release. It appears this can be applied to the version in CVS to fix the flex library issue in the proper place:
--- configure.in~ 2007-02-22 07:32:11.000000000 +1300
+++ configure.in 2007-03-29 04:33:23.000000000 +1200
@@ -198,7 +198,6 @@
dnl --------------------------------------------
AC_PROG_YACC
-AM_PROG_LEX
AC_PROG_LIBTOOL
if test x"$LIBTOOL" = x; then
AC_MSG_ERROR([could not detect libtool, bailing out])
SpyderMonkey // twiddle your Javascript from Python
I should prefix this post with the proviso there is no code online yet—yes, I know that sucks but given a choice between (finally) posting about this now or waiting until I have the code online I figured the former was better.
Here is the abstract about the project I submitted to linux.conf.au last year:
SpyderMonkey : twiddle your Javascript (or someone else's!)
from Python
SpyderMonkey (http://code.rancidbacon.com/spydermonkey/) aims to let
you twiddle with your Javascript (or someone else's!) from Python.
While at least one unmaintained Python wrapper for JavaScript exists
(http://wwwsearch.sourceforge.net/python-spidermonkey/) SpyderMonkey
differs in its implementation by using ctypes
(http://docs.python.org/dev/lib/module-ctypes.html) to wrap the
underlying Mozilla spidermonkey JavaScript implementation
(http://www.mozilla.org/js/spidermonkey/). SpyderMonkey is also the
only implementation I am aware of that also wraps the parser and not
just the interpreter--this is key to its use in static JavaScript code
analysis.
The primary motivation for wrapping the JavaScript parser was to
enable further development of JavaScript reverse-engineering and code
analysis tools.
During my previous efforts of reverse engineering of JavaScript "Rich
Internet Applications" like GMail, Google Maps and similar products I
developed a number of scripts based on regular expression parsing
"pretty-printed" versions of the obfuscated/compressed source
code. While simplistic, these scripts were able to generate Class and
Function references listing arguments and the locations where they
were used (http://libgmail.sourceforge.net/googlemaps/maps.js.html).
Eventually regex based parsing runs into a wall and this drives the
use of an actual parser. JavaScript has a quite complex grammar and in
my research I was unable to find a functioning pure-Python JavaScript
parser.
This presentation will look at the development of the GPL SpyderMonkey
wrapper and some of the issues involved in its construction. In
addition we will look at some actual and potential applications that
an easier Python-friendly interface allows us to construct in order to
assist efforts in areas of debugging, reverse engineering,
inter-operability, maintenance and source recovery.
With most RIA JS applications using compression or obfuscation and
environments like Google's Web Toolkit AJAX framework for Java
(http://code.google.com/webtoolkit/) (or Python's PyJamas
http://pyjamas.pyworks.org/) producing JavaScript without direct human
involvement there is a growing need for tools to analyse this
generated-code. Attend this session and learn what approaches can work
for you now and how SpyderMonkey may help you create new tools for the
future. (In preparation for the perhaps inevitable "Ummmm, I thought
*you* had the original source code..." realisation.)
So, yeah, anyway, the proposal didn't get accepted and so the code's still sitting on my harddrive... The SpyderMonkey page does have a cool logo on it though—that's got to count for something, surely? :-)
As mentioned in the abstract I was attempting to wrap the SpiderMonkey Parser API except it didn't/doesn't really have an official one so I had to make it up as I went along. I wrapped enough of the spidermonkey library with ctypes that I was able to detect items such as functions and variable declarations. This was implemented by way of processing the tree produced by calling js_ParseTokenStream.
I would like to Tidy-Up-The-Code-Enough-To-Release (TM)—don't you hate it when people write that—but a release ain't going to happen tonight. Sorry!
One of the biggest negatives about being self-employed and working from home is the social isolation that often goes along with it—a complaint I have had re-enforced by my contact with other home-based self-employed people. A possible solution is to have a shared office with other self-employed people. The downside to this is there is a big jump from working from home to working somewhere where you need to pay a weekly office rental with a medium- to long-term commitment. An alternative approach is to make use of "co-working facilities".
A co-working facility provides office space (or desk space) on a more casual basis than a traditional office rental arrangement. The "tenants" may be a mixture of "foundation" and "casual" where the former receive a better daily rate in exchange for an agreed term commitment.
Here are a few related links describing various implementations of this idea:
I would really like to see a coworking facility develop in Christchurch. In fact, I would like to see multiple facilities develop in Christchurch. Ideally I think a city like this should support multiple suburb-based coworking facilities: I don't want to trade a no-commute lifestyle for a long commute to an office!
At present I wouldn't be in a position to bankroll such a project but I do wonder if existing organisations or individuals would be in a position to support a development like this through financial support or provision of currently under-utilised space. Perhaps one or more of these:
Christchurch City Council
Canterbury Innovation Incubator
University of Canterbury
Canterbury Development Corporation
Christchurch City Libraries
Successful local businesses
Speaking for myself simply having a space with internet access and power would be great. Any offers? :-)
Tracking code with Google Code Search
When Google Code Search was released I decided to track down a little watermark I put in something I did a while back.
In the early days of Google Maps when I had developed an approach for displaying a map in a non-Google page I put up some example JavaScript. Because JavaScript tends to be a very "cut and paste" language I thought I'd put in a unique identifier to see where the code snippet ended up. So, in a couple of places I attached the suffix _frb to variable names. When I searched for container_frb it delivered two results—one which seems to acknowledge the source and one which doesn't.
Most of my contribution was behind the scenes as general dogsbody with some script ideas also. I did get a walk-on one-liner though and produced the wonderful credits at the end—I wonder if that's enough to get an entry in IMDB? :-) The competition was a fun weekend and I mostly enjoyed the experience—I'm contemplating finding a team to be part of this year.
The director's cut linked above—slightly modified from the submitted version—is from the middle of last year which gives you some idea of how long some of these tabs have been open... It appears the movie made it onto the DVD(s) and an online high resolution version is also available.
For those of you reading this on Planet NZTech see if you can spot the (at the time) topical NZ net tech reference. (As it happens, ours wasn't the only film to make the reference..)
Oh, and if you're interested in seeing what I thought was the best film of the competition (even though it didn't win) check out the masterpiece that is Puppeton—it's classic—may feature some offensive content.
Did I really say that?
An IM conversation with Nat Torkington before Christmas ended up adding a couple of items to O'Reilly's Open Source Gift Guide: OpenMoko phones and Gumstix. Apparently being "the first to break Google Maps API before they had a public API" can still be used as justification for adding my suggestions to a list. :-)
Unfortunately I received neither suggestion for an actual Christmas present but funnily enough I did end up getting to "make a Nokia 770 bluetooth-controlled model car" at Kiwi Foo Camp. (A topic which I fully intend to return to but at this rate it'll probably be mid-year before I do so...) As it happens, the Arduino system I used in the Bluetooth car hack actually featured on the gift list as well—before I knew about such things.
Planet NZTech banner
Before the recent redesign I had been looking at making a pretty header for the Planet NZTech page but before long was reminded why I left the design biz... Purely for my own future reference here's links to the two images I was thinking of basing it on: waterfall and PCB. (Of course, if a real designer felt like providing one thus saving me the trouble that'd be good too...)
Have also just added another dozen or so blogs to the feed—up to around 140 people now.
Sure plays a mean pinball...
By the way, if you're ever looking for a gift at the last minute and can't find me something here's a possibility: :-)
Today was my first day of attending classes at MIT... Ok, so not really. It is however probably as close as I'll ever get to attending unfortunately—although I did manage to visit the campus a couple of times during my trip to Cambridge last year.
On to the actual story...
While I've been aware of MIT's Open CourseWare initiative for some time I have not looked too deeply into what they have on offer. I can't remember how I ended up there today but while on the site I thought I'd have a look at what courses are available under the banner of Electrical Engineering and Computer Science. There are many papers available on the web site but there does seem to be a wide range in terms of the quality and depth of the materials online. In terms of the papers I was interested in, only 6.002 Circuits and Electronics, Fall 2000 seems to feature lecture videos and comprehensive notes.
For much of my life I have had an interest in electronics but I've also felt I've never had a strong grounding in the basics. None of the material (books, web sites) I've looked at lately have particularly grabbed me so I wondered if watching some lecture videos might help—I know, what kind of geek am I? Oh, wait, one of the geeky kind I guess. :-)
I'd probably prefer a non-RealVideo video source but overall this first experience has been pretty good—time will tell if I make the time to view the rest of the lectures. When you think about the content MIT has put online even in its current basic form it's really quite impressive—makes me wonder what I'd have done with it in my high school years.
This internet thing may yet amount to something...
My various sites are all hosted by TravisBSD run by the impressive Travis. Not only are they hosted by him but he does so gratis as a "service to the community"—which I certainly appreciate.
As an example of his service Travis has just spent about an hour and a half on IRC sorting out some issues that have cropped up along the way recently. And this in a week when he's got three college mid-terms on the one day! So, if you ever have Travis approaching you about employment or investment in the future I strongly advise you pay him some attention.
Thanks to Travis' work the following changes have occurred:
No more Planet "Asshat"
Readers of Planet NZTech may have noticed the appearance of what some have called the "Asshat space" or similar entities. The more cultured may prefer the term "extraneous accented A-with-circumflex character". Whatever one calls it, the result is a rather ugly Planet page with "Â" characters sprinkled throughout certain bloggers' posts.
A clue to the cause and the solution can be found in this Planet developer list post and I'll leave you to read the gory details there if you're interested.
There are probably other variations that would achieve the same result but that's the fix we've used.
So between this fix and other recent changes Planet NZTech should be looking much more tidy.
Now appearing on Advogato.org!
So, reports of Advogato's death were much exaggerated and it's had new life breathed into it—including the ability to syndicate existing RSS/Atom feeds from other sources. Unfortunately it did not seem to be able to successfully retrieve the feed for this blog.
Thanks to Steve Rainwater I discovered Advogato's feed reader was getting a 406 response—possibly because of an empty or non-existing User-Agent header causing mod_security to complain. After Travis spent time "fixing" the issue I discovered from the access logs that a few days ago the feed-reader started having success anyway so it seems the issue has been fixed twice. The end result is this post should now turn up in the Advogato recentlog. Yay! Thanks Steve and Travis. :-)
Various rancidbacon.com (sub)domains return
Various DNS and Apache config fixes have now also caused the following to return:
It should be noted just because they have returned doesn't mean they have any quality content on them. :-)
Future work
There's still a few mostly behind-the-scenes items on the "nice to have" list but Mr Travis has to study sometime so the above fixes are enough for today. Thanks again Travis.
New HTML Parser: The long-awaited libxml2 based HTML parser
code is live. It needs further work but already handles most
markup better than the original parser.