Python text table modules 0

Windows 7 SMB Sharing 0

Windows 7 network folder sharing has been driving me crazy lately. I don’t remember it being this hard.

I only want to share folders that I select. When I add Everybody permissions, I want guests to have access to it.

  • Windows seems to like to share the \User\Public folders, and ‘Public folder sharing’ in ‘Network and Sharing Center -> Change advanced sharing settings’ does not seem to have the desired effect. I simply disabled sharing of the C:\Users folder via ‘Properties -> Advanced Sharing’. Sometimes this seems to reset.
  • It seems that when sharing a folder within your user directory and using the simple ‘Share’ option in the Properties dialog, then Windows will choose to share this as the full path within Users, i.e. Users\michael\Desktop\share. Only using the ‘Advanced Sharing…’ button in the Properties dialog can you create a share that does not expose the path. This behavior is different from folders outside of the user directory.
  • Giving ‘Everybody’ access to the share is not enough if the actual file permissions do not allow access.

Some quick thoughts on the Mass Effect 3 ending. 0

Uhm, spoilers ahead.

  • It’s decent. I would rather have the debates and the theories than another ending.
  • I liked the Stargazer postscript too. It just hit some nerve.
  • The complaints that the endings are too similar seem flawed. First, since there is only one story, mine, there is only one ending. This may be different for people who play multiple characters. Second, the endings were actually very much different, conceptually. They were just visually identical, and I wonder whether this is the real source of the disappointment. Had Bioware created distinct ending sequences, would people still think them to be the same?
  • Certainly, the ending montage is quiet short, and does seem a bit on the cheep. For a 100+ hours trilogy, a Lord of the Rings-type ending seems appropriate. No doubt that some scenes of your war assets in action would have elevated those to more than just point grinding.
  • At this point, the Matrix-like Guardian of the Universe character reveal may have become just a bit old now.
  • I see an open ending right after the Illusive Man conversation, with Shepard and Anderson staring into space. Mass Effect might just not be that type of story though.

The indoctrination theory is interesting, but in the end, I don’t buy it. The color-coding argument seems fundamentally flawed. The destroy option is red because destroy is simply the Regengade choice. The control option is blue because control is the paragon choice. Anderson may otherwise be a Paragon, but he and you have been working towards a goal, which, in the dichotomy of this choice, is the Rengeade goal. Shepard sees the Illusive Man as executing the Control option, not because he is a Paragon, but because Control has always been the Illusive Man’s choice.

My doubting the theory nonwithstanding I would point to this article for a rebuttle of some of the criticism of the ending.

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.

Update 2012-04-10: In order to make my app work with both Gtk3 (Oneiric) and Gtk2 (Natty), I am now using this code:

try:
   from gi.repository import AppIndicator3 as AppIndicator
except:
   from gi.repository import AppIndicator

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.

-->