Installing su/Superuser.apk in ICS/Android 4.0 emulator 0

To avoid the Out of memory error when trying to copy the su-executable to /system/bin, you need to start the emulator manually with a large –partion-size argument:

$ emulator -avd MYNAME -partition-size 300

Then:

$ adb remount
$ adb push ~/Desktop/rootfiles/su /system/bin/su
$ adb shell chmod 06755 /system/bin/su

Python: Make simplejson.dumps output raw Javascript code 0

class JSRaw(int):
    """Hack to allow including raw Javascript code in simplejson.dumps
    output. Objects of this sort are dumped as raw strings.
    """
    def __new__(self, string):
        instance = int.__new__(self, 0)
        instance.string = string
        return instance
    def __repr__(self):
        return self.string
    def __unicode__(self):
        return self.string
    def __str__(self):
        return self.string

Example:

s = jsondumps({
    'series': data,
    'yAxis': {
        'labels': {
            'formatter': JSRaw("""
                function() {
                    return (this.value > 0 ? '+' : '') + this.value + '%';
                }""")
        }
    }
})

Storing times in UTC in Django 0

I just want to store my time values in UTC, and render them in Europe/Berlin for display, as supposedly one should, and Django, in 2011 and with 1.4 looming, still does not support this (although things may be happening).

I’ve found that the simplest way to deal with this is to use a filter which can convert from UTC to the TIME_ZONE setting, and can be placed before any of Django’s time, timesince, nativetime etc. filters one may want to use.

That still leaves you with a lack of timezone support in the admin, or when using model fields in general, but if you don’t care about those, this is the quickest way to make it work.

What I learned 0

  • Gnome 3 is actually quite nice, I think I prefer it over Unity. Only if it weren’t so buggy. And had better multihead support.
  • Unity has some pretty nice touches as well. Like the ALT+TAB’ing into a specific window of an app.
  • Even the propriety Catalyst fglrx driver can’t properly drive a 3-head 6400×1440/1200 setup when compositing is enabled. It works just fine in Windows.
  • But Windows 7′s multimonitor behaviour is insane as well.
  • I should probably get a Mac.
  • Tiling window managers are worth a try.

iPython with virtualenv 1

You’ll find a bunch of different approaches to this on Google; Using an iPython boot script that extends sys.path with paths from the current virtualenv. Or calling the iPython script with the virtualenv’s python binary (python `which ipython`).

They all tend to be problematic; for example, the latter doesn’t work if the virtualenv has been configured with –no-site-packages.

Why not simply install iPython inside the virtualenv proper? This is what I’ve been doing for a while, reluctantly, and I’m finally aware of what has bothered me about it: iPython clocks in at an insane 8.3 megabyte (the uncompressed size is 18 MB, about 15 of which is documentation). On my slow DSL connection the download takes a good minute.

Using virtualenvwrapper, I’ve now added this to my postmkvirtualenv script:

CACHE=$WORKON_HOME/.cache
mkdir -p "$CACHE"
$VIRTUAL_ENV/bin/pip install --download-cache="$CACHE" ipython

This gives me iPython in every new virtual environment, at the cost of 2 or 3 seconds installation time.

Ubuntu app indicators when using PyGObject 0

PyGObject and the Python appindicator module don’t agree with each other. As soon as I import “appindicator”, all objects from the gi.repository.Gtk namespaces seem to reset to what might be PyGTK, not sure. However, with gir1.2-appindicator-0.1 (on Natty) installed , you can do:

from gi.repository import AppIndicator

ind = AppIndicator.Indicator.new(
            "send-to-kindle",
            "indicator-messages",
            AppIndicator.IndicatorCategory.APPLICATION_STATUS)

self.menu = Gtk.Menu()
item = Gtk.MenuItem()
item.set_label("Menu Item")
item.show()
self.menu.append(item)

self.menu.show()
ind.set_menu(self.menu)

Note that there is a gir1.2-appindicator3-0.1 package in Natty, which provides a AppIndicator3 object, which seems to be the GTK3 version, and pulls a bunch of GTK dependencies. After installing it on Natty, I was seemingly unable to work with GTK2 in PyGObject, so be careful (uninstalling the GTK3 packages fixed it). Jockey (the “Additional Drivers” tool) is using AppIndicator3, and from looking at the source, AppIndicator3 works without attaching a menu to it. Apparently Canonical still gets some things right.

Automatically backup Google Reader subscriptions 0

Most of the scripts out there seem to be broken (like gookup). So I’ve written one that works:

https://github.com/miracle2k/linuxutils/blob/master/export-google-reader-subscriptions.py

It uses Matt Behrens libgreader library for the hard part.

Building Hibiscus 0

Steps to build a custom Hibiscus plugin for Jameica:

  • Checkout the code: The “hibiscus” module from the Hibiscus project, the “jameica” module from the Jameica project: “cvs -z3 -d:pserver:anonymous@cvs.berlios.de:/cvsroot/hibiscus co hibiscus && cvs -z3 -d:pserver:anonymous@cvs.berlios.de:/cvsroot/jameica co jameica”.
  • Within jameica/build run “ant nightly”, which will generate releases/jameica-lib.jar
  • Edit hibiscus/build/build.properties, makedefine.jameica.dir point to the Jameica checkout, relative to the Hibiscus root directory (not the build/ subdirectory).
  • Running “ant nightly” within hibiscus/build gives you a hibiscus-XXX-nightly.zip that can be installed into Jameica.

Netzwerk-Steckdosen 0

Z-Wave Software 1

-->