The Blog of Maxim Porges

Archive for June, 2010

  • Loom Becomes as3commons-bytecode

    As you know if you follow my blog, I was working for a while on a bytecode parsing/weaving library for AS3 called Loom. I worked on this library during the six months coming up to my wedding, and then after we got back from our honeymoon I decided I just couldn’t be bothered to dig through binary with a hex editor any more.

    I offered the project up to the people on the Loom forums, but there were no takers… until now! Roland Zwaga has been emailing me on and off for a few weeks asking questions about the library, which he’s been digging in to in order to add functionality to as3-commons and Spring Actionscript. They needed a way to extract the private and protected class data (amongst other things) during reflection, and the only way to do that in AS3 at the moment is to parse the bytecode. Rather than starting from scratch, Roland used Loom as a basis for understanding the AVM2 spec, and built from there.

    After asking me if I minded (which of course I didn’t), Roland’s decided to publish the guts of Loom with his additional work as as3commons-bytecode. He sent out a message to the as3-commons dev list today as follows.

    Good day gentlemen,

    as3commons has a new addition: as3commons-bytecode. This library used to be known as Loom-as3 (, sadly before Loom was completed its creator, Maxim Porges, didn’t have the personal time anymoe to invest in its completion. Which is a huge shame since Loom is one of the most complete Actionscript implementations of the AVM spec.

    A while ago I was sifting through the Loom sources to try and get a better understanding of all of this bytecode business and came to the conclusion that Loom would be an excellent addition to as3commons and would, as a first, be a great basis to implement bytecode based reflection on.

    I just committed version 0.5 which will give you just that, the ByteCodeType class is the main entry point and c an be used like this:


    or if you want to parse the loaded RSLS as well:

    for (var info:* in systemManager.preloadedRSLs) {

    After that the ByteCodeType instance can be retrieved through these methods:


    or, if you’d like to inspect all of them, loop through the cached instacnes like this:

    var typeCache:TypeCache =
    for each (var key:String in keys) {
    	var type:ByteCodeType = typeCache.get(key) as ByteCodeType;
    	/* ... do something... */

    The resulting reflection classes are all inherited from the ones found in as3commons-reflect but augmented with the extra information we can extract from the bytecode. This includes private and protected members, optional parameter values, parameter names (allthough those values are not always reliable), initialized member values, and more.

    Anyways, I think there’s PLENTY of room for improvement and other functionality for this library but for now I would really appreciate it if you guys could check it out, give it a test drive and give your opinion, criticism, etc,.

    100 million kudos and the same amount of respect in tons go to Maxim Porges who did all of the heavy lifting in this library, I only finished some little details added the reflection bits.

    have fun with the code!



    Although I didn’t have any interest in finishing Loom, I didn’t want all of the work I put in to it to be completely in vain. One of the things I really like about the open source community is that you can take somebody else’s work and put it to use for whatever you have in mind for it. In this way, people can learn so much from each other and push the envelope forward in to new areas the original authors never thought of. Loom certainly wouldn’t have been possible if I hadn’t been able to look deep in to the source of the Mozilla Tamarin and hurlant eval projects.

    In closing, I’m really glad to see my work on Loom contributing value to the community now as part of ascommons-bytecode, and I look forward to seeing where things go under Roland’s leadership.

    2010.06.27 / 5 responses / Category: Uncategorized

  • Arduinome Coming Soon!

    I ordered the parts for my Arduinome today, referencing the excellent sources at FlipMu and

    I’ll be documenting my journey in to Arduinome construction as the parts come in, so stay tuned! I’m also going to be maintaining a page on my site with all my Arduinome reference materials for others to follow in the future.

    In the interim, here’s the guy from Pretty Lights jamming out on his monome (the thing that inspired the Arduinome). He’s using a sample manipulation app for the *nome devices called mlr, which is a Max/MSP patch. You can run pre-compiled patches in the runtime without having to buy Max/MSP.

    2010.06.20 / no responses / Category: Uncategorized

  • Setting up WebDAV on OS X

    I was interested in setting up a WebDAV server on my Mac so that I could send files to and from it on my iPad with GoodReader. I found an article about setting up WebDAV on OS X, which was almost correct. Here’s my updates with the proper process and correct configuration.

    Before you start, note that any changes made to the Apache configuration files require a restart of the Apache server. This can be done by either checking and unchecking the Web Sharing checkbox under Sharing in System Preferences, or running the following command:

    sudo apachectl graceful

    These instructions help you to set up a WebDAV server on your machine which exposes the directory /Library/WebServer/WebDAV as your document root. If you want to set up a different directory, then change that path accordingly in all the remaining instructions. Note that the Apache user seems to need to own the path that you expose over WebDAV, so keep that in mind as you are setting things up.

    1) Start Apache via System Preferences
    Open System Preferences => Sharing and click the checkbox for Web Sharing.

    2) Modify /etc/apache2/extra/httpd-dav.conf
    Open this file and remove any existing WebDAV entries. Modify accordingly to end up with something like this. You should only have one DavLockDB entry anywhere in the file; in my case, one was already there so I left it alone.

    DavLockDB "/usr/var/DavLock"
    # Locks down all directory access by default. You can then override
    # this with additional <Directory/> entries
    <Directory />
        Order Deny,Allow
        Deny from all
    # Exposes the contents of /Library/WebServer/WebDAV on the
    # URL http://hostname/webdav/
    Alias /webdav "/Library/WebServer/WebDAV"
    # Sets up WebDAV with access controls. Uses digest auth so you
    # don't need SSL for your credentials (although note that none
    # of your file transfers will be encrypted, so don't pull anything
    # sensitive over the wire without SSL). Specifies a file with
    # usernames/passwords, and dictates the realm applicable
    # to this configuration
    <Directory "/Library/WebServer/WebDAV">
       Dav On
       Order Deny,Allow
       Allow from all
       AuthType Digest
       AuthName WebDAV-Realm
       AuthUserFile "/usr/var/webdav.passwd"
       Require valid-user

    If you want to get fancy, there is some additional information on these directives for mod_auth_digest and mod_dav at the Apache web site.

    3) Open /etc/apache2/httpd.conf and make sure these lines are uncommented
    This enables the appropriate Apache modules that will make use of the configuration you just created.

    LoadModule dav_module libexec/apache2/
    LoadModule auth_digest_module libexec/apache2/
    Include /private/etc/apache2/extra/httpd-dav.conf

    4) Create directories with appropriate permissions

    sudo mkdir -p /usr/var
    sudo mkdir -p /Library/WebServer/WebDAV
    sudo chown -R www:www /Library/WebServer/WebDAV
    sudo chown -R www:www /usr/var

    5) Create the password file and set appropriate permissions

    maxbookpro:usr mporges$ sudo htdigest -c /usr/var/webdav.passwd WebDAV-Realm "mporges"
    Adding password for mporges in realm WebDAV-Realm.
    New password: 
    Re-type new password:
    maxbookpro:usr mporges$ sudo chgrp www /usr/var/webdav.passwd

    6) Restart Apache

    sudo apachectl graceful

    7) Test
    As the original article suggests, the easiest way to test is to mount your WebDAV server via Finder.

    To do this, open Finder and select Go > Connect to Server (⌘K). Type your WebDAV URL, or http://localhost/webdav/ if you are on the server locally. Note that the trailing slash (“/”) is important, and you will not be able to connect without it.

    You will be prompted by Finder to type in your username and password, and you need to be careful to enter these exactly as specified for the htdigest command.

    Upon success, you will have mounted your WebDAV folder within Finder, and you should be able to copy a file to the folder.

    I found that the trailing slash was not required when mounting the WebDAV drive in Snow Leopard, but it doesn’t hurt. You’ll be able to both read and write files to the WebDAV share.

    If you have any issues, check Console for logs from Apache. It will yell at you if your config is bad.

    2010.06.19 / 3 responses / Category: Uncategorized

  • Possible Fix for iPad Wifi Problems

    There’s a well-known issue with iPad wifi. While I don’t have the chronic wifi problems that I have heard of others having, I did have some issues with my wifi connection being pretty weak from my home router in certain rooms of the house (typically the ones furthest from the router). I have an Airport Extreme base station, one of the newer square models.

    The problem I have had is a one-bar signal when furthest away from the router. This is not a problem on my laptop, so I knew it had to be something with the iPad reception. The low reception can be a pain on the iPad when watching videos and other high-bandwidth activities. Just for giggles, I switched my base station over to 802.11n-only from 802.11g/n-compatible, staying in the 2.4 Ghz spectrum. I’m getting much better connection speeds all over the house now, with five bars in every room.

    2010.06.07 / no responses / Category: Uncategorized