Prototype (et al) in Greasemonkey

So, using Prototype in Greasemonkey is... awkward, at best.

You see, everything you do in GM Javascript is actually stored in this weird space called "unsafeWindow". (Clearly, I don't fully understand why.)

It also seems to be impossible to intrude on the basic elements (like Element itself) that PType wishes to.

Thus, you have to be sneaky: you cause the page to load your scripts. ...And yet, for reasons incomprehensible, you still access them in unsafeWindow. Even when events fire. ...Which, by the way, seems to be the only way to do it: events firing. You can't just natively "do stuff".

Disappointing... but work-around-able.

I think we can use this to help us Monkify some of our websites. My first target is Learnerweb, which is Usable But Obnoxious as-is.

Here's a script that causes a new <p> to appear on the cspabq page when you click pretty much anywhere under the header:

// ==UserScript==
// @name Monkeys. Greasy, greasy monkeys.
// @namespace CSP
// @description Testing Prototype and ilk in GM
// @include http://www.cspabq.org*
// ==/UserScript==

var scripts = [
'http://wiki.script.aculo.us/javascripts/prototype.js',
'http://wiki.script.aculo.us/javascripts/effects.js',
'http://wiki.script.aculo.us/javascripts/controls.js'
];
for (i in scripts) {
var script = document.createElement('script');
script.src = scripts[i];
document.getElementsByTagName('head')[0].appendChild(script);
}

window.addEventListener('load', function(event) {

$ = unsafeWindow['window'].$;
div = document.getElementById('content-main');
div.addEventListener('click', function(event) {
x = document.createElement('p');
x.innerHTML = "It is very greasy. You are likely to be eaten by a monkey.";
$('content-main').appendChild(x);
}, 'false');

}, 'false');

WinAMP

It is to my deepest chagrin that I admit WinAMP is too bloated for me, these days.

"If you can guess a landing spot on the moon, I suppose you can guess a cake!"

I've been using WinAmp since I was getting beat up in the high school locker room. I've been an avid follower, and was delighted when WinAMP was one of the first players to support OGG files (perhaps 85% of my collection is OGG these days).

In my anti-social nature (mentioned in the last post), I have taken to listening to music incessantly here at work. ...But my work machine is the most absolute of burger-sucking dogs, and when one works in such software as Visual dBase, Dreamweaver, Visual Studio, and--powers of the universe preserve us--Internet Explorer, one is bound to find bits leaking out of their little unprotected blocks and spilling onto the CPU, making a terrible mess and stinking of ozone.

WinAMP does not enjoy this anymore than I do. In fact, I believe it makes matters worse.

I don't like bloat. This is why I hate all Microsoft software. All of it: I haven't found a single counter-example. Everything is bloated. Hell, I would rather skip buying a CD than listen to sound examples in anything made by Real, that scum-bag sucking fat zombie mime fuckhole company. AOL is something to be approached with fallout gear and large, preferably long-range weapons.

Pardon me. Where was I?

I use XMMS at home. (On Linux.) I believe XMMS is perfect: it does what I want, it looks reasonably cool (winamp skins), it's free, and it's got a footprint on the scale of rodents. Small rodents. There is no "thinger", there is no internet-scouring script looking for album covers... even the built-in visualizations are limited to oscilloscopes and spectrum analyzers. And I don't have to go through six screen to install it. (Hell, I just enable it with a package manager, dammit: I never see a single dialog box!)

"I think if I were a spaceman, I wouldn't care if people believed in me or not."

So, I merrily resolved to install XMMS here at work and be done with it. Alas, I quickly discovered that there are no win32 binaries for XMMS.

Drat.

I begin scouring for another player, but am quickly assaulted by free-download sites that cause AdBlocker to groan under the pressure. I fear looking for bloat-free players in this manner will be fruitless.

As I said, 85% of my collection is in OGG format, so I choose instead to float on over to the Vorbis site and check our their recommended players. To my dismay, almost all of them are commercial bastardizations of freeware (much like WinAMP is, though I fear winamp is one of precious few companies that aren't really stepping on me when I download the free version of their software: almost no nagging, and no crippled features that I care about.)

Then I stumble upon Zinf. I've heard of it before, I think: I've probably passed over it in linux installs. (There's that "mindshare" thing, eh?) It's smaller than WinAMP, and just barely bigger than I think it should be (it's 1.7 Meg). I install.

Okay, so it's not sexy... but not hideous. It plays my OGGs. It's got a music manager that I don't particularly care for, but I start using it anyway: we'll kick the tires.

...And that's where I currently stand.

"Maybe I'm dreaming. My eyes are open, which means maybe I'm awake, dreaming I'm asleep. Or... or more likely, maybe I'm asleep, dreaming that I'm awake, wondering if I'm dreaming..."

So, if you haven't noticed, the quotes have been from Aleksi Virta's "...meets tortsi" album. ...One of the best albums ever, mind you. I'm listening to it now. Memory footprint? 14Megs. This is more than I expect, so I check WinAMP playing the same song, and I lose my breath when I see it's taking up a massive 44Meg! ...Eeep. Okay. So, for the next few weeks (?), I will be testing this Zinf thing, and seeing how it goes, because only time will tell.

Still, I lament the fact that I'm abandoning WinAMP. It used to be one of the only programs I really trusted. [sigh]

"An anti-American eagle? It's diabolical!"

Anti-social

I haven't posted lately, it's true. It's been an anti-social couple of months, and getting more so. I'm enjoying the introspection.

I had the idea of blogging about "becoming an artist", since that seems to be my aim, of late. And then I asked myself, "Why do you want to be an artist?"

Since then, I haven't come up with a good answer. Oh... I've had some ideas, but none of them are terribly motivating. Things boil down to a few salient points:

  • I like programming. Even if given the chance, I would not stop.
  • I don't like artists, on the whole... a few good souls, sure, but that's true everywhere. By and large, artists tend to be... broken people.
  • I am so not into self-marketing.
  • The money's worse than programming (with exceptions).
That said, none of these trains of thought have deterred me from doing what I'm doing. Namely, I'm drawing. A lot. I also spend a lot of time thinking about drawing, analyzing what I see. Last, and perhaps most copiously, I seek out art, judge it, and learn from the pieces I like most.

Tying that in to programming, I actually wrote a ruby script that scrapes Deviant Art and grabs "favourites" from all of the artists on one page of your own favourites page. (Think of them as meta-faves). It uses ActiveRecord to store some db information, Hpricot and open-uri for the scraping, and it's probably 120 lines. Fun to write.

I'm actually of the mind that my favourites on DA are remarkable works of art. The process has also taught me exactly where I want to focus my efforts. This is key. It breaks down into stages, as I see it:
  1. Draw, until I...
  2. Get some kind of tablet.
  3. Do "digital painting" until I...
  4. Get a strong foundation in form.
  5. Start rendering (3D).
  6. Move slowly into physical sculpture.
There are a few key points, here.

First, I love digital paintings. I love the colors, I love the textures: like paint, but less chaotic. It's what I want to do... for as long as it will sustain me. Brushes intimidate me. I don't like getting messy. Digital painting is my thing.

"But."

Sculpture is what I consider the height of "personal" art. (The subtext there is that I think there are cooler versions of collaborative art, but that's for another discussion.) If had to choose one thing, that's what I would focus on. But there are a few things keeping me from jumping right in. Most importantly, I don't think I have a strong enough concept of space and form. It's also a "slow" form of art, not as immediately gratifying as drawing or painting. It's also much harder to sell, takes up more space, and is otherwise less practical. ...But someday, I'll be able to work around all those things. Certainly computer modeling gets around most of those, and perhaps I'll dabble in it in the near future. But at the moment, I'm not confident enough: I haven't modeled in.. .oh my... has it really been over a decade?!? Pardon me while I go puke for a while.

Subject lines

It occurs to me that Subject lines are totally in the wrong place, when composing a message (they're appropriate at the top of a received message).

It's not until after you write your message that you truly have an appropriate idea for your subject line.

The subject should appear right before the "SEND" button.

A 1000 Blank White Cards Initial Migration for Rails

class FirstWhack < ActiveRecord::Migration
def self.up create_table :cards, :force=>true do |t|
t.column :title, :string, :null=>false # Name of the card. "Jumpin' Jesus on a Pogo-Stick"
t.column :img, :string # A fully-qualified URL or local filename. Null implies "blank"!
t.column :effect, :string # Psuedo-code. Ex: "modify 1 cards where target has tag 2" Optional
t.column :action, :string # Describe the effect. "Play on a blue card--change the image." Optional.
t.column :points, :integer, :null=>false, :default=>0
t.column :player_id, :integer # Current owner, null is discards
t.column :game_id, :integer, :null=>false
t.column :created_at, :datetime, :null=>false
t.column :created_by, :integer, :null=>false # fk to players
end
create_table :tags, :force=>true do |t|
t.column :name, :string, :null=>false
end
create_table :cards_tags, :force=>true do |t|
t.column :card_id, :integer, :null=>false
t.column :tag_id, :integer, :null=>false
t.column :player_id, :integer # Who created it? If null, it was auto-added (ex: "blank")
t.column :created_at, :datetime, :null=>false
end
create_table :players, :force=>true do |t|
t.column :name, :string, :null=>false, :limit=>128
t.column :born_on, :date, :null=>false # So we know their age (and birthday?) - play will be youngest -> oldest
t.column :email, :string # Notification of turns. Optional.
t.column :img, :string # Full URL or local filename. Optional.
end
# Apparantly we've got a Catch-22, here: I don't yet have a Player object. Hmmmn.
# jr = Player.create :name=>"Jeremy Rice", :born_on=>Date.civil(1974,8,7), :email => "jrice.blue@gmail.com"
create_table :players_tags, :force=>true do |t|
t.column :player_id, :integer, :null=>false
t.column :tag_id, :integer, :null=>false
end
create_table :games, :force=>true do |t|
t.column :name, :string, :null=>false # Name of the game: "Teh Interwebs is 4 p0rn///"
t.column :current_player, :integer # Null until the game starts. Fk to players.
t.column :turn_order_sort, :string, :limit=>4 # Null for ASC, otherwise "DESC".
t.column :created_at, :datetime
t.column :started_at, :datetime
end
create_table :games_players, :force=>true do |t|
t.column :player_id, :integer, :null=>false
t.column :game_id, :integer, :null=>false
t.column :ready_to_start_at, :datetime # Null until the player has created their first 5 cards.
t.column :joined_at, :datetime
end
# This will store each play in a game. Useful for undos, but might also produce a kind of history.
create_table :plays, :force=>true do |t|
t.column :player_id, :integer, :null=>false
t.column :game_id, :integer, :null=>false
t.column :card_id, :integer, :null=>false
t.column :comment, :text # Jibe from the player; optional.
t.column :targets, :text # Not yet sure how I'll store this, but it'll be an array of objects.
end
end

def self.down
drop_table :cards
drop_table :tags
drop_table :cards_tags
drop_table :players
drop_table :players_tags
drop_table :games
drop_table :games_players
drop_table :plays
end
end

Anger

Today's thought-in-the-shower was:

Angry → stupid.

For the most part, the word "angry" and its derivatives can be substituted for "stupid".

  • "I got stupid at my son last week."
  • "Obnoxious drivers make me stupid."
  • "9-11 make a lot of Americans stupid."
...Really, this makes sense. Biochemically, anger must be releasing some rather nasty hormones that interfere with logic.

Same with being horny. : ) ...which is another word that clearly maps to "stupid".

Speaking of which, it dawned on me that people who use "Men can't help themselves sometimes" as an excuse for why women must dress appropriately at all times is akin to arguing that no one should be offensive because they're at fault when people hit them.

Okay, that thought isn't stated elegantly. But I'm tired. ...I woke up with an idea to make Blank White Cards into a Rails app. I couldn't sleep: I had to draw out the ORM and some ideas on a mini-parsing language for the "actions" at the bottom of cards.

[sigh]

[insert some joke about geekery mapping to stupidity here]

Ubuntu, Here I Am

Done! Voila! I write this from Firefox within Ubuntu.

...Not quite a cakewalk. ...Much to my chagrin, the installation page has this "Please Wait" screen after handling your video card. This is highly unusual, in my experience, for a Linux app to do: usually such screens (and indeed, the REST of the installation) kindly tells you exactly what it is up to. So my assumption was that the process had crashed, after the "Please Wait, 6%" screen stayed up for 20 minutes. I tried twice more (changing some suspected settings), and got the same results.

But I grabbed my wife's laptop and dug into the Ubuntu install docs, and, lo, they explain that packages are installed on TTY4 during this process, so you can switch over to view them, if you care to.

The dialog should say as much. Harrumph.

Anyway, I'm off to run the additional installation pacakges... getting ruby, mysql, The GIMP, and whatever else strikes me as missing. There's also a bunch of Linux music apps to check out. ...Oh, and I'd like to grab WINE (though Ubuntu kindly set up a dual-boot system, so I don't need it).

Awesome. I'm glad I did this. Linux in under 24 hours, and without a CD drive. : )

Not bad.

Ubuntu, Round 2

The thumb drive image was corrupt.

I don't know why, but after I copy the boot sector image to /def/sdf, it ends up changing the size of the volume to 16 Meg. Weird.

After re-trying that in vain a couple of times, I decided to follow the long way around, which involved installing syslinux, running that (there's a win32/ subdir with an EXE in it, takes a drive letter as an arg), and then copy "files from the Ubuntu archives" to the disk. Archives? WHAT archives?!? No clue.

[dig dig]

Oh, you mean THESE archives. Okay. ...But where the heck ARE They?!? No clue.

[poke poke]

It looks like two of the files are available, but the other one (which I guess is optional, really) isn't there. Hmmn. It occurs to me that the image that I unpacked (and which mucked up the format of my stick) has these files on them. Perhaps I'll grab another (small) stick and unload the image onto it, copy the files to my HD, and yada yada. Sure... let's do that and be safe. -Ish.

The smaller stick came up with a different drive letter (why?), but was still mounted on /dsv/sdf, so I copied the image over to it, ejected it, put it back in, noted that it, too, was reduced to 16 Meg, and copied all the files over to the disk. So far, so good.

Format the small stick (to bring it back to 64 Meg, grr), and eject it. Pop the big 'un back in. Copy all the files over to it. Whee. I peek at the file that was missing from the archives and see that, yeah, I probably wanted that... it seems to have prompts and what-not, probably making the install easier. I hope. There's a note on the Ubuntu site about how this file should contain a line saying "default vmlinuz", but I guess this is bullshit: the default directive (install) seems to point to a viable set of commands. I trust in the file as-is. Last step: copy the ISO image over to the (now big) thumb-drive. This takes 4 minutes: it's a big one.

And now it's time to reboot.

If you don't hear from me in 4 hours, call the President.

Linux

So, I did research on Linux tonight, and I'm edgy about the whole thing. I wondered what I would really be gaining, besides "sticking it to Windows".

I suppose I'd be learning lots of new geekery. That's worth something.

Regardless, I decided to go ahead and try out Ubuntu in the short-term, perhaps switching to SuSE if I decide I really can live with Linux and no Windows. It couldn't hurt too much, right?


My CD-drive is fried, so I can't write the ISO image to a disk and boot with that. I do have a handy 1Gig thumb drive, however... but the instructions say that you need to build the thumbdrive with a Linux system. Hmmmn.

I thought perhaps I could cheat with Cygwin, which I have installed (another reason I'm feeling odd about the move)... but it turns out you can't redirect STDOUT to a directory. No worries, I'll just go... to... /dev... wha?!? There's no /dev in cygwin.

[dig dig] Okay, there is /dev, but for some unexplainable reason, they hide it from you. You can still type /dev/sda and get to the harddrive, for example. Weird. But there's no /dev dir, and you can't see everything that's there. They do, however, point to a utility that makes this possible. I install. I run. /dev appears.

And it's huge. Nothing is clearly the USB drive... and I'm not sure how to find the bloody thing.

I decide to start heading each of the mount points, and I find that, indeed, /dev/sdf seems to be accessing by thumbdrive (by virtue of the fact that the thing blinks as I head it). Neat.

I zcat the boot image to the drive, I copy the ISO image... and... OH MY GOD, it's Saturday!

Time for sleep. Plenty of time for this over the weekend: the wife is away, so I'll be bored, anyway.

Fear and trepidation... mixed with perverse glee. We shall see.

Open Source

A very interesting post over at O'Reilly has me thinking about Open Source. The bloke asks what the "most important" Open projects currently are.

My answer (search for "JRice") complains that the question wasn't very clear. ...Still, it's a heart-warming subject, and I loved the thought of it so much I thought I would make a list of projects that I have enjoyed and appreciated over the years (in order that they occur to me):

  • FreeBSD
  • Fedora
  • RedHat Linux
  • GNome, KDE, Enlightenment
  • Perl, Ruby, Python
  • vim (and vi)
  • MySQL
  • pine
  • The GIMP
  • WAMP (Apache, specifically)
  • MediaWiki
  • TWiki (well, I do think MediaWiki is far superior, but... I did use this...)
  • imageMagick
  • GCC (of course!)
  • Wikipedia (not all things "Open" are programs!)
  • OGG Voribis
  • tcsh and bash
  • Mozilla (Firefox)
  • Firefox plugins... particularly FireBug (!), AdBlock, and SessionManager
  • Eclipse / RadRails
  • Java
  • OpenOffice
  • PGP (!)
  • GhostReader
  • YAML
  • Wine :)
  • Jabber
  • SSH (and PuTTY)
...In making this list, I'm reminded of how incredibly rich the Open Source world is, and I'm more than a bit ashamed to think that I hardly run half of these apps today, in lieu of their commercial counterparts. It's making me seriously re-consider scrapping the whole Windows thing on my home machine. Screw.

...There are really two big reasons that I haven't already done this: music and games. But I think it has come time to reconsider this decision. Music is a money pit, and games could easily be switched over to a nice new PS3, which I'd like to get sometime this year, anyway.

And, hey: I have a Windows license... I can just run Wine, when desperate!

I going to do it.

...And, yes, I know I have been profoundly silent, of late. It's mostly because I'm busy on 43 things.

XMas

So, Chrsms. The greedy version.

My main gift was a very expensive watch, from my wife. Geek's watch!

The only gift I got from my wishlist was a photography book, which has (20 pages in) reminded me how much I suck as a photographer. ; )

I got a couple of neat display-type items: a chinese (I think) teapot with two cups, and a very cool blue bottle of sake. Nice.

I got an expansion (The Tower ) for Carcassonne. Cool.

I got some money, which we're going to use for a trip... either Vegas (which I would like for Blue Man, Cirque, food, and art), or northern NM (which I would like for the rest... and art).

I got some other trinkets, but they're all relatively minor.

I bought myself HL2: Episode One. Already beat it. Loved it.

The vacation itself was nice and relaxing: we played games, including one that I need: NAQ. We saw Happy Feet. Meh. (Entertaining, sure, but not nearly as good as Pixar films.) We went to the beach, once, where I visited a few nice galleries and a very cool rocks/minerals store. I read The Chronicles of Amber (well, the first half). I worked on my character for our Amber game. We watched a movie and a few episodes of Myth Busters around the house. It was quiet.

Enjoyable.

Visual Studio

As I've mentioned, we use Visual Studio to write C#, here at work.

Recently, MS released a " service pack" for VStudio. According to their site, "fixes in this Service Pack include stability, perfomance and security enhancements made in many areas of the product."

It's
431.7 MB.

That just doesn't sound like bug fixes to me.

...I'm just sayin'...