General


I just realized the benefit of something I saw a while ago in a Rails ticket. It is mostly about acts_as_vertical, which is cool and has its uses, but what I’m talking about now is the dynamic StylesheetsController. The way it works in the ticket is that it renders stylesheet based on database values and caches the resulting CSS file.

For CSS this is sort of a novelty until you really become a nazi about the one-place-for-any-given-piece-of-information rule as espoused by the Pragmatic Programmers. When reading about the holy grail of 3-column layout at A List Apart, it struck me that the CSS he’d written, while quite simple, encoded the same pieces of information multiple times - namely widths and padding.

My solution was to reinvent the StylesheetController, which I only later realized I’d seen before. My version looks like this:

class StylesheetsController < ApplicationController
  caches_page :content

  def content
    headers['Content-Type'] = 'text/css'
    render :action => params[:name]
  end
end

It requires a route that looks like this:

map.connect 'stylesheets/:name', :controller => 'stylesheets', :action => 'content'

Now move your style.css from /public/stylesheets to app/views/stylesheets and rename it style.css.rhtml. Not the prettiest thing ever, but without a new template extension that’s what we have.

Perhaps more important is the realization that this works just as well for javascript files. Now I can use all the Rails helper goodness to construct my static javascript files! How awesome is that? Why hello visual_effect. Hello remote_function.

In case you’re interested, here’s my style.css.rhtml from the article:

< %
right  = {:width => 130, :padding => {:horizontal => 10}}
left   = {:width => 180, :padding => {:horizontal => 10}}
center = {:padding => {:vertical => 10, :horizontal => 20}}
[right, left, center].each do |column|
  column[:full_width] = column[:width] + 2 * (column[:padding][:horizontal] || 0) rescue 0
  column[:padding] = {:horizontal => 0, :vertical => 0}.merge(column[:padding])
end
-%>
body {
  min-width: < %= 2 * (left[:full_width] + 2 * center[:padding][:horizontal]) + right[:full_width] %>px;
}
#container {
  padding-left: < %= left[:full_width] %>px;
  padding-right: < %= right[:full_width] + 2 * center[:padding][:horizontal] %>px;
}
#container .column {
  position: relative;
  float: left;
}
#center {
  padding: < %= center[:padding][:vertical] %>px < %= center[:padding][:horizontal] %>px;
  width: 100%;
}
#left {
  width: < %= left[:width] %>px;
  padding: < %= left[:padding][:vertical] %>px < %= left[:padding][:horizontal] %>px;
  right: < %= left[:full_width] + 2 * center[:padding][:horizontal] %>px;
  margin-left: -100%;
}
#right {
  width: < %= right[:width] %>px;
  padding: < %= right[:padding][:vertical] %>px < %= right[:padding][:horizontal] %>px;
  margin-right: -< %= right[:full_width] + 2 * center[:padding][:horizontal] %>px;
}
#footer {
  clear: both;
}

/*** IE Fix ***/
* html #left {
  left: < %= right[:full_width] %>px;
}

The iPod nano that Kelly bought me has come in quite handy. I use it every day now when riding to and from work, which is forcing me to get in shape, albeit slowly.

It occurred to me while riding today that using the iPod in that setting is actually quite nice. While some people complain that the ear buds don’t keep out enough external noise, this is a benefit while riding the bike. I want to be able to hear cars that are coming and have music as a background.

The second benefit of the iPod while biking is that it keeps my ears warm. I know the ear buds don’t cover my ears, but they do block the wind from getting inside my ears, which is the only part that’s at all sensitive.

Mostly I just put it on a random shuffle, but today I played Matt Costa’s Songs We Sing, and that was quite nice.

The problems I have with biking are mostly clothing related. My pants keep getting caught and torn by the gear mechanism - not good. I think I need some biking pants. Also, I’ve been wearing T-Shirts to work (par for the course at my job) and they do a not-so-good job at keeping the wind from making me cold. I tried wearing a normal light jacket, but it just made me sweat. Biking shirt? Dunno. I also need some shoes with clips and no or recessed laces. There’s another guy at work that wears the whole setup, so I’ll probably ask him where he got his stuff.

And here I thought biking to work would be easier than dealing with a car. :)

In reality, it is, it’s just not trouble-free. But cheaper plus 50 min exercise per day is a pretty good deal, so I’ll take it.

Technorati Tags: , ,

My second patch to RoR involves porting the behavior.js file written by Ben Nolan over to prototype with Ruby helpers. I’ll post back here with any additional info.

DMCA, meet your twin brother, the DCPA. This time they would like to prevent us from doing anything that could even potentially be used to put an audio recording out into the world unencumbered.

What are the ramifications of this law? An Ars article seems to think that it would prevent all manner of fair use:

The broadcast flag is embedded in the signal like a special tag that defines the content’s terms of use, while the secure moving technology acts as a sort of DRM wrapper/sandbox for the content that ensures that any (compliant) playback device not only respects the restrictions dictated by the broadcast flag but also does absolutely nothing novel or unexpected with the content that the broadcast flag’s terms did not or could not anticipate.

Is it an accurate deciphering of the legalese? From what I can tell, it is. I don’t want it to be, because it seems that it’s a horrible thing to enact into law, but that’s what I get out of it.

For me it comes down to a simple question: is it the government’s business to regulate the music, movie, and other related industries? Let’s see what happens on the two extremes:

The government does not regulate them at all

In this scenario, there are no restrictions on what a “playback device” can, should, or must do.

Pros

  • There are no enforced regulations on playback device manufacturers, allowing them to produce a product without a legal team (or at least a small one), saving money for them and their customers
  • This gives consumers choice in how they access their content. If they wish to purchase a playback device that is laden with DRM, they can. If they wish to buy one without DRM, they can

Cons

  • This would make it easier for the casual music pirate to copy, distribute, and acquire music - arguably a loss for the music industry, despite the possibility that it could actually spur interest in new and otherwise untouched artists
  • There may be very little incentive for playback device manufacturers to incorporate DRM into their systems

The government regulates all playback devices

In this scenario, the government dictates that all playback devices created from now on must obey the Broadcast flag embedded in some digital media, which can arbitrarily limit what can be done with that media

Pros

  • As a pro for the content industries, this allows them to force playback devices to be compliant with their DRM, possibly growing their industries and creating more jobs etc
  • Casual piracy may shrink down to a very small size, though “professional” pirates will find a way around it

Cons

  • This is an added expense for all playback device manufacturers, who will pass the cost onto the consumer
  • Consumers may be confused and frustrated by the restrictions on their content, which they paid for and feel they should be able to use however they like

I believe that the government does not have adequate cause to regulate these industries based on the possible benefits to society as a whole. Not only would the be violating individual rights (those of the playback device manufacturers), but this system may actually lead to a decrease in consumer spending in the affected industries, producing an overall negative economic effect.

That one kid

There’s always that one kid who has to ruin the monkey bars for everyone else by falling off of them and breaking his arm after doing something stupid. Pirates may be doing something stupid, but should we all be forced to live in DRM chains as a result? No. Unfortunately our government has a recent track record of stomping on individual rights in the name of whatever they’re calling the greater good these days (the War on Terror; the Liberation of Iraq; the Protection of our Children).

Technorati Tags: , ,

I found this awesome application for Mac/Windows/Linux that uses a LAN to control another machine using the same keyboard and mouse, but with the video still going to the regular monitor. I’m using it right now from my work PC to control my PowerBook to type this blog entry. It kicks ass! Mapping the control keys over was a little weird, but it works well enough. Imagine when I actually get a Mac at work!

You can find the application at its Sourceforge homepage.

Technorati Tags: , ,

I finally got internet. It occurred to me that I don’t actually need a technician to come and set it up. I have all the supplies and I am quite capable of dealing with stuff myself - just activate the service! I told Cox as much, and they obliged.

Now I can record all the things that have been going on with my apartment and at work. It’s the middle of my second week! Things have been going fairly well. Last Friday there was a planning meeting (happens every two weeks) where I got assigned about four tasks, none of which are super-hard, and I was set up to pair (read: work with) on them with an established guy, so I’ve got a fairly light load. Six seems to be about the norm.

Most of the things I’ve been working on have been moderately interesting. I pointed out a way to cut certain parts of the code in half, which we’ll probably start working on next iteration (two-week cycle of development). Some of the changes I’ve had to make have been, in my opinion, stupid. Overall it’s been good. The people I work with are nice, and about half of them play ping pong, and all that do are better than I am. One of the guys, Kip, has lots of songs on his computer and I can stream them on mine through iTunes. He has good taste, and it includes “Plans” (Death Cab for Cutie), whose lead singer I first heard in Such Great Heights from the album “Give Up” by The Postal Service. Coloration and linkage courtesy of ecto, my blog editor for Mac OS X.

And speaking of OS X, it now runs on Intel! Really! But only a MacIntel. Apple unveiled a new iMac and a new PowerBook dubbed the MacBook Pro… ehm, not such a good name, I think. So the nomenclature goes like this?

  • iMac G5 => iMac
  • PowerMac => Mac
  • iBook => MacBook
  • PowerBook => MacBook Pro

This is as suggested elsewhere on the internet, and it seems accurate, though I think having the PowerMac become just the “Mac” would be too ambiguous. I say that I have a Mac, but I mean my PowerBook, not a desktop monster. Mac Pro then? Who knows?

Despite the bad name, I like the MacBook Pro. It has an iSight built-in, it is one inch thick, it’s sexy, it has the illuminated keyboard, side-ports, and a new magnetic power cord. “Magnetic?”, you ask? Yes. And it’s a darn good thing too, as my last power adapter suffered a cruel death at the legs of Sarah and my PowerBook’s power port is, well, slightly off now. The magnetic one would just come right out when it gets tugged too hard. At least that’s the theory. They don’t ship until February.

Oh, and it will be able to run Windows (though from what I’ve heard XP may be a challenge, though Vista should work fine). I’m not sure that’s a big selling point for me, personally, but I’ll sure as hell use it as a selling point for others (yes, that includes you mom).

My apartment is a mess right now. I took (almost) everything out of the boxes on Sunday and tried to put it all away. There were not enough hours in the day, nor could I work up the motivation after work the last few days, so there’s lots of stuff still strewn about. Getting internet has lifted my spirits some, so I may conquer some of the task again tonight. Guess that means Sarah’s gonna help me with it.

As promised, a few pictures: work and apartment.

Technorati Tags: , , ,

There are a few new (to me) AppleGeeks comics that are pretty funny - one more Get a Mac and one about the FSM.

Work is going well. Today was the first day I rode my (new) bike to work, and I rode it back in the dark (with the light from Julie) and I didn’t die. Right now I’m siphoning bandwidth off an unsuspecting neighbor, probably named Shawn. When I get internet, I’ll post more, I promise. Until then…

Thanks Shawn!

It’s my third day, and I have no internet access at home yet, so I haven’t posted anything about my new job or my new apartment. I have some spare time right now so I’m gonna write about it.

First of all…

Thanks for the help

Kelly (and Fancy) helped me a lot with buying stuff and setting up things in my apartment. She spent two days with me driving around, spending lots of money, opening things up and putting them where they ought to go in my place. This saved me a ton of time, and I really appreciate it.

Mom bought me much of the stuff that Kelly set up for me, especially kitchen cleaning supplies, dishes, a water heater, etc. Susan bought me a set of pots and pans, knives, and a cutting board. I haven’t used the pots and pans yet, but the knives are awesome (very sharp with good handles) and the cutting board is light and easy to clean.

Todd got me an eBay gift certificate, which I’ve so far used to buy two phones - one for Kelly and one for me.

Grams and Grandpa Black bought me a nice sweater and a cook book that seems well suited to me: each recipe has only three steps and the ingredients are all pictured on the sides. Looks very handy.

Sarah bought me a sweater that I wore on my first day of work.

Thanks to everyone else who helped make the move easier.

The Apartment

The new place is pretty usable now that Kelly set everything up. The hot water is quick to come out. The carpets, walls, etc are all clean. The neighbors are fairly quiet. The floor creaks in a few spots, which is kind of annoying.

I’m trying to figure out how to place my (sparse) furniture and other items. This morning I was considering where to put the receiver and speakers. They’ll mainly be used for music, I imagine, and they should be fairly close to the Airport Express so that I can stream music from my computer. The other use may be for watching movies, depending on how I set up my desktop PC.

There are no chairs or couches, so everything is fairly open. Today I’m going to see about Ikea furniture etc. I’m thinking about having a few chairs and a coffee table of sorts.

Pictures are forthcoming. Check back on this post later.

The Office

My office is about four miles from my apartment, which translates into about 15 minutes on the bus. This will serve quite well until I get a bike and for those rainy or lazy days.

Everyone here is fairly friendly, and many of them play ping-pong in a room shared by some server racks and a ping-pong table. The break room has a foosball table, which I have yet to play on. My cubicle is shared with a guy named Jack, who is Chinese (?) and also likes to play ping-pong. I haven’t played him, but from talking to others in the office he is quite good. So, apparently, is my supervisor. I’ve got some catching up to do.

I have a PC (so sad), but it’s a Dell so at least it’s reliable. There are others here who have macs, but there is a limited supply, so it may be a while before I get one. This is a Java place, so we use (mostly) IDEA and WebLogic. It’s a fairly different environment from any I’ve seen before, and it’s taking some getting used to. IDEA has some cool features reminiscent of TextMate, but it’s a tad slow.

I’ve fixed two bugs so far, and figuring out how to do it has helped me learn the system’s structure a bit. I miss prototype, as the JS stuff they have is kinda pathetic.

The break room has coffee, tea, and soda for free. I’m limiting myself to about 1-2 sodas a week, probably. I’d rather have water in most circumstances anyway. Today there is going to be a welcome lunch for me and the other new guy, Jeff, who works in web marketing. It’s a Chinese buffet.

I don’t have pictures yet because I don’t have any way of uploading them at home, but I’ll post them here when I do have them.

It seems like any jackass with a computer can send millions and millions of pieces of spam, causing their victims to waste their time sorting out the good mail - or, in this case, blog comments - from the bad. I’ll show you an example of one of 341 that I just cleaned out:

I must say i got here by mistake, but now i know it’s destiny. Great site! Small Cards is always Red Round: http://ranchero.com/netnewswire/ , Kill Plane is very good Grass right Chair will Increase Girl without any questions , Full, Central, Superb nothing comparative to Bad Round can Con Player

This is representative of 99% of the ones I got.

Compliment

This is always some sort of compliment. I chose the one above because it was so absurd.

Comparative Site

This is a semi-random phrase that indicates (via ‘:’) some site that a user might normally go to, chosen at random. The example above is for NetNewsWire, a Mac news reader.

Sponsored Links

I’ve taken the links out of them, but some of the words here would be used as links, mostly to online casinos or porn sites. Here the words are set up in a way that is seemingly innocuous (to a computer), but is nonsensical to us. Notice that they use the vocabulary of a casino.

How obnoxious.

Technorati Tags: ,

Work starts tomorrow. Kelly is going to drive me to Santa Barbara, help me set up stuff in my apartment, then drive me to work tomorrow. I still don’t have a bike, partly because the Holiday Season hasn’t allowed me much free time recently.

The ones that I liked fairly well were:

  • Trek 1500 SCR: $1099
  • Specialized Allez Elite: $1300
  • Cannondale Sprint Caad8: $1250

I’ll be mainly using it to commute to work and for leisure. Any ideas on which I should get?

Technorati Tags: ,

« Previous PageNext Page »