I'm not happy with this blog, I'm not sure why I'm not happy with this blog, but I figure since it's 2010 I should get a tumblog.
http://jes5199.tumblr.com
Saturday, January 9, 2010
Monday, August 17, 2009
ruby's sprintf considered harmful
irb(main):001:0> sprintf("%d", "01")
=> "1"
irb(main):002:0> sprintf("%d", "02")
=> "2"
irb(main):003:0> sprintf("%d", "03")
=> "3"
irb(main):004:0> sprintf("%d", "04")
=> "4"
irb(main):005:0> sprintf("%d", "05")
=> "5"
irb(main):006:0> sprintf("%d", "06")
=> "6"
irb(main):007:0> sprintf("%d", "07")
=> "7"
irb(main):008:0> sprintf("%d", "08")
ArgumentError: invalid value for Integer: "08"
from (irb):8:in `sprintf'
from (irb):8
irb(main):009:0> sprintf("%d", "09")
ArgumentError: invalid value for Integer: "09"
from (irb):9:in `sprintf'
from (irb):9
irb(main):010:0> sprintf("%d", "10")
=> "10"
irb(main):011:0> sprintf("%d", "11")
=> "11"
irb(main):012:0> sprintf("%d", "12")
=> "12"
Of course, this bug's been known for years.
Wednesday, May 6, 2009
unexpectedly dangerous commands
rsync! unexpectedly dangerous!
oops, I should have specified a sub-directory.
and then...
ssh no longer accepts my key.
because rsync's "-a" flag changed the ownership of the target directory
rsync -a . root@pom:~
sending incremental file list
./
.acl
README.txt
oops, I should have specified a sub-directory.
and then...
ssh root@pom -i ~/.ssh/id-key
root@pom's password:
ssh no longer accepts my key.
because rsync's "-a" flag changed the ownership of the target directory
Thursday, April 2, 2009
(rails) naming chained named scopes
Is nobody doing this?
Rails named scopes are chainable, right? Here's a traditional example:
and then you can ask for Story.popular.hilarious.all
But it didn't take much complexity for me to want to make a named scopes that represented a chain of named scopes.
Here's my first draft of a solution:
It's a little ugly, but it seems to work.
Story.popular_and_hilarious.all.should == Story.popular.hilarious.all
Rails named scopes are chainable, right? Here's a traditional example:
class Story < ActiveRecord::Base
named_scope :hilarious, :conditions => ["type = ?","comedy"]
named_scope :popular, :conditions => ["popularity_level > ?", 3]
end
and then you can ask for Story.popular.hilarious.all
But it didn't take much complexity for me to want to make a named scopes that represented a chain of named scopes.
Here's my first draft of a solution:
named_scope :hilarious_and_popular, lambda{ self.hilarious.popular.scope(:find) }
It's a little ugly, but it seems to work.
Story.popular_and_hilarious.all.should == Story.popular.hilarious.all
Monday, March 16, 2009
TheSans
The guy who developed Inconsolata namechecked TheSans
And that piqued my curiosity. After a few days of hunting, I found a source that could get me the font for less than the list price of $Ridiculous
Even though it was explicitly designed for programming, it's a little funny looking. And the zeros aren't dotted or crossed.
in VIM
in Gnome Terminal
I was particularly struck by the beauty of Luc(as) de Groot's Consolas, which is his monospaced design for Microsoft's upcoming Vista release. This font, similar to his earlier TheSansMono, demonstrated clearly to me that monospaced fonts do not have to suck.‡
And that piqued my curiosity. After a few days of hunting, I found a source that could get me the font for less than the list price of $Ridiculous
Even though it was explicitly designed for programming, it's a little funny looking. And the zeros aren't dotted or crossed.
in VIM
in Gnome Terminal
anti-aliasing nightmare on debian
Debian mysteriously turned on font-anti-aliasing when I upgraded my laptop a few days ago. I guess that's fine, but suddenly my terminal got completely unreadable.
before
after
I thought about turning it antialiasing off -- and I still may -- but it occurred to me that I could probably do better.
I asked around, and I found a few shootouts, including Jeff Atwood's, but none for my exact setup.
The problem is, Linux/X11's font renderer isn't really ClearType. Also, different applications seem to render the same font different ways: VIM and Gnome Terminal sometimes show the same character in the same font in a dramatically different way.
Now I've got a handful of beautiful monospace fonts, but I can't seem to decide which to use. I'll post some examples here, as I get time to make screenshots.
So far, I've got:
I don't have Monoco or Pragmata, but maybe I'll find them later.
before
after
I thought about turning it antialiasing off -- and I still may -- but it occurred to me that I could probably do better.
I asked around, and I found a few shootouts, including Jeff Atwood's, but none for my exact setup.
The problem is, Linux/X11's font renderer isn't really ClearType. Also, different applications seem to render the same font different ways: VIM and Gnome Terminal sometimes show the same character in the same font in a dramatically different way.
Now I've got a handful of beautiful monospace fonts, but I can't seem to decide which to use. I'll post some examples here, as I get time to make screenshots.
So far, I've got:
- Andale Mono
- Consolas
- Consolas
- DejaVu Sans
- Inconsolata
- TheSans Mono
- Bitstream Vera
I don't have Monoco or Pragmata, but maybe I'll find them later.
Wednesday, February 18, 2009
Rails 2.2.2 is a lemon
There's one bug that makes my life miserable in all sorts of ways. It's the Catch-22 that you often can't run rake tasks if any of your models fail to compile.
It seems to be a bit of a heisenbug:
http://rails.lighthouseapp.com/projects/8994/tickets/1548-gem-tasks-fail-when-cache_classestrue
http://rails.lighthouseapp.com/projects/8994/tickets/802-eager-load-application-classes-can-block-migration
http://www.redmine.org/issues/show/2441
I've seen it bite me:
Gaaah.
It seems to be a bit of a heisenbug:
http://rails.lighthouseapp.com/projects/8994/tickets/1548-gem-tasks-fail-when-cache_classestrue
http://rails.lighthouseapp.com/projects/8994/tickets/802-eager-load-application-classes-can-block-migration
http://www.redmine.org/issues/show/2441
I've seen it bite me:
- trying to migrate up fields in the database, while a model was trying to call "alias" on the field
- trying to automatically install a gem dependency, including while a model was trying to mixin a module from that gem
- trying to run specs in a plugin when the app it was plugged into had syntax errors in a model
Gaaah.
Subscribe to:
Posts (Atom)