iPhone Calendar Sync

The Google Instructions for selecting which Calendars will sync to your iPhone are really really terrible.

These setup instructions tell you to visit http://m.google.com/sync/ on your iPhone to select your calendars. But when you visit that address on your iPhone, it tells you to visit http://m.google.com/sync/ on your computer--which, hilariously, takes you back to the original instructions.

Google is totally punk'd-ing us.

If you would like to *actually* select which calendars you would like to sync visit this address on either your phone or computer.

https://www.google.com/calendar/b/0/iphoneselect

Active Directory Usefulness

Decoding the UserAccountControl attribute in ActiveDirectory...

#!/usr/bin/python

import sys

MAP = [
("SCRIPT","0x0001","1"),
("ACCOUNTDISABLE","0x0002","2"),
("HOMEDIR_REQUIRED","0x0008","8"),
("LOCKOUT","0x0010","16"),
("PASSWD_NOTREQD","0x0020","32"),
("PASSWD_CANT_CHANGE","0x0040","64"),
("ENCRYPTED_TEXT_PWD_ALLOWED","0x0080","128"),
("TEMP_DUPLICATE_ACCOUNT","0x0100","256"),
("NORMAL_ACCOUNT","0x0200","512"),
("INTERDOMAIN_TRUST_ACCOUNT","0x0800","2048"),
("WORKSTATION_TRUST_ACCOUNT","0x1000","4096"),
("SERVER_TRUST_ACCOUNT","0x2000","8192"),
("DONT_EXPIRE_PASSWORD","0x10000","65536"),
("MNS_LOGON_ACCOUNT","0x20000","131072"),
("SMARTCARD_REQUIRED","0x40000","262144"),
("TRUSTED_FOR_DELEGATION","0x80000","524288"),
("NOT_DELEGATED","0x100000","1048576"),
("USE_DES_KEY_ONLY","0x200000","2097152"),
("DONT_REQ_PREAUTH","0x400000","4194304"),
("PASSWORD_EXPIRED","0x800000","8388608"),
("TRUSTED_TO_AUTH_FOR_DELEGATION","0x1000000","16777216"),
]

def main(args=None):
orig_num = int(args[1])
calc_num = orig_num
mapping = [(m[0],m[1],int(m[2])) for m in MAP]
mapping.reverse()
flags = []

for name,hex,dec in mapping:
last_name,last_hex,last_dec = name,hex,dec
if dec == mapping[0][2]:
continue
if calc_num >= dec:
calc_num -= dec
flags.append(name)
print ' '.join(flags)


if __name__ == '__main__':
main(sys.argv)


Decoding Active Directory ridiculous time format....

#!/usr/bin/python
import time
import datetime
import sys

def ad2unix(adtime):
secs = int(str(adtime)[:-7])
#secs = int(adtime) / (1000*1000*10)
base = datetime.date(1601,1,1)
return base + datetime.timedelta(0,secs)

def main(args):
return ad2unix(args[1]).ctime()

if __name__ == '__main__':
print main(sys.argv)

Javascript For Each Loop Not Supported in Safari

I got kind of excited because recently I found out there was a 'for each' loop construct in Javascript.

In the 'old' loop construct to output the items in an array you have to write:

foo = ['hello','bill','kangaroo'];
for (the_item in foo) {
alert(foo[the_item]);
}

The new construct is cleaner and looks a lot like Python:

foo = ['hello','bill','kangaroo'];
for each (the_item in foo) {
alert(the_item);
}

That's all well and good except that apparently this isn't supported in all browsers. Everything was working fine in Firefox 3.0 (Mac OS X) but when you use this code in Safari 4.0 (Mac OS X) there a Syntax error! Safari has literally no support for this functionality.

I have yet to test in other browsers.

Maybe this is a Firefox 'feature' or maybe Safari is just missing a big junk of Javascript... but I have no plans to go digging through some RFC to see who's in the wrong.

"Fixed" IP Address for VMWare Fusion

If you need to explicitly set what IP address you want your VMWare Fusion guest OS to get when it requests a DHCP lease from the VMWare "virtual router" (a.k.a., vmnet8) then you need to edit your /Library/Application Support/VMware Fusion/vmnet8/dhcpd.conf file to force a "fixed address".

#
# Configuration file for ISC 2.0b6pl1 vmnet-dhcpd operating on vmnet8.
#
# This file was automatically generated by the VMware configuration program.
# .... blah blah ...
#
allow unknown-clients;
default-lease-time 1800; # 30 minutes
max-lease-time 7200; # 2 hours

subnet 192.168.197.0 netmask 255.255.255.0 {
range 192.168.197.128 192.168.197.254;
option broadcast-address 192.168.197.255;
option domain-name-servers 192.168.197.2;
option netbios-name-servers 192.168.197.2;
option domain-name "localdomain";
option routers 192.168.197.2;
}

host dev25 {
hardware ethernet 00:0c:29:eb:06:9f; # Your Guest OS MAC address
fixed-address 192.168.197.144;
}

Note that a "fixed address" is not the same as a "static IP". As far as your Guest OS is concerned it is still getting a "dynamic" address from DHCP--it will just always get the same one.

If you don't want to boot up your VM to see your hardware address then check out [VM_NAME].vmwarevm/[VM_NAME].vmx.

And look for the line that looks like:
ethernet0.generatedAddress = "00:0c:29:eb:06:9f"

Compound Interests Makes You Sober

Figure out how much money you are really wasting when you buy that round of shots.

Use the Inflation Calculator (the one on the very bottom).

It will tell you, for example, that the $10 you spent on booze last night, if instead, you had set it free into the financial wilds to work for you, say at 8% annual interest, and left it until you retired in 50 years it would be worth $469. Of course in 50 years $469 is only going to be worth about $107 (assuming inflation holds steady at 3%). In any case wouldn't you rather buy 7 cases of future-beer in 2058 then two shots at some crappy bar?

Sort by Directory/File Size

List the contents of this directory, sorted by filesize, with a 'human readable' size prefix:

du -sL * | sort -n | cut -f2 -d"$(echo -e "\t")" | xargs du -hLs

example output:
16K system.log.1.bz2
16K system.log.7.bz2
20K install.log.2.bz2
20K system.log.3.bz2
20K system.log.6.bz2
20K weekly.out
24K system.log.0.bz2
28K system.log.5.bz2
44K windowserver.log
60K secure.log
68K fsck_hfs.log
100K windowserver_last.log
208K apache2
376K system.log
528K daily.out
668K install.log.0
732K asl.db
864K asl
du: samba/cores: Permission denied
2.0M samba
2.6M cups

Is a Process Listening to a Port?

If you are trying to tell if a process is listening on a port try these commands...

lsof -i -P | grep -i

-i tells lsof (which looks at all open files) to only look for TCP/UDP connections.
-P turns off the mapping of port numbers to port names.

netstat -anp

Dumps a crap-ton of networking data to terminal

Reference this as well: http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/security-guide/s1-serve...

Mount NTFS

Use MacFuse and NTFS-3G to mount an NTFS partition.
  • Download the latest version of MacFUSE at http://code.google.com/p/macfuse/downloads/list/
  • Download the latest version of NTFS-3G at http://macntfs-3g.blogspot.com/
  • Install MacFUSE and NTFS-3G from the .dmg files (you need Adminitrative access). You will need to restart because these installs are futzing around with your kernel.
  • Your NTFS partition should be auto-mount after restart. If not you may have to do something like...
mkdir /Volumes/WinPart/ && sudo mount -t ext2 /dev/disk1s1 / Volumes/WinPart/