Wednesday, December 16, 2009

Hamming(7, 4)

It's a pain to find any easy-to-understand explanations on how to do Hamming(7, 4), so here's the most useful information from my reference on how to do it.

NOTE: You can substitute addition (+) with XOR (^).


Let's say you have four data bits: d1, d2, d3, d4. To create the parity bits, you use the following formulae:

  1. p1 = d2 + d3 + d4
  2. p2 = d1 + d3 + d4
  3. p3 = d1 + d2 + d4

The bits sent across the wire are: d1, d2, d3, p1, d4, p2, p3


Now that we have the bits sent across the wire (d1, d2, d3, p1, d4, p2, p3), we can detect appropriate errors.

Error Detection

First, we calculate:

  1. p1* = d2 + d3 + d4
  2. p2* = d1 + d3 + d4
  3. p3* = d1 + d2 + d4

If any of these parity bits don't match the parity bits sent over the wire, then there was an error.

Error Correction

Now this information was the most difficult to find.

With the bits sent across the wire (d1, d2, d3, p1, d4, p2, p3), we must first calculate:

  1. c1 = d1 + d3 + d4 + p3
  2. c2 = d1 + d2 + d4 + p2
  3. c3 = d1 + d2 + d3 + p1

NOTE: You can detect errors by checking to see if any of c1, c2, or c3 are true (nonzero).

With these calculated, now we can find which bit we need to flip to correct the error:

  1. bit = ((c3 ? 4 : 0) | (c2 ? 2 : 0) | (c1 ? 1 : 0)) - 1
  1. If bit = 6, then flip d1.
  2. If bit = 5, then flip d2.
  3. If bit = 4, then flip d3.
  4. If bit = 2, then flip d4.
  5. In all other cases, there are more than one bit errors and we can't correct them.

Alternatively, it could be thought of this way: bit is the index of the flipped bit from the end of the string (where p3 is) with zero-indexing.

Wednesday, November 25, 2009

Restoration of the Old Kingdom

It starts off with a boy escaping punishment from his mother via a secret passage to a cavern...

Years later, when the boy is a young man, his mother is making them move for away. As he packs up his belongings, he is distracted by a rabbit bounding off towards the village. Once there, he is confronted by a group looking to go on an short adventure, led by a wiseman . Hoping to make his last day in his hometown a good one, he accompanies them.

They make their way to a market house at the end of a valley, where the young man had been employed previously, but they must make their way past the valley, and the wiseman discovers that it's blocked off only by a wall of the market. Unfortunately for the market owner, one of them barrels through rows of stock, then breaks through the wall. Not wanting to be stopped, they ran through.

The group happens upon a cave, and enter it as directed by the wiseman. The journey here becomes quite dangerous, with the final section requiring them to walk across the top of stalagmites that project upward out of a searing-hot spring.

Once in the final room of the cave, they discover a door at the top, much to their surprise. The young man stands, almost in a trance, at the entrance to the final room as memories from his late father fill his mind. He begins to manipulate hidden switches throughout the room, causing fire to rise from all sides, finally resulting in a major quake.

Outside, light begins to fill the area around the hill containing the cave, and the quake causes much of it to collapse. After the dust clears, a castle is revealed, and the song familiar to everyone who remembers the old kingdom that resided in the area is played from the bell towers. They exclaim, "The king has returned!" and run to the castle to greet him, only to come upon the young man. After an awkward pause, someone familiar to the old king says, "You look just like him... You must be his son!" The people rejoice, as the old kingdom can now be restored.

Once sat upon the throne, the young man realizes that this cavern of his youth was the throne room of the old castle. He also found out his father's death led to the collapse of the old kingdom, and his that mother wanted to keep him isolated from anything involving it.

Tuesday, November 10, 2009

Wikipedia Graph Generator

I've been working on this project for the past month or so, but since it pretty much works I've lost interest. For those interested, this sort of graph is an example of generated output, and shows pages as vertices and inter-page links as directed edges. The scripts can be found here:

Since the data set is quite large (the PostgreSQL database dump compressed is over 550 MB), it'd be much easier for anyone who wants to check this out to generate the data. The process is as follows:


If the above image doesn't load, open the image location in a separate window or tab.

  1. Run psql -U postgres wikidown2 < schema_create2
  2. Download this file from Wikipedia: enwiki-latest-pages-articles.xml.bz2 (5.3 GB)
  3. Run enwiki-latest-pages-articles.xml.bz2 pages.lst links.lst I originally used CSV here, but switched to an ASCII group separator later. The '.csv' suffixes are vestigial.
  4. Run links.lst links-sorted.lst.
  5. Run pages.lst pages-presorted.lst.
  6. Run sort -k1nru pages-presorted.lst pages-sorted.lst.
  7. Unfortunately, due to the behavior of Python's hash algorithm and Postgres's tree algorithm, there will be a duplicate title. The only real solution is to keep trying the following steps and edit pages.lst accordingly. Remember than whenever you delete a row in pages.lst, you must also delete links in links.lst that point to it.
  8. Run bzip2 links.lst and bzip2 pages.lst.
  9. Run pages.lst.bz2 links.lst.bz2. This step is considerably faster if both files are mounted in tmpfs (RAM), but only if your machine has enough RAM. tmpfs is not available on Windows.

Once you've run those steps, you can run

Saturday, November 7, 2009

Addendum: "Leaf Hat Linux" Stickers

In response to my previous post, it appears that I'll have to have 1000 printed and they'll be 4" wide by 2" tall. I'll raise the price to $0.40 per sticker, but will only charge $3.00 per ten stickers or $20.00 per hundred stickers.

Sorry for the inconvenience; it was news to me too. The quality won't suffer, though, since it's all still not rastorized.

"Leaf Hat Linux" Stickers

I'm having 500 "Leaf Hat Linux" stickers printed. These are high-quality stickers, with no rasterization done at any point, and will be 3.5" wide by 1.25" tall.

If anyone wants one or more, contact me. I'll probably set the price at $0.35 per sticker.

Friday, October 23, 2009


I thought it was about time that I make a few convenient changes to the old sizeof utility. The primary change here is adding support of printing either bytes (as bsizeof, which is useful for piping to sort -k1nr) or size in larger units as appropriate (as sizeof).


#include <sys/types.h>
#include <dirent.h>
#include <stdio.h>
#include <string.h>
#include <libgen.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <limits.h>

off_t getsize(const char * path) {
off_t ret = 0;
struct stat info;
struct dirent * file;
DIR * dirinfo;
char d_name[PATH_MAX];
size_t pathlen = strlen(path);
char * app = d_name + pathlen + 1;
if(pathlen < PATH_MAX) {
strcpy(d_name, path);
strcat(d_name, "/");
if(!stat(path, &info)) {
ret = info.st_size;
else if(S_ISDIR(info.st_mode)) {
dirinfo = opendir(path);
while((file = readdir(dirinfo)) != NULL) {
if(strcmp(".", file->d_name) && strcmp("..", file->d_name) && pathlen + file->d_reclen + 1 < PATH_MAX) {
strcpy(app, file->d_name);
ret += getsize(d_name);
return ret;
int compute_size_string(char * str, off_t size) {
if(size > (1 << 30))
sprintf(str, "%.2lf GiB", ((double) size) / ((double)(1 << 30)));
else if(size > (1 << 20))
sprintf(str, "%.2lf MiB", ((double) size) / ((double)(1 << 20)));
else if(size > (1 << 10))
sprintf(str, "%.2lf kiB", ((double) size) / ((double)(1 << 10)));
sprintf(str, "%lu B", size);
return 0;
void print_size_computed(off_t size, const char * name) {
char size_string[1024];
compute_size_string(size_string, size);
printf("%-10s %s\n", size_string, name);
void print_size(off_t size, const char * name) {
printf("%-40lu %s\n", size, name);

int main(int argc, char ** argv) {
int i;
off_t size;
char * bname = basename(argv[0]);
void (* handler)(off_t, const char *) = strcmp(bname, "bsizeof") ? &print_size_computed : &print_size;
for(i = 1; i < argc; i++) {
size = getsize(argv[i]);
handler(size, argv[i]);
return 0;

Sunday, October 18, 2009

Dream: Mountain Spring and Waterfall

I know for a fact that I've had this dream before, which is why it's interesting. The overarching plot starts off with me wanting to run away from home, and through the course I visit multiple different locations. I'll only describe the snapshots that I can recall.

  1. I start by walking down my homestreet, which isn't so abnormal. I make a left at the tee.
  2. A thought runs through my mind, "If I keep going this way, through the mountains, I'll end up in Everett." I even see the mountains in the distance. Strangely, there aren't any actual mountains between where I live and Everett in real life.
  3. I end up passing through a rural area reminiscent of the rural Cascade foothills, with light forest and a lot of grass on the slopes.
  4. Eventually, I arrive at a massive spring, where the water is clear and the bed is made of white rock. There are executives of some sort ("suits") in the water, and I mention to one that I've been in the pool before. He only utters a bit of poetry in response.
  5. My next stop is where the road I'm walking along makes a light right turn, with the stream originating from the spring separating it from the base of a cliff. A high road runs across the top of the cliff.
  6. I exit the forest, only to come to a series of waterfalls in a somewhat more barren landscape. I had been off the road for some time, instead opting for a paved path originating from it. The path splits, with one end capped with a balcony and the other direction crossing a bridge similar to this one, only using steel tubing instead of wood. The bridge crosses a very tall, yet moderately wide waterfall, which levels off for a hundred meters, then cascades down a much wider set of horseshoe falls. I take out my camera and snap photos of the scenery, but when I get to the bridge I hesitate, remembering my last experience. The bridge begins to violently sway in a manner similar to that of a boat as I try to cross it, forcing me to return to the path.
  7. I climb various other paths to take photos of odd sculptures that adorn the ridge visible from the balcony, where other tourists do the same.

It's an interesting dream, but I only recall having had it once before.

Friday, October 16, 2009

ロマンスの神様 - 広瀬香美

This song is so happy and warm that I feel like my head's going to explode with rainbows. It sounds silly, but you'd have to listen to it to see what I mean.

勇気と愛が世界を救う 絶対いつか出会えるはずなの
沈む夕日に淋しく一人 こぶし握りしめる私
週休二日 しかもフレックス 相手はどこにでもいるんだから
今夜飲み会 期待している 友達の友達に

目立つにはどうしたらいいの 一番の悩み
性格良ければいい そんなの嘘だと思いませんか?

Boy Meets Girl 幸せの予感 きっと誰かを感じてる
Fall In Love ロマンスの神様 この人でしょうか

ノリと恥じらい必要なのよ 初対面の男の人って
年齢 住所 趣味に職業 さりげなくチェックしなくちゃ
待っていました 合格ライン 早くサングラス取って見せてよ
笑顔が素敵 真顔も素敵 思わず見とれてしまうの

幸せになれるものならば 友情より愛情
「帰りは送らせて」と さっそくOK ちょっと信じられない

Boy Meets Girl 恋してる瞬間 きっとあなたを 感じてる
Fall In Love ロマンスの神様 願いをかなえて
Boy Meets Girl 恋する気持ち 何より素敵な宝物
Fall In Love ロマンスの神様 どうもありがとう

よくあたる星占いに そう言えば書いてあった
今日 会う人と結ばれる 今週も 来週も さ来週もずっと oh yeah!

Boy Meets Girl 土曜日 遊園地 一年たったらハネムーン
Fall In Love ロマンスの神様 感謝しています
Boy Meets Girl いつまでも ずっとこの気持ちを忘れたくない
Fall In Loveロ マンスの神様 どうもありがとう

Thursday, October 15, 2009

Working with images a lot, thanks to my webcomic, becomes a lot easier when certain things are automated. For example, this script takes care of flattening an image (by removing alpha information), and even passes the output through pngcrush when applicable. It also includes a default output convention:

from sys import argv, stderr, exit
from subprocess import Popen
from optparse import OptionParser, OptionValueError
from os import remove
from os import close as os_close
from re import compile as re_compile
from os.path import join, isfile
from tempfile import mkstemp

size = re_compile('^(.+)x(.+)$')

def check_size(option, opt_str, value, parser):
m =
if m:
parser.values.size =,
raise OptionValueError('Invalid size: %s' % value)

filext = re_compile('^(.+)\.(.+)$')
filext_png = re_compile('\.png$')

img_type = ['Bilevel', 'Grayscale', 'GrayscaleMatte', 'Palette', 'PaletteMatte', 'TrueColor', 'TrueColorMatte', 'ColorSeparate', 'ColorSeparationMatte', 'Optimize']
img_cspace = ['CMY', 'CMYK', 'Gray', 'HSB', 'HSL', 'HWB', 'Lab', 'Log', 'OHTA', 'Rec601Luma', 'Rec601YCbCr', 'Rec709Luma', 'Rec709YCbCr', 'RGB', 'sRGB', 'Transparent', 'XYZ', 'YCbCr', 'YCC', 'YIQ', 'YPbPr', 'YUV']

parser = OptionParser(usage = 'Usage: %prog [ options ] input [ output ]')
parser.add_option('-s', '--size', dest = 'size', type = 'string', action = 'callback', callback = check_size, default = None, help = 'The output size: WIDTHxHEIGHT')
parser.add_option('-n', '--no-clobber', dest = 'clobber', default = True, action = 'store_false', help = 'The output size: WIDTHxHEIGHT')
parser.add_option('-f', '--filter', dest = 'filter', default = 'Catrom', help = 'The filter to resize with if necessary.')
parser.add_option('-b', '--background', dest = 'background', default = 'white', help = 'The background when flattening.')
parser.add_option('-F', '--no-flatten', dest = 'flatten', default = True, action = 'store_false', help = 'Don\'t flatten the output.')
parser.add_option('-t', '--type', dest = 'type', type = 'string', default = None, help = 'The type of the output image: analogous to both -type and -colorspace in ImageMagick')
parser.add_option('-d', '--depth', dest = 'depth', type = 'int', default = None, help = 'The depth of the output image.')

options, args = parser.parse_args()
if len(args):
input = args.pop(0)
if isfile(input):
output = None
pngout = False
if len(args):
output = args.pop(0)
pngout = True
m =
if not m is None:
output = '%s_small.%s' % (,
if == 'png':
pngout = True
output = '%s_small.png' % input
pngout = True
if not options.clobber and isfile(output):
print >>stderr, 'Output file exists:', output
args = ['convert', input]

if options.flatten:
args += ['-background', options.background, '-flatten', '+matte']
if not options.size is None:
args += ['-filter', options.filter, '-resize', '%sx%s' % options.size]

if not options.type is None:
if options.type in img_type:
args += ['-type', options.type]
if not options.depth is None:
args += ['-depth', str(options.depth)]
elif options.type in img_cspace:
args += ['-colorspace', options.type]
if not options.depth is None:
args += ['-depth', str(options.depth)]

if pngout:
fd, tmpfile = mkstemp()
args.append('png:' + tmpfile)
Popen(('pngcrush', '-rem', 'sRGB', tmpfile, output)).communicate()
print >>stderr, 'No such file:', input
% python
Usage: [ options ] input [ output ]

-h, --help show this help message and exit
-s SIZE, --size=SIZE The output size: WIDTHxHEIGHT
-n, --no-clobber The output size: WIDTHxHEIGHT
-f FILTER, --filter=FILTER
The filter to resize with if necessary.
The background when flattening.
-F, --no-flatten Don't flatten the output.
-t TYPE, --type=TYPE The type of the output image: analogous to both -type
and -colorspace in ImageMagick
-d DEPTH, --depth=DEPTH
The depth of the output image.

Thursday, September 24, 2009

Whidbey Grand Tour #4

This trip was pretty much the same as last time, except for a few differences:

  • Some weird guy formerly employed as a flagger (for construction) tried to talk to me about some things I wouldn't normally talk about, but they were within social norms.
  • Instead of the Island Transit 412 and Island Transit 411C, I rode Skagit Transit 90X between Everett and Mt. Vernon. This route, unlike the two Island Transit routes, is not free.
  • I explored downtown Mt. Vernon a bit, and found a fancy co-op market. Organic root beer is less syrupy than, for example, Barq's.

Sunday, August 30, 2009

Memorial of Fiona


Fiona, my best friend, passed away yesterday, after fighting a liver ailment that left her very weak. She and I had only been together two short years, even though it felt like we had known each other forever.

We first knew she wasn't feeling well when she stopped eating about a week or so before it happened. With a vet visit, she was rehydrated and given an IV cast to help keep her from dehydrating. She still didn't eat, but seemed happy enough: on the Wednesday night before she was put down, she came and visited me for attention, rolling around as she did before any of this started happening, purring and kneading. However, her condition deteriorated very quickly the next night: she started hiding, which was out of character for her. According to my mother, she even tried to escape when taken outside, to go hide somewhere and die. Even so, she remained alive until the fateful day, hiding in the bonus room beside mine quietly. While she wasn't very animated, she still meowed to me when I talked to her.

On the last day, she was still hiding in the bonus room when we pulled her out. She struggled to get away when she saw the cat carrier, but not with as much force as she had in the past. She didn't even cry much in there, despite how much she hated what would normally come next. At the vet's office, we pulled her out and I held her one last time, crying like I never had before; she clung to my shoulder, hoping I'd protect her. Even my mother started crying at that point. The vet was able to clear an injection area, and I said some of my last words to her as she injected the anesthesia, in both her hind and fore legs. I'll never forget the look on Fiona's face as she lies there lifeless, and I'll never forget the memories we shared together.

She had many behaviors I won't forget, but it's still a good idea to list them:

  • When I came home after work or school, she would come up to me and nestle into my lap for attention, where I pet her and she kneaded and purred with a big smile. She even tolerated being partially covered by the drawing board I used, as long as she still got attention.
  • In general, she loved getting attention, and would roll around on the floor at my feet for a good foot petting.
  • She loved her toy, which was similar to a fishing rod, but had a small collection of feathers on the end of the line. I wish I would've spent more time playing with her, though.
  • She managed to play with herself, batting mice around and chasing after them.
  • Catnip didn't always have an effect on her, but when it did she acted very wild.
  • In the morning, she joined the other two cats for wet cat food down in the kitchen. It was fun watching them as my mother fed them, and funny when she dropped food on Fiona's head because she stood on the wax paper. Fiona would sometimes lick the can clean.
  • At night, she would come into my room just after I closed the door, then either run up to the bed or the window sill. She'd always eventually make it to the bed, but was often distracted by the pull cords on my blinds. She even broke one of them off eventually. Once on my bed, she'd walk atop me, then lay down on her stomach to get more attention. She often would later go eat, then either leave the room or come back and lay upon or beside me for even more attention.
  • She really didn't like the fan or the air conditioner.
  • When I had the television on, she sometimes watched it with me.
  • Her pupils were almost always fairly small, sometimes three or four millimeters the narrow dimension.
  • Sometimes she would sit on my shoulder or back, or on the back of the chair, when on my old chair or couch.
  • In my old chair, she would nestle into my lap when I had my legs spread. Sometimes, she would also sit beside me. She didn't much like my replacement chair.
  • Her meows were always high-pitched, with a very slight upward inflection at the end. When confused, bewildered, or scared, they became quieter and ended with a question-like inflection. When happy, they sounded very dry. She would rarely howl unless alone somewhere at night.
  • She rarely hid, choosing to be in plain sight much of the time downstairs. We knew there was a problem when she did hide.
  • She ate a lot.
  • She and Sylvie would try to play together every now and then, but their wild times weren't synchronized well; someone almost always ended up offended.
  • She, Sylvie, and Meg would often randomly attack each other, supposedly to only uphold the social hierarchy.
  • She always loved a good belly rub.
  • When not given attention, she would often take the "rabbit stance" and sit nearby.
  • She had the cutest smile, and would almost always knead for a few minutes after laying down while pet.
  • Fiona had really bad breath.
  • Fiona's previous owners thought she was too demanding for attention.
  • Fiona really liked eel and rice, and for a while liked green beans and corn.

There may be more of these coming in the future, but I really don't want to continue this particular entry.

Friday, August 28, 2009

わかれうた - 中島みゆき

With the soon-to-be-passing of my cat, this song came to mind. It really does fit with how I feel:

途に倒れて だれかの名を
呼び続けたことが ありますか
人ごとに言うほど たそがれは
優しい人好しじゃ ありません

別れの気分に 味を占めて
あなたは 私の戸を叩いた
私は別れを 忘れたくて
あなたの眼を見ずに 戸を開けた

わかれはいつもついて来る 幸せの後ろをついて来る
それが私のクセなのか いつも目覚めれば独り

うかれ街あたりで 名をあげる
眠れない私は つれづれに
わかれうた 今夜も 口ずさむ

だれが名付けたか 私には
別れうた唄いの 影がある
好きで別れ唄う 筈もない
他に知らないから 口ずさむ

恋の終わりは いつもいつも
立ち去る者だけが 美しい
残されて 戸惑う者たちは
追いかけて焦がれて 泣き狂う

わかれはいつもついて来る 幸せの後ろをついて来る
それが私のクセなのか いつも目覚めれば独り

うかれ街あたりで 名をあげる
眠れない私は つれづれに
わかれうた 今夜も 口ずさむ

English translation

by Greg Sharp

Have you ever been lying in the street
Calling someone’s name over and over
Twilight, unlike in the stories
It is neither friendly nor charming

With the flavor of farewell
You knock on my door
Wanting to forget farewell
I open the door, without looking into your eyes

Farewell always comes
It comes right after happiness
Is it my habit?
Always waking up alone?

You wear your grief
Running around town, making yourself known
But me, sleepless and bored
I sing the farewell song again tonight

Who gave me this name?
The girl who sings the farewell song
It’s not like I sing farewell because I like it
I sing it because I don’t know any other song

Always, when love is over
The one who leaves is beautiful
The bewildered one who is left behind
Chases and yearns and cries and cries

Taken from here.

Tuesday, August 4, 2009

Old Story: "The Kitsune-Ookami"

This is very old stuff I happened upon while looking through my website's archive. As far as I can tell, it's from when I was in late junior high, around six years ago. It does bring back memories, though. I'm a bit embarrassed to post it, but it's not as bad as it could be.

I am the wolf/fox hybrid. I was created in a lab accident by my guardian. I have been kept in a cage until recently. I broke out in a release of my rage in the form of demonic energy. Beware, for it may happen again. The darkness in my soul has settled, but it'll rise again.

It started off when I was eight. My parents had died recently, and I had be wandering about aimlessly. A kind old man had been sitting beneath a tree. Being as curious as I had been, I walked toward him. He looked at me and said, "Hello, young one. What brings you over here?"
I responded by saying, "I have nowhere to go. My parents died."
" need someone to care for you."
I looked down, tears forming in my eyes.
"Well, I'll take you in."
I looked up at him and smiled weakly, "Okay."

He took me to his huge castle, which scared me. I put my hands over my eyes.
"Don't be afraid, young one."
I nodded lightly and entered.
We entered a long hall. A few of the things he showed me scared me. When we reached the end of the hall, he showed me a door. I pushed the door open, and saw a nice bedroom. There was a red velvet king size bed. There were also a lot of dressers about.
I said, wide-eyed, "Is this my room?"
He nodded lightly.
I ran with glee as I went to jump on the large bed...

The years passed by. I grew into a healthy, strong teenager. I learned by reading books from his large library. I later found his name to be Professor Motoko. It was all good, until one day...

I was walking along, still as curious as ever. I came across this big steel door, which I have never seen before. I tilted my head and walked toward it. When I grasped the black handle, it was oddly warm. I pushed the door inward, a loud, resounding creak occurring. When I walked in, I found it to be a long passage, with a bright light at the end. I walked toward the light, almost intrigued by it. When I reached it, I found it to be above. I looked up and found it to be a large bulb. I blinked, baffled. Turning my head downward again, I noticed a bright green light far off to the left. I walked toward it, only to find Professor Motoko working with some huge black thing. I looked at him.
"What's this thing?"
He looked at me with a crazy look in his eyes, "Oh no, you can't be here!"
I walked toward him. He jumped down and ran at me. I felt a blow to my right as I was knocked into a huge clear chamber with a huge metal band around it, a black cap on top, and wires coming out of it. He messed with a whole bunch of different things, running around the lab like mad. A chain was pulled, a switched was flipped, and a button was pushed.

A bright light enveloped me. A great pain cut through me like a knife. I winced, falling to my knees. The pain became greater as I fell to my side, passing out.

After much time, the blackness behind my eyelids became red. When I opened my eyes, the redness remained. I felt a great power within myself. I found myself growling, my eyes narrow. A great rage started to form, unprovoked. The power started to flow from my fingertips. As I looked at my body, the blue glow enveloped the entire thing. My fingers arched as long, metal claws came from my fingertips. I slowly moved my fingers individually, feeling a great desire to destroy. My eyes focused upon the containment chamber. I outstretched my arm, my claws extended. My arm trusted downward, shattering the side of the big case.

I walked forward, out of the clear prison. My eyes traced the surroundings as I continued to walk. As I got to the edge of the room, my newly formed fox-like ear twitched as a sound entered it. I turned around to find Motoko with a huge rod. He whacked it against me. My energy levels drained, my oversized body collapsing. I passed out.

My body twitched as I awoke, finding myself in a huge metal cage. I leaped upward, my head hitting the top. I charged at the side of the cage, my hands gripping the bars tightly. I managed to rattle it, but was unable to break it. The redness in my eyes grew deeper as my body heated up. The glow from my body turned white as I fell to my knees, my fingers curled lightly. My body trembled as the power overcame me. The red turned to white as everything faded.

When the white cleared, I found rubble surrounding me. My eyes narrowed as the natural light flooded inward. My feet paced forward across the wooden rubble, my balance unsteady. As I look downward, I found my feet to have gotten a lot smaller, as if they were paws. My eyes crossed, only to find a large nose residing upon my face. I looked to my hands, finding that they were similar as before, only covered in a dark orange and brown fur. The wind began to blow lightly, but instead of feeling it against my skin, I felt some waving. I look around at my body, finding it covered in fur with colors ranging from the dark orange to a deep brown with hints of silver. I began to pace again. As my feet went over a hard, round thing, I looked down. My eyes set upon the remains of Professor Motoko's skull. A deep growl resounded in my throat. I shook it off and continued to walk. My body turned to the path leading away from the castle as my feet paced forward.

I took one last look at the ruins through the corner of my eye, before snorting and facing away. My feet began to pace forward, away from the memories. My anger clouded my mind. My thoughts were:

"How could he ever do this to me?"
"Why would he be doing this?"
"Was I taken in to be an experiment?"

The anger never even touched on sadness. As I thought about this, I found myself walking upon all for limbs, my hands transformed into paws. I walked on all fours, as if it was natural.

A hunger formed in my stomach as I walked. I had a bizarre taste for blood. My pacing quickened, the hunger growing. My narrowed eyes shifted about, scanning the terrain for any signs of movement. They spied one bit of movement between the trees. My trot became a brisk walk, then a run as I followed the movement. My body dropped to the ground silently. I felt my legs instantly straighten, my body being forced through the air as I landed upon my prey, a large male deer. I sunk my elongated teeth into its neck, the blood entering my mouth. The taste made my vision tint a brighter red. As my teeth dug deeper, the spine of the neck snapped. The body of the deer went limp. My mouth pulled from its neck and lunged at the body. The fangs dug in as I pulled my mouth from the large body rapidly. The crimson fluid stained the pelt of the animal. As I tore at the body rapidly, more and more red tissue became exposed. Me mouth returned to its side as my teeth into it. I pulled out a mouthful and swallowed...

After several minutes of scouring the deer of its soft tissues, only the bone remained. The hunger had disappeared. A strong urge to rest formed within me. I paced toward a bush and around it. As to my amazement, a gray-furred creature rested behind it. I stepped towards it, sniffing the fur. I found the pheromones of a female being admitted by this creature. Seeing no reason not to, I laid my body beside hers, my side pressing to hers. My eyelids relaxed as my they slowly closed...

After what seemed for days, I felt pressure upon my muzzle. This pressure was odd, due to the fact moisture was left by the movement. My eyes opened slowly, the red tint gone. For once, I felt calm, relaxed. My first sight as my eyes opened, a large gray beast. I felt the urge to jump, yet it subsided as I smelled the pheramones I have noticed from before. My head slowly raised, becoming level with the grey, furry creature's. As my legs began to take my weight, lifting it slowly, the female slipped beneath me slowly, brushing against a tender spot. If I were to still be human, this would be a blushing moment. I looked to my opposite side, her slipping outwards from beneath me in that direction. She lightly touched her nose to mine. My eyes widened slightly as I felt her cold, wet nose against mine. I knew that she has become interested in me, yet I could see no reason why.

Thursday, July 30, 2009


I came across this song while browsing the Vocaloid Wiki, and boy I was caught by surprise. It's no wonder it's popular outside of Japan: it's very upbeat, and manages to feature most of the Vocaloids (including fan-made) at least once.

It was painful getting the source encoding of the lyrics file correct, but here it is in Unicode for your enjoyment.

Honey くれたよね わたしに
愛のメロディ 今
心の中で 響いてる

Honey 君はなんでも お見通し
伝えたいの 私の気持ち

笑っても 泣いても

送るわね Honey
愛の言葉 顔文字たくさん使い
二人でヒミツしましょ 愛を感じていたい

君が呼ぶ Honey
甘い言葉 心のブログ更新し
幸せと 驚きで 飽きないの

ねえ わたしに 君 教えて

Honey くれたよね わたしに
愛のイヤホン 今
心の中で 使ってる

Honey 君の声しか 聴こえない
頭の中 ハートでいっぱい

喜びも 悲しみも

送るわね Honey
愛の言葉 顔文字たくさん使い
二人でヒミツしましょ 愛を感じていたい

君が呼ぶ Honey
甘い言葉 心のブログ更新し
幸せと 驚きで 飽きないの

ねえ わたしに 君 教えて

Friday, July 24, 2009

新世界 - 平原綾香

This song was in a dream I had last night. It's based on Dvorak's New World Symphony.

Find your way, no matter how hard it is.
Keep your feet on the ground and see what is waiting
the new world is there.

When I'm lost 青い 月明かり
夢の続き 探してた

出会い 別れ 夢やぶれて
すべてが 終わりのように見えた

どんな 自分を 生きればいい
どこまで 人を 信じればいい

きっと 心に 夜明けは来る
まだ 見えない未来の 向こうから

When I'm lost 遠い 道の先で
自分との決まりを 今 破る時

くるしいこころも そのままでいい
かなしいおもいも そのままでいい

それは 心 なおすことなく 手放すこと
いつだって きっと自分は 生まれ変われる

いのち 満ちる この地球(ふるさと)
誰もが 帰る 旅の果てに

まだ知らない この私が微笑んでいる

どんな 自分でも 愛していたい
今起こる 何もかも 信じたいから

溢れ出す涙 夢を見せて
私だけに 出来る 何かが 必ずある

なつかしい大地を 強く踏みしめて

もう何も 迷わない そんな世界へ ゆけるはず
私は行く 新しい世界へ

Saturday, July 18, 2009

Central Link Grand Opening

Othello Station during testing, from Wikipedia.

Today marks the first day of the rest of Puget Sound's history: the opening of Sound Transit's Central Link, the first stage in the large-scale Link light rail network. I went for the ribbon cutting, since I always like firsts (search for "9:33 AM"). Note: while I do live in Bothell, I usually drive to Lynnwood on weekends.

I left early this morning via the first southbound 511, then transferred to a 7. I didn't know that they had shuttles for the occasion, but ran to a 97 shuttle to Mt. Baker Station. Note that the one I rode was a Metro DE60LF, not a Sound Transit bus. The shuttle driver missed the station, and had to turn around south of Columbia City station, and negotiate the small residential streets until we got back.

Now, I didn't actually have an inaugural ride ticket, since I had work at the time they were available, but I still managed to attend the ceremony behind the "public fence." Various people, including engineers and local activists and leaders gave their speeches. However, the most ceremonious act was when the mayor of Tukwila rode a Link train North and Greg Nickels rode another Link train South to Mt. Baker Station. They performed the ribbon cutting, then the inaugural riders, including the mayors, were allowed on the trains. To my surprise, I also managed to get a seat on the southbound inaugural train, which was a three-car train. There was plenty of seating.

The ride was quite smooth, with some great views and cool art. Everyone was very excited, and surprised at how comfortable the ride was. There's even A/C, which is likely what contributes to the most of noise that the Times was complaining about.

I rode from Mt. Baker, to Tukwila (the train turned around without forcing us to transfer at the end, which isn't normal service), back to Westlake Center, and lastly down to the International District. There was a lot of roundabout walking to transfer from northbound to southbound in the Tunnel, including exiting to the surface and re-entering.

I'm extremely excited to see what this new light rail line spurs. Who knows, I may be riding it from Lynnwood on my commute to Seattle!

Tuesday, July 14, 2009


This song and this icon really suit my mood right now.

必要なものというのは そんなに多くはない



少し探してみることもなく すぐに忘れてゆく

You never need me You never need me
Need me You never need me
もう何もないの 何もないの

そう信じてみるけれど 今はそれさえあやしい



少し探してみることもなく すぐに忘れてゆく

You never need me You never need me
Need me You never need me

You never need me You never need me
Need me Forever never need me
You never need me never need me never need me
Forever never need
You never need me

Wednesday, July 1, 2009

Standard XHTML and Flash

With the status of standardization of web "technologies" in such a sad state, "Web 2.0" really doesn't mean much on the code side.

I've found something interesting regarding standardized Flash support: a way to include it in strict XHTML (not "transitional"). It involves creating a dummy Flash movie that loads the first one. I found it in this blog entry..

The XHTML code for the movie is as follows, assuming the movie we actually want to load is movie.swf:

<object type="application/x-shockwave-flash"
<param name="movie"
value="c.swf?path=movie.swf" />

c.swf is a fairly simple bit of ActionScript:


According to the article, it loads the movie as expected and streams it. One caveat is that it won't operate properly if the browser doesn't support Flash. To fix that, something like this is necessary:

<object type="application/x-shockwave-flash
<param name="movie"
value="c.swf?path=movie.swf" />
<img src="noflash.gif" alt="" />

Of course, the img tag can be replaced with any "alternate" element to be displayed when there's no Flash support. Pretty cool.

Thursday, June 18, 2009

Kitsap Loop

Today was the first successful completion of my "Kitsap Loop" journey, which is essentially going south through Tacoma, west over the Narrows, north through Kitsap County, and back east via the Washington State Ferries. The "weakest link" of this trip is Kitsap Transit's Purdy Connection, which runs only five times each day over the course of the day. This connection is also why I haven't been able to complete this trip on my previous attempt, since I arrived too early and didn't want to wait for two hours.

Like the Whidbey Island journey, I will only mention highlights. This trip isn't called a "grand tour" because it didn't cover much of Kitsap County, unlike the Whidbey trip.

  1. CT 414 Seattle
  2. ST 594 Tacoma
  3. PT 2 TCC (originally intended to take a later PT 1 TCC)
  4. PT 100 Purdy
  5. KT Purdy Connection
  6. KT Port Orchard to Bremerton
  7. WSF Bremerton to Seattle
  8. MT 99 International District
  9. CT 414 Mountlake Terrace

Unlike previous journeys, which always started at either my house, Lynnwood, or Bothell, I decided to take advantage of CT's new parking garage at Mountlake Terrace Transit Center. It was mostly empty, but the TC was very nice, new, and much cleaner than many others. They even had a cable-stay walkway! Expecting a 40-foot Invero to pick me up, I was even more surprised when a 278XX bus picked me up.

I had hoped to make a quick-and-painless transfer to my next bus on Stewart in Seattle, but construction got in the way, and I had to run along Lenora to catch my next bus. I really wasn't expecting it to be that annoying.

Another painful transfer was to my next bus, which arrived just as I was getting my bearings. That bus smelled just like a locker room, which was disgusting the entire way.

I had originally intended to have twenty-minute headways, making the above dashing around completely unnecessary, and ended up accumulating time until I was an hour early at TCC. The driver (the same one I rode with on my previous attempt) was a bit mystified when I said, "I'll just take the next one." Instead of just waiting for an hour, I went to an IHOP a couple blocks away for lunch.

At Purdy, I had to wait another hour (as I had planned initially). After watching some teenagers go into the woods next to the transit center and come out, I decided to investigate the path for myself. The only notable thing back there was a fairly fast-flowing creek, as well as a lot of trash that had been left before.

The bus for the Purdy Connection was a dial-a-ride-transit/access bus, which made sense since it acted like Metro's DART service (somewhat fixed-route with some deviations). Those on board were friendly, and chatted as though they knew each other. Fortunately, there were no deviation requests, and it was a straight-shot along SR-16 to Port Orchard, and my hair got a beating by the wind.

The foot ferry was a fun ride, and was even smaller than King County's Water Taxi. It also was a very short trip, since I could see what I knew to be Bremerton from Port Orchard.

Having successfully completed a link I had never done before, I ended up in Bremerton. While I had hoped to meet a friend of mine there after missing the first ferry transfer, she couldn't make it in time before the next ferry left. Instead, I had some ice cream, and even saw two Orion I buses!

I barely made the free route 99 after landing in Seattle, and was lucky to even see it at all. It was over ten minutes late, or ten minutes early. Transferring to the 414 wasn't so chancy; it came only twenty minutes after I had arrived, with the Invero I had expected earlier. Is it just me, or do all of CT's Inveros have broken reclining mechanisms?

This was truly an epic trek, but I likely won't do it again alone due to that darn Purdy Connection. I don't think I'll ever forget this one.

Tuesday, June 16, 2009

Whidbey Grand Tour #3

That's right, today was my third all-day bus tour around Whidbey Island. Whidbey Island is nice to visit because of the wide, open fields, dense forests, and small-town feel. There are also several funny street names, such as "Power Road," "Spyglass Road," several variations on "Bluff Road," and "Useless Bay Road." Views of the water are common along the bus routes, such as Deception Pass, and in some places the roads are mere feet from water's edge. Last, but not least, all Island Transit routes are fare-free, as they are all tax-funded. Their buses are primarily cutaway ElDorado models, with some Gillig Phantoms.

While I won't go into in-depth detail of every leg of the trip, I will mention everything of note I can think of. There won't be a very smooth flow between paragraphs. That said, here's a list of the routes I took in order:

  1. ST 532 Everett
  2. IT 412C Camano Island
  3. IT 411C Mt. Vernon
  4. IT 411W Oak Harbor
  5. IT 1 Clinton
  6. WSF Clinton to Mukilteo
  7. CT 113 Lynnwood
  8. CT 121 UW-Bothell

While in Everett, two things of note happened. First, I saw that Everett Transit has purchased multiple diesel-electric hybrid buses. Secondly, I purchased something at Everett Station's cafe called a "Frozen Xplosion," which is pretty much fruit juice blended with ice. Last time I had bought this, they were out of the peach juice, and made something closer to an Italian soda instead, but I preferred this time with the actual peach juice. A Coast Starlight train stopped by during my wait for the next leg of the route, which hadn't happened before.

The widening of a certain section of SR-20, which had been underway during my last visit, was completed this time around. A section later along the route, however, was currently under heavy construction. One reason I like the cutaway buses is that they tend to give a rough (but fun) ride, and this was an extreme case. The driver even said "Prepare to grit your teeth" just before the rough section.

Apparently wood burning is legal on Whidbey Island, as someone had a large pile of wood burning a few blocks away (but in clear sight since it was an open area) just before the driver changeover. The smell was very strong where it passed us, but didn't last so long.

Riding Washington State Ferries is generally fun, and unlike the larger ferries in Seattle the Clinton-Mukilteo run doesn't have a separate pedestrian ramp. I never really figured out the order involved until today. Upon docking, passengers then vehicles are unloaded, then priority vehicles, regular vehicles, and pedestrians are loaded.

As per the "tradition" established after every trip, I stopped by the Mukilteo ferry port's Ivar's eatery. It was the only real meal I ate in around nine hours, and was welcomed. I barely made catching the 113 after this, but was treated to a ride in one of CT's new (281XX) buses.

That's pretty much everything of note on my trip. My last thoughts here are that buses generally smell bad, primarily due to spray deodorant and cigarettes. I can't wait until my trip through the Kitsap Peninsula!

Monday, June 15, 2009


As I've mentioned earlier, I've been working on a homework scheduler. Work isn't anywhere near done, but it's functional enough (but not tested enough). Here's what I have so

To use this script, the following files must be symlinks or hard links to

  • classes
  • exams
  • assignments
  • instructors
  • quarters
  • sections


I was having all sorts of trouble trying to figure out how to extract audio from any video file into a WAV (signed 16-bit, little-endian) format. I was fortunate enough to find something that worked universally, so here it is:


if [ $# -ge 1 ]; then
if [ $# -ge 2 ]; then
ffmpeg -i "$IN" -f wav -acodec pcm_s16le "$OUT"
echo "Usage: $0 in [ out ]" >&2

Wednesday, June 10, 2009

For the longest time, I've wanted to search PDF files from the command line. Now, I can with! This program uses pyPdf to look for pages containing strings that match the provided regex, but due to the messy output of pyPdf, it won't print the matching lines.

from optparse import OptionParser
from sys import argv
from pyPdf import PdfFileReader
from os import walk
from re import compile as re_compile
from re import IGNORECASE
from os.path import join

parser = OptionParser(description = 'Search for text in PDF files.', usage = '%s [ options ] term [ file1..fileN ]' % argv[0])
parser.add_option('-i', '--insensitive', action = 'store_true', dest = 'insensitive', help = 'Search case-insensitively.', default = False)

def pdfgrep(expr, file):
pdf = None
with open(file, 'rb') as f:
pdf = PdfFileReader(f)
for i in xrange(pdf.getNumPages()):
content = pdf.getPage(i).extractText().strip()
yield i

argv = [unicode(i, 'utf8') for i in argv]
options, args = parser.parse_args(argv[1:])

optionmap = {
'insensitive' : IGNORECASE

if len(args) >= 1:
term_flags = 0
for key, value in optionmap.iteritems():
if getattr(options, key):
term_flags |= value
term = re_compile(args[0], term_flags)
paths = ['.']
if len(args) >= 2:
paths = args[1:]
for path in paths:
for dirpath, dirnames, filenames in walk(path):
for filename in filenames:
if filename[-4:] == '.pdf':
fullfilename = join(dirpath, filename)
pages = list(pdfgrep(term, fullfilename))
if len(pages) > 0:
print u'%s:%s' % (fullfilename, u', '.join([str(i + 1) for i in pages]))
parser.error('No search term provided.')
% python -i undo ../Notes/CSE444
../Notes/CSE444/PDF/lecture14.pdf:3, 6, 10, 11
../Notes/CSE444/PDF/lecture13.pdf:17, 18, 22
../Notes/CSE444/PDF/lecture09-10.pdf:2, 16, 31, 32, 36, 37, 39, 40, 41, 42, 43, 45, 48, 49, 58, 59, 60, 62, 63, 65