Friday, December 3, 2010

Failback Exchange 2010 DAG with Powershell

Exchange 2010 DAG will do failover, that is switch to a backup server when the primary goes down.
But for whatever reason the genius at Microsoft decided not to enable failback, that is return to primary when it comes back.

However this is fairly easy to script up in PowerShell:

Add-PSSnapIn "Microsoft.Exchange.Management.PowerShell.E2010"
Move-ActiveMailboxDatabase -identity "database name" -ActivateOnServer "SERVERNAME" -Confirm:$false


Configure the task in Task Scheduler using New Basic Task. When you open the properties tab select Run whether the user is logged in or not and make sure to select Use highest privilege level.


For the trigger use Event ID 2157.

Monday, November 1, 2010

Sync iphone to multiple itunes libraries - works on 10.0.1

Its a bit of a pain that you can't sync an iphone to multiple itunes libraries - for me it's between home and office.
It turns out that it is pretty easy to get this to work.

CAUTION: Back up your iTunes media before you do this, as you may need to readd all your music and media after recreating the library file.

Each itunes library has a persistent ID in its Itunes Library.xml file:


<key>Library Persistent ID</key><string>C4C5884F4015XXXE</string>

You need to change this ID on every iTunes you want to sync to to be the same. Save the file.

You also need to change iTunes Library.itl. On OS X, this doesnt have any extension.

Open this with a hex editor and search for the current Library Persistent ID as hex. It should be right near the top. Replace it with the one from your primary machine, but also copy the bit before it:

68 64 66 6d 00 00 00 90 00 00 1c d5 00 16 00 03 06 31 30 2e 30 2e 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09 c4 c5 88 4f 40 15 64 de

Now start iTunes. It might complain that the library file is invalid and recreate it. When it does, immediately quit iTunes and check the file. If it's still the same Persistent ID, then the trick has worked and now you should be able to copy music and movies to the device.

Tested on my iPhone 2g running iOS 3.1.3, Mac running iTunes 10.0.1, Win7 running iTunes 10.0.1. Use at own risk.


Friday, September 3, 2010

Generate podcast feeds with Python

My friend Gozu helpfully posts his and some of the other boosh.fm DJs shows on his website.

I'd like to grab them from my phone with a podcaster. I was surprised to not immediately find a Python podcast generator when I googled, so I whipped up a little script using pyrss2gen.

Code is up here.

Sunday, August 29, 2010

coding at Auckmageddon

Thanks to Vector and Orcon, A5 has a 1gbps internet connection which really craps on all the other LANs that have ever happened in NZ. We tried to come up with ways we could max it out and someone suggested trailers.apple.com. I was asked to come up with a script to parse the feeds for a list of 1080p trailer URLs we could feed into wget. This is what I came up with:


from urllib2 import urlopen
from BeautifulSoup import BeautifulSoup
from json import loads


urllist = []
for t in loads(urlopen("http://trailers.apple.com/trailers/home/feeds/just_added.json").read()):
    urllist.append(t['trailers'][0]['url'])


for u in map(lambda x: "http://trailers.apple.com/" + x, urllist):
    try:
        h = urlopen(u+"includes/playlists/web.inc").read()
        soup = BeautifulSoup(h)
        avail = soup.findAll("li", {"class":"trailer last"})[0].findAll("li", {"class":"hd"})
        print avail[-1].findChild("a").attrs[0][1]
    except:
        pass

It turns out that not all the trailers have corresponding HTTP urls to the .mov files - some are handled through ITMS for unknown reasons.

Anyway, we still havent managed to crack much more than 200mbit, and Soundie seems a little dissapointed.

Tuesday, August 24, 2010

confused 0.2 released

I have finally released confused for Linux. This version is a PAM module. It's a complete ground up rewrite of the old amnesia based code, and it's pretty straight forward.

The only potential problems I can see are with the way it packs the post auth scripts; if you put a huge script in it potentially could overwrite or truncate other entries in the database.

Oh, while you're at it: check out pam_solitaire as well.

----- BEGIN BLOG -----

Thoughtcrime does not entail death. Thoughtcrime IS death. I have committed even before setting pen to paper the essential crime that contains all others unto itself.