Log in

No account? Create an account
“Nightwatch” [entries|archive|friends|userinfo]
"Praxeology rests on the fundamental axiom that human beings engage in conscious actions toward chosen blah blah blah blah blah teh market!"

[ website | Pictures and Stuff ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

just in case you were feeling happy [Sep. 5th, 2008|02:58 am]
In August 1999, political organizer Ralph Reed's firm sent out a mailer to Alabama conservative Christians asking them to call then-Rep. Bob Riley (R-Ala.) and tell him to vote against legislation that would have made the U.S. commonwealth of Northern Mariana Islands subject to federal wage and worker safety laws.


"The radical left, the Big Labor Union Bosses, and Bill Clinton want to pass a law preventing Chinese from coming to work on the Marianas Islands," the mailer from Reed's firm said. The Chinese workers, it added, "are exposed to the teachings of Jesus Christ" while on the islands, and many "are converted to the Christian faith and return to China with Bibles in hand."

A year earlier, the Department of the Interior -- which oversees federal policy toward the U.S. territory -- presented a very different picture of life for Chinese workers on the islands. An Interior report found that Chinese women were subject to forced abortions and that women and children were subject to forced prostitution in the local sex-tourism industry.
LinkLeave a comment

(no subject) [Sep. 5th, 2008|12:41 am]
There's a very interesting security hole in GNOME. If a program is in a loop constantly asking for the keyring password, you can't kill it from the GUI. You have to enter the password to make it shut up. The password box for the keyring is modal and prevents you from interacting with all other apps.
Link1 comment|Leave a comment

hehe [Aug. 12th, 2008|12:00 am]
[Current Mood |dorkydorky]

Whoever ported Cave Story to the Mac left in the symbols!!!

void __cdecl EncryptionBinaryData2(_BYTE *data, signed int in_len)
  unsigned __int8 v2; // al@1
  int key_pos; // ebx@1
  signed int len; // edi@1
  int key; // esi@2
  int i; // edx@4
  int n; // eax@6

  len = in_len;
  key_pos = in_len / 2;
  v2 = data[in_len / 2];
  if ( v2 )
    key = -v2;
    key = -7;
  i = 0;
  while ( i < len )
    if ( i != key_pos )
      n = (key + data[i]) & 0x800000FF;
      if ( n < 0 )
        n = ((n - 1) | 0xFFFFFF00) + 1;
      data[i] = n;

This is used for most of the data files in the game.
LinkLeave a comment

(no subject) [Jul. 28th, 2008|05:17 pm]
LinkLeave a comment

(no subject) [Jun. 27th, 2008|08:47 pm]
I've started work on a mod of Lua. Seems that everyone who uses Lua does this eventually... it's interesting how its internal simplicity leads to fragmentation.

Anyhow, here's what I have planned:
- Curly brace syntax instead of paired keywords. Sorry, but "if then else end" is pretty baroque at this point. Braces are nicely Huffman coded.
- Mandatory semicolons.
- Arrays index from 0. Dijkstra is completely right on this one.
- fn as an abbreviation for function. Also, fn(x) : foo should be accepted as shorthand for function(x) { return foo; }
- No tuples. Tuples are lists instead. a, b, c is shorthand for [ a, b, c ].
- On that note, tables are initialized as { key: value }, allowing native JSON compatibility.
- A unit type like OCaml, written as ().
- All functions take one argument and return one argument, just like OCaml. Zero argument functions are invoked like f(); i.e. applying f to unit. Multiple argument functions are passed a liist.
- Method invocation with ->, just like Perl and C++.
- Maybe some form of pattern matching? Not sure how to do this correctly without bloating the language.

Suggestions, comments?
Link3 comments|Leave a comment

(no subject) [Jun. 18th, 2008|12:33 am]
[Current Mood |sleepysleepy]

I'm going to be using Twitter instead of LJ for most of my updating for a while at least. I rarely post what can't be summed up in 140 characters on this thing anyway.
LinkLeave a comment

Acen? Dame yo [May. 17th, 2008|01:40 pm]
I went with Scott to check out Acen. Since we couldn't be there Friday, it made no sense to preregister. Due to delays on the CTA, we got there around 12:15 PM. No problem right?

There were people who had arrived at 7:15 in the morning still standing in the fucking registration line.

No thanks. I bailed. Acen is fun and all, but I ain't waiting 6 hours. I guess I'm getting old.
LinkLeave a comment

foxnews.jpg [May. 1st, 2008|11:25 am]
[Current Mood |gigglygiggly]


This is just unreal.
Link5 comments|Leave a comment

Sound on Linux! [Mar. 15th, 2008|02:53 pm]
[Current Mood |weirdweird]

If you have sound problems on Linux, do this:

(1) Install PulseAudio. Instructions for Ubuntu are here.
(2) Enjoy.

Seriously, PulseAudio needs to be set up as the default in Linux distributions now. Because it tries to emulate every known way for Linux apps to access the sound card (with the notable exception of aRts, but you can upgrade to KDE 4 to mitigate that), apps that play sound suddenly start to Just Work. I've installed PulseAudio on both of my main Linux systems now, and it was ridiculous how all the problems just disappeared. Sound mixing and incompatible sound APIs have been terrible warts on Linux for a long time, and the sooner people just move to Pulse, the better.
Link6 comments|Leave a comment

(no subject) [Feb. 25th, 2008|04:15 pm]
"I play a lot of TF2 anymore."

This is a weird sentence, Dr. Dos. Half the class didn't know what it meant! Your dialect screws up semantic analysis of negative polarity items.

The prof said it was a rural Pennsylvanian dialectical thing. Has anyone else heard this? Dos is the only one I know who uses "anymore" this way.

edit: better example sentence
Link6 comments|Leave a comment

Disable the private flag in Transmission [Feb. 12th, 2008|12:41 am]
[Current Mood |geekygeeky]

The private flag in BitTorrent, which disables any external peer exchange for a torrent, is DRM, plain and simple. It's a malicious feature designed to force the wishes of the content producers (the private trackers) on you. The P2P community shouldn't rail against DRM and simultaneously encourage it when it's convenient. I do sympathize with private trackers, but they can't be hypocritical: DRM isn't the way to go about their issues.

Thankfully, we have open source BitTorrent clients, so we don't have to put up with our computers working against us.

Following is a patch to Transmission 1.05 to remove the private flag. I don't care if Transmission gets banned from trackers for this: it's easy enough to make the client masquerade as other clients.

diff -Naur transmission-1.05/libtransmission/metainfo.c transmission-1.05-noprivate/libtransmission/metainfo.c
--- transmission-1.05/libtransmission/metainfo.c	2008-02-12 00:38:45.000000000 -0600
+++ transmission-1.05-noprivate/libtransmission/metainfo.c	2008-02-12 00:39:32.000000000 -0600
@@ -219,13 +219,7 @@
     /* Private torrent */
-    val  = tr_bencDictFind( beInfo, "private" );
-    val2 = tr_bencDictFind( meta,  "private" );
-    if( ( NULL != val  && ( TYPE_INT != val->type  || 0 != val->val.i ) ) ||
-        ( NULL != val2 && ( TYPE_INT != val2->type || 0 != val2->val.i ) ) )
-    {
-        inf->isPrivate = 1;
-    }
+    /* Disabled in -noprivate branch */
     /* Piece length */
     val = tr_bencDictFind( beInfo, "piece length" );
Link5 comments|Leave a comment

C# option parsing library [Feb. 10th, 2008|07:54 pm]
[Current Mood |accomplishedaccomplished]

I wrote a command line option parsing library in C#, based on Perl/CPAN's Getopt::Long. I think it is better than all the others available for C#.

Features include:
- Scalar, array, or hash types for option arguments
- Incrementable options (e.g. --verbose --verbose --verbose for 3x verbose)
- Option bundling if enabled (-zxvf=foo.tar.gz is the same as --gzip --extract --verbose --file foo.tar.gz)
- Generic argument types: you can ask that arguments be returned in any numeric type, string or bool, and it Does What You Mean
- Optional events to hook into in order to create custom options

Here's an example (NXGetoptLong/t/Simple.cs):
using System;
using System.Collections.Generic;

using NX.Getopt.Long;

using C = System.Console;

namespace NX.Getopt.Long.Tests {
    public class Simple {
        public static void Main(string[] args)
            var p = new Parser();
            var gzip = new VoidOption("gzip") { Aliases = new string[] { "z" }
            var extract = new VoidOption("extract") { Aliases = new string[]
                { "x" } };
            var verbose = new IncrementableOption("verbose");
            var file = new ScalarOption<string>("file");

            p.Bundling = Parser.BundlingOptions.Enabled;
            p.GetOptions(args, new Option[] { gzip, extract, verbose, file });


Get the code here.
LinkLeave a comment

C# gripe [Feb. 7th, 2008|09:30 pm]

Do not use factory classes. Every single use of factory classes can be done much more cleanly using private classes. Just replace the is-a relationship with a has-a relationship.

Here's an example of the wrong way to do it, which I see all the time:
public abstract class Pokemon { 
    public void Attack();

public class Growlithe {
    public void Attack() { ... }

public class Pikachu {
    public void Attack() { ... }

public static class PokemonFactory {
     public static Pokemon Create(string kind)
         if (kind == "Growlithe")
             return new Growlithe();
             return new Pikachu();

This is Java-ish syntactic noise, and it leaks implementation details. Why should the caller have to care whether the object is internally a Growlithe or a Pikachu, when you meant to present the opaque type Pokemon to them?

Here's a better way to do it:
public class Pokemon {
    private abstract class InternalPokemon {
        public abstract void Attack();

    private class Growlithe : InternalPokemon {
        public void Attack();
    private class Pikachu : InternalPokemon {
        public void Attack();

    private InternalPokemon ip;

    public Pokemon(string kind)
         if (kind == "Growlithe")
             ip = new Growlithe();
             ip = new Pikachu();

    public void Attack()

This is less code, and it hides implementation details. It's also more flexible, because it allows you to use any object you want as the "internal" object.
LinkLeave a comment

(no subject) [Jan. 8th, 2008|01:01 am]
[Current Mood |energeticenergetic]
[Current Music |Ladytron - Seventeen]

MPD and Sonata beat the shit out of iTunes and Apple TV as a way to deal with the problem of playing music through speakers that don't suck when your main computer is a laptop you take everywhere.

I have a hacked Apple TV running Ubuntu hooked up to my speakers (with a custom modified Linux kernel that allows the analog audio to work on the Apple TV - if anyone is reading this and needs a patch let me know). I gave it a bigger hard disk, so it'll have plenty of room for any music. It'll be my music master server of sorts, and I'm keeping it up to date with rsync. It's connected to my wifi AP via ethernet and advertises itself with Avahi, so anything behind my router can talk to the MPD.

Sonata is the slickest music player I've seen. I can control the music through my main speakers with Sonata from anywhere in the apartment, with no setup required as long as I'm on my wifi network.
Link2 comments|Leave a comment

(no subject) [Dec. 13th, 2007|04:36 pm]
[Current Mood |blahblah]

I bought The Orange Box for Team Fortress 2.

It doesn't work.

(Wine + Ubuntu + Intel GMA X3100, for the small chance that someone is googling this and doesn't want to repeat my mistake.)
Link1 comment|Leave a comment

Audio APIs for Linux [Dec. 5th, 2007|11:20 pm]
[Current Mood |hungryhungry]

Some observations on Linux desktop audio APIs.

  • ALSA is a nice driver framework. ALSA sucks as a high-level audio API. Stop coding your general desktop use app in it. It is hard to configure and finicky, and most apps that claim to support it (e.g. ZSNES) don't actually support it very well.

  • OSS is great if you are living in the days when a Sound Blaster 16 was a high-level audio card. Unfortunately, these days we need more than one program to be able to play sound at one time. More often than not, ESounD or aRts will be hogging /dev/dsp, resulting in incredibly confusing error messages to the end user. If your app (I'm looking at you, Praat and VMware) still uses OSS, please do us all a favor and upgrade.

  • ESounD is GNOME only and basically works, but for real time apps it is slooooooow.

  • aRts is KDE only, and since Ubuntu is the way things are increasingly going, it's more likely than not not installed on your users' machines.

What does that leave? It's an option that is all too often forgotten:

  • SDL. SDL is simple and it has a remarkable tendency to just work. There are bindings to every language in existence, it's a mature codebase, and it embodies the Unix design philosophy well. Plus, if you write in SDL, you're portable to Windows and Mac OS X too!

I write this after fiddling with audio setting after audio setting in various programs, trying to get them to all work properly together, but to no avail. Then I set all the programs' audio output to SDL, and every single program worked.

If you're writing a Linux audio program, do your users a favor and use SDL by default.
Link4 comments|Leave a comment

(no subject) [Nov. 30th, 2007|04:17 pm]
[Current Mood |curiouscurious]

Once I'm done with all this work, I want to code something.

I've always wanted to write an SNES emulator. I have some ideas for how to improve accuracy and performance. For instance, I'd like to try out the idea of a "lazy dot clock": one of the big stumbling blocks so far in SNES emulation has been emulating the PPU's process of continuously drawing the screen, pixel by pixel. It's too slow to do this actively (i.e. actually drawing a pixel at a time at the right speed), but the thing is that the SNES CPU is too slow for games to truly take advantage of pixel-by-pixel changes anyhow. It should theoretically be possible to calculate the position the dot clock should be at at the moment the SNES CPU performs an operation that is affected by it, and at that point draw the scanline up to that position. It would also be best to take advantage of multithreading for the audio stuff: the SNES audio chip is especially suited to this because the amount of interplay between the core system and the audio chip is minimal (4 1-byte registers mirrored on both sides, to be exact). I'd like to try writing the emulator in C#, with the tight CPU intensive stuff (like the core 65816 CPU emulation, probably) in assembler.

Or I could write an iPhone driver for Linux. This would involve reversing the USBMux stuff, then the Lockdown stuff, then implementing the AFC protocol. Again, I'd probably do this in C#/Mono. It'd be tricky, and Apple can change the protocol at any time, but it's a big gaping hole in Linux driver support at the moment.

Any thoughts? Other project ideas? Nothing too ambitious, mind you :)
Link2 comments|Leave a comment

CHRISTMAS CARDS TIEM [Nov. 28th, 2007|09:13 pm]
[Current Mood |sicksick]

Because I need some holiday cheer while I'm swamped in work and swamped with this awful cold... WHO WANTS A CHRISTMAS CARD?!

Since it was a success last year, I'm going to do the Christmas card exchange again! Just drop me an e-mail at pcwalton at uchicago dot edu with your address and I'll send you something. It's not necessary, but if you want to send me one back just ask for my address.

I guarantee I won't stalk you!

Link1 comment|Leave a comment

New laptop soon [Nov. 8th, 2007|11:50 am]
Apple declared my laptop DOA and said it would cost over $1400 and who-knows-how-long to repair. Screw that. I'll probably go down to pick it up, so I can grab the undamaged 160 GB hard disk out of it. I have a HDD enclosure, so that'll still be useful.

I dove into my Google SoC money and bought an $800 Fujitsu LifeBook that was on sale at newegg. Yes, a non-Apple laptop. My friend Shu loves his Fujitsu, so I figured I'd give it a shot. I'm not bitter, since nobody repairs water damage, and I'm okay with that. Rather, I'm annoyed with how consumer-unfriendly Apple has been lately. The successes of the iTunes Music Store and the iPhone have made the company think that petty things like kernel-level DRM and closed platforms and bricking phones are acceptable. And they're not. I'm totally okay with closed source - it's closed source and asshole tactics that I don't like. DVD Jon is totally right about all this (well, I still think he's crazy for liking the Zune but hey).

So I'm going to be an Ubuntu + Xfce user before long. I discovered Xfce at the lab, and I love it. It's a pretty desktop that doesn't get in your way. Add Compiz Fusion and Murrina and it'll be as pretty as OS X.

I'm going to miss Adium though.
Link2 comments|Leave a comment

loooool [Oct. 12th, 2007|02:38 pm]
The Mises Institute (libertarian crazies) review The Phantom Menace.
LinkLeave a comment

[ viewing | most recent entries ]
[ go | earlier ]