Wit: A Programmer’s Best Tool

I was humbled this past week.  I went to an interview at a game company.  But I didn't have my most valuable asset. Read the rest of this entry »

Comments off

Internet 1, Pat 0

Of course, the $170/month internet doesn't work. Turns out, Verizon claimed near 100% V-Cast (EVDO Rev.A) coverage of Sainte Genevieve county. They're lying. While we were able to get a signal, we could never acquire a digital signal. Read the rest of this entry »

Comments off

Backported entries…

I just imported a bunch of my posts from theconans.com so as to preserve them here.  Some of them are nice, like favorite sci-fi books.  Scroll back a bit and check it out.

Comments off

Never underestimate the bandwidth…

I'm so excited.  UPS says my Internet will arrive in a truck on Monday.  It's already at Nashville! The title, of course, is a reference to that oft-heard saying, probably by Dennis Ritchie.

Comments off

Thought for the day: 2008-08-06

My daughter asked me last night:
Daddy, what if the whole world was clay except for chain saws?
Read the rest of this entry »

Comments off

Lots of photos available…

I finally got the bulk of our photos tagged and uploaded to Muddyhorse Photos.  Enjoy!  Note:  the tag plugin for Gallery is a bit rough, but that's what we have for now.

Comments off

Conference: Overall

Overall, a pretty good conference.  Here's a quick summary of Dr. Dobbs Architecture & Design World 2008. Read the rest of this entry »

Comments off

Conference: Topics

I plan on doing a write-up of the major points about the conference.  Here are some upcoming topics: On the whole, it was a good experience.  I'd love to have as good a time at the next conference.

Comments off

Conquering the bus

I took my first two bus rides today after class.  Aside from inserting my pass right, and figuring out how to get off the bus, it wasn't too bad.  We went to Chinatown, and ate at Saint's Alp Tea House, as recommended by dear friend Anna.  Very Tasty!

Comments off

Chicago Arrival…

We made it safely to Chicago today.  We're up on the 29th floor!  Pretty nice.  Thanks to Jim, Stacy, and everyone else who helped in the process of making Pat survive the big city!  By the way, no internet access in room?  What is that about?

Comments off

Quick Guide to using Weak References in Java

Java's WeakReference functionality is an easy way to handle a lot of data but not have to worry about running out of memory.  Works well in lazy-initialization situations, such as when you want to be able to read in a potentially large amount of data, but that data is not important enough that you want to guarantee that it is always immediately available. For example, say you are reading a 5 megapixel image off the disk in order to determine its size or make a thumbnail or otherwise read metadata. Or, you could be scanning files for spell checking or search terms.  Either way, you really don't care that the original, large, source data stays in memory. If would be great if it did, for performance's sake, but not the end of the world if it was garbage-collected. By default, all java references are strong references -- the object on the other end of a strong reference is not garbage collected until the object containing the reference is collected.  That is where java.lang.ref.WeakReference comes in. Instead of keeping your strong reference in your object, you give it to a WeakReference instance instead. It does the dirty work of allowing the reference to be collected. You now have a strong reference to only a WeakReference object -- a relative lightweight, in memory terms.  All you have to do is make sure the data is loaded when you want, and WeakRef and the GC will take care of unloading it as needed. So, let's take the example of reading a large file into a string, but we don't mind re-reading the file if memory becomes tight. The following code assumes there is a class, FileUtils, that has a method for reading the file. Implementation of that method is left as an exercise to the reader.
import java.io.File;
import java.lang.ref.WeakReference;

public class LazyFileReader {
    private WeakReference<String> fileRef;
    private final String filename;

    public LazyFileReader(String filename) {
        this.filename = filename;
    }

    private String forceLoadFileData() {
        // force initialization; create reference
        String rv = FileUtils.fileToString(new File(filename));
        // update weakRef:
        fileRef = new WeakReference<String>(rv); // **1**

        return rv;
    }

    public String getFileData() {
        String rv;

        if (fileRef == null) { // **2**
            // first loading, force:
            System.out.println("first loading: " + filename);
            rv = forceLoadFileData();

        } else {
            // load from weakRef:
            rv = fileRef.get(); // **3**
            if (rv == null) {
                System.out.println("file needs reloading: " + filename);
                rv = forceLoadFileData(); // **4**
            } // endif
        } // endif

        return rv;
    }
}
Some notes, indicated by // ** # ** comments above:
  1. Note that once a WeakReference has released its data, you can't update the reference -- you must create a new one each time.
  2. The very first time getFileData() is called, we don't even have a WeakReference reference. This situation will only happen once.
  3. get() is the means by which you get back the reference you put in. A null value indicates that the reference was collected and therefore needs to be recreated.
  4. Note that we perform the exact same code during the first time through and the first time through after the reference was collected.
Hope that helps.

Comments off

The Power of Naming

How often have you read a story where the way to defeat an enemy is to know its name?  Or seen a movie where the discovery of a name leads to control over the named object?  Some examples in popular culture:
  • Rumpelstiltskin would be the prime example here.  By learning the name, and speaking it to the creature, the miller's daughter got out of the bargain she had made (to be able to spin straw into gold, she had to give up her firstborn).
  • In The Tenth Kingdom, the blind woodsman would only release his prisoner and give the heroes his magic axe if they could guess his name.  (Luckily, he kept it in his hat.)
  • The undoing of the Horned King in The Book of Three by Lloyd Alexander was the speaking of his name.
  • In Aidyn Chronicles for the Nintendo64, the main character Alaron lacks a True Name, which binds his body and soul together.  Without it, he is incomplete.
The question is, does any of this apply to the real world? It was, in fact, in my playing of Aidyn Chronicles that I first became cognizant of this whole business.  In it, there is a discipline of magic called Naming set in contrast to the more familiar Elemental (fire, air, earth, water) magic.  At the time, I thought, "What's the big deal?  Is having a name and giving a name so important?"  This was 2001. Flash forward to 2007.  I have a daughter now, and she's struggling to learn everything in the world.  She will eat up new words and start using them immediately.  She feels every word brings her more power. Well, knowledge is power, names are knowledge, and therefore names are power.  So I guess it makes a bit of sense.  You can know about something.  But this is not just knowing something, it is naming that something.  If you know enough about a thing, you can name it, categorize it, relegate it.  Give a name to your fear, the saying goes. I suspect naming can have broader powers too... a way of setting the stage for a debate, for example.  If you coin a product name, a movment, a philosophy, or anything, you may well be determining the ultimate fate of that thing.  At the very least, you're doing a bit of mind control by making a popular name that everyone speaks. Wikipedia has a bit more discussion in this vein, under the True Name topic.

Comments off

Horsing around

Kaylee & Rodeo I was the tech guy again for the horse show at the Ste. Gen County fair.  Not a bad gig, but I am a terrible MS Access 97 designer, so the application is pretty bad, and generally wrong. Actually, I can't blame Access 97, I just did very poor requirements gathering and data analysis.  Generally, you have riders, horses, and classes (a set of horses and riders doing something specific, competing against each other). What I did wrong was assume that each rider has one number, and each number has one rider (one and only one is the phrase, in CS and math circles).  It's pinned to their backs, for crying out loud!  I made rider-number a unique key on the Rider table. Well, either things changed, or I just didn't understand things.  Now, the number is associated with the horse.  Oftentimes, if two people are using the same horse, but in different classes, then they will sign up with the same number.  Apparently, that's how the big shows do it. My workload now is typically 100% for the first hour and a half or so, as I try to slam in as many entries of horse/rider/class as possible, focusing on the earlier classes.  After that initial rush, things trickle down to 20% or so, while I add in late entries and print off class lists. I have an actual Access form for adding rows to the RiderHorseClass join table.  That form doesn't refresh its entry fields, so every change to Horse and Rider tables means I have to reopen the RiderHorseClass form and go to a new record.  Because I have key-constraints in there, I also can't just enter data without them being in the source tables. Anyway, it's a classic case of over engineering, Pat-style.  I could almost denormalize the RiderHorseClass table and just allow free-form entry, if Access would be happy with that.  I do want to avoid having to type Rider and Horse names in their entierty... Problem is, I've been using the DB for 10 shows now, and I am too lazy to change.  What do I do? Anyway, one perk was this: Sunset

Comments off

WordPress Newbie: Categories vs. Tags

I know nearly nothing about wordpress, and quickly got confused by the fact I can enter categories and tags.  Well, after a bit of searching, I found the answer.  Click Read On for more. Read the rest of this entry »

Comments off

Favorite Sci-fi books

I posted this over at IGN, but I wanted to preserve the content here. To that end, here are some of my favorite science fiction books. Regarding A.C. Clarke, be sure to read the first Rendezvous with Rama book, but none of the sequels. Also, try out Neal Stephenson. My favorite so far is The Diamond Age, but Cryptonomicron and Snow Crash are excellent as well. All of them fall in the computer geek realm, not so much space sci-fi as nerd sci-fi. Note: these are not short books, but are well-written. A couple of older favorites: Junkyard Planet / The Cosmic Computer, by H. Beam Piper is a 1963 novel that is a light read but is entertaining and has survived pretty well, ie, it doesn't sound outdated or silly. Through a copyright quirk, it is public domain, and can be downloaded if you can't find a copy. My Name is Legion by Roger Zelazny continues the hacker theme a bit. It involves a global ID system that one man has a backdoor into and he uses this to be a "freelance investigator and problem solver." read more over at TheConans »

Comments off

ObjectDock: Gorgeous, but useless…

ObjectDock is a free Windows TaskBar replacement, sort of.  You can look at the screenshots to get a feel for what it looks like.  It's not exactly fair to call it a TaskBar replacement, it is trying more to be a launch bar, and a host for small dock applets, like a weather widget, email notificaiton, etc.  MacOS X has something similar, Google Desktop is similar.  Here's my quick review. Read the rest of this entry »

Comments off

Movie Review: Juno

Juno is a fabulous movie, clever dialog and real depth to characters.  I don't want to say too much about it, as I can't do it justice.  A great soundtrack and songs accompany us through the journey. Read the rest of this entry »

Comments off

Game Review: N+

N+ is the new hotness on XBox Live Arcade, created by metanet software as a sequel to their flash game, N. Read the rest of this entry »

Comments off

Pat’s Favorite FireFox Extensions

Here are all of the best Firefox Extensions I use. I do stay on Firefox 1.5 for most of my browsers, so some of these may not be available for 2.0 and greater. These are presented roughly in the order of how often I use them.

Read the rest of this entry »

Comments off

Fun links…

I just wanted to share a couple of nice links I came across yesterday Read the rest of this entry »

Comments off

« Previous Page« Previous entries « Previous Page · Next Page » Next entries »Next Page »