Installing Ubuntu Jaunty on a Shuttle X50
london
[info]arexx
This method should work for any Ubuntu image. I installed Netbook Remix because I thought the larger interface features would suit the touchscreen. It's working out okay so far.

Working: Wireless (not WPA?), Screen, Touchscreen, Sound.

Not working: Video acceleration? See below for update regarding Xorg crashes.


  1. Download an Ubuntu image from http://www.ubuntu.com/getubuntu/download

  2. Make a USB stick using instructions for your operating system from https://help.ubuntu.com/community/Installation/FromImgFiles

  3. Add a keyboard and mouse to use as an input device until the touchscreen is calibrated.

  4. Insert the USB stick and turn the machine on - no changes were required to my BIOS settings out of the box.

  5. Start Ubuntu in live mode.

  6. You will have problems with the video card. Agree to start in Low Graphics Mode until you have a network connection and can install newer Intel drivers (we'll get to this later).

  7. Install with defaults, or settings of your choosing.

  8. Restart. Remove the USB disk when you're instructed to and press ENTER.

  9. Add https://edge.launchpad.net/~ubuntu-x-swat/+archive/x-updates/ to your sources, update and dist-upgrade to get the newest Intel graphics driver. Reboot your computer and you should be in native resolution. My ultimate thanks to Arsinio and Geir Ove Myhr for solving this one. You can read Arsinio's more detailed instructions here

  10. Configure the touchscreen manually (The calibration tool doesn't get the x flip right). You can do this by editing the parameters in /etc/evtouch/config. I calibrated with the Ubuntu tool, and then reversed MINX and MAXX, set FLIPX to 1 and changed the X0-8 deltas to 0. You'll then need to restart evtouch and xorg, ie. in a terminal:
    sudo /etc/init.d/xserver-xorg-input-evtouch stop
    sudo /etc/init.d/xserver-xorg-input-evtouch start

    and then log out and log in again. My screenlimits according to the calibration tool are as follows:
         3490, 831      605, 826
         3535, 3258     561, 3250

    ... note that the X co-ordinate decreases from left to right. The X flip hack is working pretty well, except that it doesn't compensate for a certain amount of twist/non-linearity at the extremities. Five minutes with the compensation tool and a calculator would probably solve it. YMMV.



Ubuntu Netbook Remix is working out quite nicely, netbook-launcher is fun to use with touch. CellWriter provides an operable (but not particularly usable) on-screen keyboard for brief input.

Pics or it didn't happen:






Update 2009-09-03

The screen randomly stops responding. I'm able to SSH into the computer, so everything apart from the screen seems to be ticking along, but the image on the screen remains frozen until the machine is rebooted. Lines like this appear at the end of /var/log/Xorg.0.log:

(EE) intel(0): First SDVO output reported failure to sync

Some googling finds this bug report. I haven't played with the driver (which if you remember we installed out of a PPA earlier) but I did find this other similar bug report which suggests disabling DRI and acceleration. With these changes, the system appears stable so far. You can disable DRI and acceleration by adding the following two lines to your /etc/X11/Xorg.conf:

Section "Device"
        Identifier      "Configured Video Device"

        # To try to prevent gfx hangs
        Option "NoDRI"
        Option "NoAccel"        

EndSection
Tags: , ,

Javascript, scope and var - averting incomprehensible disaster
london
[info]arexx
So you're calling a function and a variable in the scope you're calling from is mysteriously changing value? There may be a really simple fix to save you from having nightmares about semantic closure scoped first-class dangling references and let you get on with your application instead.

Are you using this pattern to iterate over a list?

for (n in things) {
    var thing = things[n];
    // ...
}


Not so fast, glasshopper. You're doing it wrong. You just defined n as a global. If you're using n again in a loop in a function called from within your loop, it's going to hose all over the outer loop too. Do this...

for (var n in things) {

    var thing = things[n];

    // ...

}


... and maybe you'll stand a chance of sleeping at night. And by "you" I mean "I". And by "sleeping" I mean "not crying". And by "night" I mean "Joe Lanman, who explained what the hell was going on here".

Remote Logging for Python via XMPP (Jabber, Google Talk)
london
[info]arexx
# moononstick.py

# Version 1.0

# A really simple Python logging module Handler that sends log

# messages via XMPP. Compatible with Jabber and Google Talk.

# (c) Alex Macmillan 2009.



# If you like you may consider this work licensed under WTFPL 2.0.



# INSTALLATION and CONFIGURATION



# 1. Install dependencies:

#    $ easy_install dnspython

#    $ easy_install xmpppy



# 2. Copy moononstick.py to your Python project's directory.



# 3. Set the Jabber ID that messages will be sent from.

#    You can register the logger a new Jabber ID for this

#    purpose at, for instance, jabber.org.

#    eg. yourname_devlogger@jabber.org

MY_JID = "yourdevjabberid@example.com"



# 4. Set the sending Jabber ID's password

MY_PASSWORD = ""



# 5. Set the Jabber ID that you want to receive messages.

#    eg. yourname@gmail.com

DEST_JID = "yourname@example.com"



# 6. In your application, add:

#    import moononstick

#    moononstick.init_jabber_logging()



# You're done.



# Note: You may want to use an instant messenger to log in with your

# new dev jabber id and make sure it's friends with the jabber id that

# will be receiving log messages first, to ensure that the dev account

# is allowed to send messages to the receiving account.



import logging

import sys,os,xmpp,time



tojid=DEST_JID

jidparams={

    'jid' : MY_JID,

    'password' : MY_PASSWORD

}



# Some cheap-ass globals.

jid=xmpp.protocol.JID(jidparams['jid'])

cl=xmpp.Client(jid.getDomain())



# This is the format of messages that you will receive.

jabberformatter = logging.Formatter("*%(asctime)s* - %(name)s - *%(levelname)s*\n%(message)s")



def connect():

    con=cl.connect()

    if not con:

        print 'MoonOnStick: could not connect!'

        sys.exit()

    print 'MoonOnStick: connected with',con

    auth=cl.auth(jid.getNode(),jidparams['password'],resource=jid.getResource())

    if not auth:

        print 'MoonOnStick: could not authenticate!'

        sys.exit()

    print 'MoonOnStick: authenticated using',auth



def present():

    cl.sendInitPresence(requestRoster=0)



def message(text):

    id=cl.send(xmpp.protocol.Message(tojid,text))

    print 'MoonOnStick: sent message with id',id

    

def disconnect():

    cl.disconnect()



class JabberHandler(logging.Handler):

    """Handler that sends all received messages via XMPP to a willing recipient."""

    def __init__(self):

        logging.Handler.__init__(self)

        # Create a Jabber connection.

        connect()

        present()

        

    def emit(self, record):

        message(self.format(record))

    

def init_jabber_logging():

    # Get a Jabber handler.

    jh = JabberHandler()

    # Set it's formatter to the jabber formatter.

    jh.setFormatter(jabberformatter)

    # Attach to the root logger.

    r = logging.getLogger()

    r.addHandler(jh)

    # Set the root logger to log all DEBUG messages and above.

    r.setLevel(logging.DEBUG)

Home