Some ramblings and write-ups about tech, music, travelling and other topics.

[OS X] Removing Custom Items from Finder Sidebar

  • As of 10.6: click drag the folder away then push the cmd key before letting go of the mouse
  • Manually editingĀ ~/Libary/Preferences/

Printing C-style Byte Array Using hexdump

some dummy contents

Mirroring Posts to

I'm an indecisive person; I like all the perks of running my own installation of WordPress, but still want to host my posts on I've been manually exporting from my blog on my private server ( to my blog manually using the WordPress eXtended RSS (WXR) "Export" and "Import" tools provided in WordPress dashboard. This is great, but not ideal, especially if you'd rather spend more time scripting to automate something than the time it takes to do the thing manually, like me... .... so, I've written a little Python script that uses the XML-RPC library (xmlrpclib) to fetch all posts on my private server, and posts/update them on my blog (it was raining and I was stuck indoors anyway). Currently the script only mirrors from source to target, overwriting any existing posts with the same title. I'm sure it can be improved to allow updating instead of mirroring by comparing the last modified date, and decide which way to copy, but that, as with everything else on this blog, is left as an exercise for the diligent reader...

#!/usr/bin/env python

import logging
import time
import re
import xmlrpclib
from optparse import OptionParser

MAX_POSTS = 10000   # big enough for ya?

def decode_iso8601(date):
    # Translate an ISO8601 date to the tuple format used in Python's time
    # module.
    regex = r'^(d{4})(d{2})(d{2})T(d{2}):(d{2}):(d{2})'
    match =, str(date))
    if not match:
        raise Exception, '"%s" is not a correct ISO8601 date format' % date
        result =, 2, 3, 4, 5, 6)
        result = map(int, result)
        result += [0, 1, -1]
        return tuple(result)

if __name__ == "__main__":
                        format='%(asctime)s %(levelname)-8s %(message)s',

    parser = OptionParser()

     Mirror posts from one wordpress blog to another")
    parser.set_usage("%prog ")

    parser.add_option("-s", "--source-url", dest="sourceUrl",
                      help="XML-RPC URL of the source blog",

    parser.add_option("-u", "--source-username", dest="sourceUsername",
                      help="Username for source blog",

    parser.add_option("-p", "--source-password", dest="sourcePassword",
                      help="Password for source blog",

    parser.add_option("-t", "--target-url", dest="targetUrl",
                      help="XML-RPC URL of the source blog",

    parser.add_option("-U", "--target-username", dest="targetUsername",
                      help="Username for target blog",

    parser.add_option("-P", "--target-password", dest="targetPassword",
                      help="Password for target blog",

    (options, args) = parser.parse_args()"Source server: %s" % options.sourceUrl)
    source = xmlrpclib.ServerProxy(options.sourceUrl)
    sourcePosts = source.metaWeblog.getRecentPosts(
        1, options.sourceUsername, options.sourcePassword, MAX_POSTS)   # assumes it's the first blog you have"Fetched %d posts" % len(sourcePosts))"Target server: %s" % options.targetUrl)
    target = xmlrpclib.ServerProxy(options.targetUrl)
    targetPosts = target.metaWeblog.getRecentPosts(
        1, options.targetUsername, options.targetPassword, MAX_POSTS)    # assumes it's the first blog you have"Fetched %d posts" % len(targetPosts))

    for sp in sourcePosts:"TITLE: %s" % sp['title'])
        logging.debug("DATE:  %s" % time.strftime('%m/%d/%Y %H:%M:%S',
        postId = -1
        for tp in targetPosts:
            if sp['title'] == tp['title']:
                # Edit and existing post - might be better to check the date and decide which way to sync...
                postId = tp['postid']
                logging.debug("    Already exists. Overwriting")
        isPublished = (sp['post_status'] == "publish")
        if postId == -1:

Problems Suspending Machines with USB3 in Ubuntu

I've noticed that my new Asus U30FT was having problems suspending - it just got stuck on a blank screen. Long story short, it turns out because newer versions of Ubuntu come with ehci_hcd builtin kernel, and there's a couple of things you need to add to disable all devices that uses ehci_hcd, and unload the xhci module. #!/bin/sh # File: "/etc/pm/sleep.d/20_custom-ehci_hcd". case "${1}" in hibernate|suspend) echo -n "0000:00:1a.0" | tee /sys/bus/pci/drivers/ehci_hcd/unbind echo -n "0000:00:1d.0" | tee /sys/bus/pci/drivers/ehci_hcd/unbind ;; resume|thaw) echo -n "0000:00:1a.0" | tee /sys/bus/pci/drivers/ehci_hcd/bind echo -n "0000:00:1d.0" | tee /sys/bus/pci/drivers/ehci_hcd/bind ;; esac #File: "/etc/pm/config.d/usb3-suspend-workaround". SUSPEND_MODULES="xhci" Source: