Disable same-origin policy in Firefox

Just throwing up a quick post in the same vein as this gentleman who also lacked the Google-fu to quickly find it using the obvious search.

Comments

Building Wine on Mac OS X

There are probably a bazillion of these posts out there, but I wanted to play with DTrace and Wine in OS X (post on this to come) and had to get the thing built first. This is mainly a “here’s what I did” post, with some “and this is why” sprinkled in.

I grabbed the dependency I was missing (you might need others, like libjpeg and libpng3 that I already had around) and the latest source from git

sudo fink install fontforge git
git clone git://source.winehq.org/git/wine.git \
wine-git

Of course, it’s good practice not to muddy up your source tree, so build in a separate directory

mkdir bwine-git
cd bwine-git

Running just `configure` generates complaints about missing libxslt, libpng, and libjpeg. For libpng and libjpeg, I just needed to point to Fink’s libraries and headers under /sw. It took a little digging to figure out pkg-config had been installed by Fink, but since I wanted to use the system libxml and libxslt under /usr, I had to point pkg-config to the .pc files in /usr/lib/pkgconfig[1].

PKG_CONFIG_PATH=/usr/lib/pkgconfig \
CPPFLAGS=-I/sw/include \
LDFLAGS=-L/sw/lib ../wine-git/configure

I’m directed by configure to `make depend && make`; I purposely leave out a -j2 since 1) it’s a hot day and I don’t want to kill my poor MacBook Pro, and 2) I don’t remember if it works correctly

make depend && make

And finally, test it works

./wine notepad.exe

Unfortunately, I get the message that “Wine cannot find the FreeType font library. To enable Wine to use TrueType fonts please install a version of FreeType greater than or equal to 2.0.5.” Let’s point dyld to our X11 libs (where FreeType lives), and try again

DYLD_FALLBACK_LIBRARY_PATH=/usr/X11/lib \
./wine notepad.exe

Success!

[1] It seems that Wine’s autoconf script takes the value returned from pkg-config, if pkg-config exists, without trying the alternative (values from xslt-config and xml2-config, in this case), even if pkg-config returns an empty string. I might get around to submitting a patch.

Comments

Upgrading a RAID-1 array…in only a week

750GB hard disks have been at the $/GB sweet spot for a while now, and now that they’ve hit $100, I decided to upgrade my home directory RAID-1 from 250GB to 750GB. I really dread these upgrades, as there’s always a chance you can really screw things up. So, for when I upgrade to 2TB or whatever in two years, I wrote up some notes.

In my configuration, sdb1 and sdc1 are the partitions currently part of my RAID-1 md0. sdd is one of the 750GB disks. I’m adding one 750GB disk at a time, because 1) I want at least two copies of my data to be available at all times and 2) I only have one free drive bay and don’t want disks dangling next to the machine for hours.

  1. Change the number of active devices in the array from two to three. This will cause any newly added drive to become active (i.e. actually write the array’s data onto the new drive)

    mdadm -G /dev/md0 -n 3

  2. A little burn-in testing for the new disk

    badblocks -svw -t random -p 2 /dev/sdd

  3. Partition, not forgetting to set the partition type to 0xfd, Linux raid autodetect
  4. Add the new drive as a spare to the existing array

    mdadm /dev/md0 --add /dev/sdd1

  5. Once recovery is done (check `mdadm -D /dev/md0`), fail and remove one of the old disks from the array

    mdadm /dev/md0 -f /dev/sdc1 -r /dev/sdc1

  6. Shred the removed drive

    shred -v -n 2 -z /dev/sdc

  7. (Physically) swap out the removed drive and replace it with the second new one
  8. Repeat steps 2-5 above for the second new disk. Hold off on the shredding, as this is going to be our backup
  9. Reset the number of active devices in the array to two

    mdadm -G /dev/md0 -n 2

  10. Grow the array

    sudo mdadm -G /dev/md0 --size=max

  11. Let it resync, then unmount and resize the filesystem

    umount /home
    resize_reiserfs /dev/md0
    mount /home

  12. Finally, if everything seems okay, shred that second old disk

    shred -v -n 2 -z /dev/sdb

…and we’re done! The one annoying thing is that with testing and a couple of resyncs, you end up with loads of down time between really short and simple tasks. So it’s possible (and I speak from experience) to stretch this weekend project out over a whole week.

Comments

OpenID-enabled two-factor authentication on the cheap

I ran across this nine-month old post at cavemonkey50.com and I’m kind of left wondering where I was when this idea made its round on the blogs. Basically, PayPal will sell you a SecurID-like fob that can be OpenID-enabled using VeriSign as the OpenID provider (eh, VeriSign…sketchy? maybe.) The two key observations:

While PayPal is providing the Security Key, the key is actually a VeriSign Identity Protection (VIP) device … VeriSign is actually an OpenID provider and allows you to link your Security Key to your OpenID.

So give PayPal $5, get one of these SecurID-like devices in the mail 10 days later, link it to VeriSign’s OpenID provider, and boom you get two-factor OpenID authentication. Assuming your email, blog, photo sharing site, etc are hooked into OpenID, you have a little less to worry about when you’re on the road using some random internet cafe terminal.

Comments

Learning Mandarin Chinese with Mac OS X

I use a Mac probably 90% of the time, so I wanted to share some tips for OS X I picked up that (I hope) are really helpful to the Mandarin Chinese learner.

As a bit of background, let me tell you where I’m coming from: I went to Chinese school for years as a kid and didn’t really learn much of anything. I was never fluent, never really learned enough characters to sufficiently read (let alone write), and then I just stopped caring for some amount of time. Now, I’m back for more learning.

So, here are the tips:

  • ITABC Input Method

    I haven’t really used Windows in years, but last time I tried, I don’t think it had the pervasive Unicode support to even display Chinese characters in most apps. That said, I was nicely surprised when I found OS X 10.5 comes with a slew of Traditional and Simplified Chinese Input Methods built in. The one I use, ITABC, is dead simple. You just enter pinyin without tones and choose from candidate matches. There are plenty of places online (here’s one at Yale) that can walk you through setting it up.

  • CEDICT for Apple Dictionary

    Apple includes a dictionary application in OS X. No big deal, right? Well, it’s actually pretty cool, because you can add your own custom dictionaries that integrate as seamlessly as the built-in dictionaries. CEDICT is a Chinese-English dictionary project (here’s an online dictionary based on CEDICT) that’s available as a user dictionary for Dictionary.app. Even better, it also has pronunciations (little sound bites you can play) embedded in dictionary entries.

    Here’s CEDICT for Apple Dictionary at Apple Downloads. Just download it and drop it into your /Library/Dictionaries (or ~/Library/Dictionaries).

  • Dictionary.app integration throughout OS X

    I mentioned seamless integration in that last bullet point. Well, in the Apple way, the dictionary is integrated throughout the system. Hover over some text, hit a hotkey (defaults to Cmd-Ctrl-D, but might I suggest F1), and a little panel pop up (inline, in your application) with the definition.

    This hint at Mac OS X Hints reminds us that we can hold down the dictionary hotkey to continuously get the definition of whatever word is currently under the cursor. Say you’re scanning news.google.cn and there are a handful of words you don’t know. Just hit that hotkey, the dictionary entry panel pops up in Safari, and it moves with you as you move the cursor across the sentence.

  • If the default popup panel is too small for your tastes, this post has a link to a modified DictionaryPanel.app (drop it in /Applications/Dictionary.app/Contents/SharedSupport) that enlarges the popup panel window. Alternatively, you can open up DictionaryPanel.app/Contents/Resources/English.lproj/PopupWindow.nib in Interface Builder and just need to change the size of both the popup window and its content. Be sure to make a backup first!

  • ChinesePod on iTunes

    Alright, so this last one might be a strech, but I found out about ChinesePod, which is a podcast with lessons in spoken Mandarin. It helps that the podcasters are pretty amusing. How does this tie in? Well, iTunes is setup to scrape the newest lessons and syncs them automatically with my iPod, so I can listen on my way to work. Zero effort necessary!

Alright. That’s it for now. If you know of any other tips, please do share!

Note: This might seem like one big rave for OS X, but I tried really hard to keep that to a minimum. Apple’s just too cool :)

Comments (1)

Subway

I’ve been eating at Subway pretty often recently. They have a sub-of-the-day deal, $2.99 for a 6-inch, and also have any footlong sub for $5. Incredible, I know. It’s pretty much the cheapest meal option, cheaper than anything I could cook or microwave that has any semblance to real food.

Today, I had a footlong club for lunch (where, oddly enough, I ran into my roommate). Fast forward a couple hours to dinner time, and my roommate tells me he’s going back to Subway and convinces me to go back again too. Two feet of club sandwiches in one day.

Anyway, what I wanted to share is this: I always walk to Subway, and this map shows how far Subway is from my apartment. It’s less than two blocks, probably two minutes to walk. But my roommate offered to drive there. And we drove there. We drove two blocks to go to Subway.

Just wanted to share.

Comments

Stressing disks in OS X for burn-in

Sounds simple, you’d think doing drive burn-in for reliability is something people do everyday on Macs, but either my Google-foo is off or there’s just not an easy way to stress test disks. A drive just died from under two weeks use (note to self: don’t buy Iomega), so I’m forcing myself to put the replacement I received this morning through its paces before committing any data to it.

This external drive, for reasons of compatibility and account restrictions, needs to eventually be formatted on my Mac to ext2, using ext2fsx (another post on the bugginess of ext2fsx later). Below is a list of ways I ran across to stress the disk.

Ideas for stressing a disk on OS X:

  1. format the disk with “secure erase” to write dummy data to the entire disk
  2. just format the disk ext2/fsck it; the inode placement should give good coverage of the disk without taking SO LONG*
  3. run `e2fsck` (fsck_ext2) with the -c -c option which invokes badblocks to read/write each block to find and track bad blocks.

I started with the first, but realized badblocks is probably a better tool for the job (is there a native BSD equivalent?) save for the fact that you don’t get much seeking going on. The second one might address that, or maybe reading the disk’s block device while doing something else might induce the contention to give you the necessary seeking.

*A side gripe: since disk capacities (I have a 500GB external drive) have been growing faster than disk bandwidth (perhaps my fault for using 480Mbps USB2), reading or writing an entire drive takes on the order of HOURS (over two hours twenty minutes best case for my setup, and easily twice that from my experience today). It just never really affected me until now, and I’m kind of annoyed.

Comments

American Express could be awesomer (was: American Express is awesome)

I started this entry before leaving on a two week trip to China, as a reminder to rave about American Express. I thought I should at least post it, even without the happy ending I was expecting.

The day before leaving for China, I browsed some travel websites and found out that an American Express card will get you personal check cashing services at some Bank of China branches. Of course, the internet didn’t yield much information, so I gave American Express’s Global Assist line a call. I was floored that the lady offered to call their China offices and the Bank of China to determine if my cards would work for cashing personal checks.

So, wow. The intent was great. All this nice service. I think I called on a Saturday, expected a call back Sunday night (Monday morning in China). Unfortunately, that call never came and I left on my trip.

Comments

FreeBSD 7.0 worth it just for ZFS?

I’m a diehard OS X user, but keep around a desktop for nightly jobs and file storage. I’m rather unlucky with disk drives (killed one just yesterday), so I’ve been meaning to move to ZFS. FUSE on Linux doesn’t feel too trustworthy right now (right, I’ll trust drivers not in the mainline kernel), and having finally gotten used to BSDisms, I’m not sure starting fresh with Solaris is the right path.

Long story short, I decided to try FreeBSD 7.0 (ZFS built in!). The last time I used FreeBSD was to shape traffic in a network testbed. This time, I’m looking for dead-simple usability. I want my WinPrinter to work plug and play, X to start outta the box in high res, and all that jazz.

First step, downloading the cd images and making a dvd image from that.

More later…

Comments

Computer Scientists: “FREE ACM Flip-Top Calculator” with membership

See: https://www.acm.org/studentoffer4

Seriously, they’ve got to be kidding. Maybe ACM isn’t familiar with their target audience, but a four-function flip-top calculator (granted it looks like it also has clock and calendar functions in its awkward display) is just not the way to incentivize students to join.

Please, stop with this branded junk.

Comments