October 2006

C#’s params keyword makes variable parameter functions easy

I don’t know why I didn’t know this earlier, but C# has a nifty language element called params that lets you do multi parameter functions nice and easy. Instead of assigning an array as a parameter, which means explicitly creating and populating an array in your calling code, you can use do void foo(params int[] myparams) and call it with foo(1, 2, 3, 4) etc. This is much nicer for the caller, and judging from my preliminary tests, it looks like it’s backward compatible with older method calls, so you can add the params keyword to an existing function that takes an array without having to change all the old references.

Technorati Tags:

.Net

Comments (0)

Permalink

Getting the PS2 to read blue discs

I fixed my PlayStation!

A few months back, I bought a copy of the “has to be awesome” Intellivision Lives! disc for the PS2 at the local used game shop. Sadly, it didn’t work, and I had to return it, attributing it to a bad used disc. This weekend, I stopped at a game shop while visiting my folks and found the same game, so I snapped it up. When I got home, it wouldn’t work either. The PS2 made a horrible crunking noise and eventually gave up with a “disc read error.”

I figured the odds of two used discs going bad were slimmer, and I noticed that the data side of this disc was blue. A few Google searches for PS2 blue disc problem revealed that this was pretty common - the system uses two different lasers or something, one for DVDs and one for CDs, and the alignment can sometimes be off for one or both of them.

This guide told me all I needed to know, from how to open the damned case to how to adjust the laser angle. The only pain in the butt is that you don’t know what the angle’s supposed to be, so the process basically involves turning a knob, turning on the PS2, trying to read a blue disc, turning it off, turning the knob, etc.

Of course, I broke Jason’s first law of hardware repair: don’t put everything back together right away. It turns out that the alignment isn’t perfect, and once in a while I still get disc read errors, but for now I can get around it by reinserting the disc until it works. If and when I get more blue discs, I’ll go through the process again. Or I’ll just get a new console.

As for the game, it’s pretty fun, but it suffers a bit from the Intellivision’s controller style, which doesn’t translate well. I wanted it for Shark! Shark!, which doesn’t need anything fancy, so I’m happy. There are also a few video featurettes that are worth watching, but not more than once.

Now that I’m feeling all handy, I think it’s time to fix the broil element on the stove…

General

Comments (0)

Permalink

Two types

Jeremy Miller claims that there are two types of developers in the world: those who say “goo-id” and those who say “gwid.” It never occurred to me to say gwid before, but I bet the compulsion will bubble to the surface whenever I’m in a developer conversation from now on, which means I should probably just lock myself in a bunker and stick to IM.

On the topic of pronunciation, I was happy to read that I’ve been pronouncing MySQL correctly all along.

General

Comments (0)

Permalink

Brent Simmons on hybrid applications

I grow more jealous of Cocoa: Brent Simmons has posted slides from a presentation regarding my old flame, the hybrid app. Mostly bullet points, but with enough code samples to give a non-Cocoa programmer some envy.

It’s funny, if I was writing an app on a PC I’d make it hybrid because I could have more control over the UI at the desktop layer, delegating the web to data tasks, but if I was on a Mac I’d go hybrid because I could do more with the UI if it was a web page, due to my lack of understanding of the many many square brackets in Objective-C.

In either case, the goal behind a hybrid application (for me) would be to solve a problem that benefits from centralized data.

Technorati Tags: ,

Cocoa

Comments (0)

Permalink

Getting Real sports a few new versions

37 Signals has re-released their Getting Real book in a few new formats: it was originally a $19 PDF, and now there’s a $29 book (via Lulu) and a free HTML version. Now I might finally get around to deciding how much of this “less” business is hype and how much is valid. I’m suspecting 25:75.

Coincidentally, I’ve got to start commuting today after a year and a half of maintaining a home office. Hello, Palm + Plucker!

Programming

Comments (0)

Permalink

All I want for Christmas is a full-text I, Cringely feed

I, Cringely is semi-offline for the next few days while they install some new blogging software, but the RSS feed finally has full-text content instead of the one-liners of the past! Here’s hoping that the full-text isn’t just a placeholder while the core site is offline, and it’ll still be there when the site returns.

(For those who miss NerdTV, there’s also a preview video on the temp page)

Technorati Tags:

Interweb++

Comments (1)

Permalink

MySQL and ASP.NET performance

Karl Seguin’s got a post on a topic near and dear to my heart - MySQL on Windows. We’re running ASP.NET with a MySQL back end, which happens to be the same kind of setup that he’s looking at for an upcoming project. When we made the decision, it was the early days in the company and we couldn’t afford SQL Server licenses but needed to support some legacy ASP code, so we were driven by necessity. Karl actually took some basic metrics, so, uh, good for him.

Shortening his short version of the story, InnoDB on 5.x might be problematic, but ASP.NET connects at about the same speed as PHP does, and MySQL on Linux blew away SQL Server on Windows. It was a simple test that shouldn’t provide any real conclusions, but hey, it gives me a much stronger position than “uh, we run it because we had to.”

For the record, I love the MySQL/ASP.NET combo, at least if you’re tied to IIS like we are. For code, while we do have some PHP applications, I’m quicker and more comfortable (and thus more productive) with C#. For the db, there are a lot more web developers out there running MySQL and posting stuff online about it, so I’ve got a broader knowledge base to draw from when I have a riddle to solve.

Technorati Tags: ,

.Net
MySQL

Comments (1)

Permalink

Wozniak, Homebrew, and DemoCamp

Robert Scoble’s interview with Steve Wozniak is worth watching if you’ve got an hour to kill. They talked a little about the Homebrew Computer Club, which was a little before my time, but it captured my imagination when I read about it in Steven Levy’s Hackers: Heroes of the Computer Revolution back in high school. Computers, especially hardware, have gotten a little more complicated since then, but it struck me yesterday how the current “Camp” movement is probably the best approximation of the energy that must have been present in those days, and it’s exciting to think of what might come out of the new generation of meetups.

Not-so-coincidentally, I made it out to DemoCamp10 last night after missing several over the summer (paradoxically, my first DemoCamp was at the Radiant Core offices, which wasn’t exactly easy to find, but I couldn’t summon the motivation to look up No Regrets on the map). I’m sure that in the Homebrew days there must have been a few demos where the magic smoke was let out, and the tradition carried over last night. Still, there were a few solid presentations. I was particularly interested in the first one, an online grading and code review system (screencast here). I have no need to mark students’ work, but as ( I think) Greg Wilson pointed out, there are some applications for code review within a development team. My life as a former bank guy kicked in and I thought it’d be interesting to see some kind of financial application review process. Talking at our table, the consensus seemed to be that the left side of the app was solid for most uses, but the right side would be awesome if there was some kind of plugin architecture so various needs could be catered to. There’s a lot left to be done in the collaborative workspace, and the system I saw last night could fill a few of those holes.

Technorati Tags:

DemoCamp

Comments (2)

Permalink

New MySQL Connector/Net 1.08 RC available

I just spotted a (long-awaited!) update to the MySQL Connector/Net - version 1.08 RC is now available for download. I was about to patch my own to resolve the “Character set ‘utf8′ is not supported” issue, but now I might be able to get away with the RC version - it’s probably safer than anything I’d patch, in any event.

So far things look good, with only one small fix required - this falls into the “I was getting away with it until now” category, but in a fit of copying and pasting, it looks like I had a few parameters in a query with the same name. It was working before 1.08, but it looks like a change (possibly this one) made the system a little bit more strict.

I’m going to keep the system under load for a day or so, and if all looks good, I’ll deploy it. At this point I’ll take the risk of an RC-related bug over the known character set error problem.

Technorati Tags:

MySQL

Comments (1)

Permalink

Reducing spam with Ruby and Thunderbird

I’ve been getting swamped with spam lately on the order of 300 messages a day, and I’ve nobody to blame but myself. See, I’ve had some of my domains for more than 5 years now, and back then, having a “catch-all” email setup was pretty cool - I didn’t have to worry about giving my friends an exact email address, and I could make “one-off” addresses easily for form signups that I wanted to track to see where future spam came from. Anything addressed to an arbitrary account @ thrustlabs.com would get
to me.

Of course, spammers win big in this scenario, and I’m getting hit with 7 or 8 emails at a time with the same subject addressed to various made-up accounts like “accounting@thrustlabs.com” and whatnot.

The solution’s obvious - shut off the catch-all, right? Unfortunately, I didn’t exactly keep track of the addresses I’ve given out over the years, so turning off catch-all could block something that’s actually important. Urgh.

Fortunately, I know just enough Ruby and just enough about Thunderbird’s mbox format to write something that’ll extract my email addresses from email stored in folders:

emails = {}
Dir['c:/documents and settings/your account/application data/thunderbird/profiles/**/*'].each { |file|
  if FileTest.size?(file) then
    mbox = File.new(file, "r")
    while(line = mbox.gets)
      emails[line.scan(/[A-Za-z0-9._]+@thrustlabs.com/)[0]] = 1
    end
    mbox.close
  end
}
emails.each_key {|email| puts email }

It might not be pretty, but it works for me (as always,it might destroy your computer, handle with caution, etc., etc.)

I took the output, edited out the spam-generated accounts, and set up explicit forwarding accounts for each of the addresses that were left, disabling catch-all at the same time. Once that takes effect (it’s a shared server, so there’s a lag), I can go through the rest of my spam and identify other troublesome addresses for other domains (I just did the two oldest, and thus biggest problem, domains to start). You know, assuming I didn’t do something stupid like block all my mail. Come to think
of it, that would be rather peaceful…

Technorati Tags: , ,

Ruby

Comments (0)

Permalink