2015-05-07
2010-03-25
New fb Release
2010-01-31
Marshalling MongoMapper Documents
def new
@user = flash[:user] || User.new
end
def create
@user = User.new params[:user]
if @user.save
redirect_to user_path(@user)
else
flash[:user] = @user
redirect_to new_user_path
end
end
TypeError: singleton can't be dumped
Some chain of references from the model evidently connects it to a singleton object. MongoMapper is still under heavy development, so I'm confident at some point this will be resolved, but meanwhile the following monkey patch appears to do the trick: module MongoMapper
module Document
def marshal_dump
instance_variable_names.inject({}) { |m, name| m[name] = instance_variable_get(name); m }
end
def marshal_load(values)
values.each_pair { |k, v| instance_variable_set(k, v) }
end
end
end
I stuck this code in a file called mongo_marshalling.rb in config/initializers. 2009-12-07
Workstation NFS Mounts Considered Evil
It wasn't always thus.
It didn't matter which client I used: isql, Ruby, FlameRobin. It didn't matter if I connected from the local machine or a different workstation.
I tried installing various builds: Superserver, Classic, 64-bit and the experimental 32/64-bit build.
I used dtruss (that's an strace-like interface to dtrace for the Mac) on isql to see where it was hanging.
I watched CPU and memory and network usage.
Finally I installed Wireshark and started watching network traffic while connecting to the database. There it was. Every time, while waiting for the client to connect to the database, there was a flurry of mdns packets.
mdns? Multicast DNS. What Apple started calling Bonjour right after Tibco Software beat them to the Rendezvous.
Those flurry of packets were all attempting to lookup alpha.local. Alpha was the name of a CentOS test VM I occasionally ran in VMware Fusion. Evidently I was only allowed to connect to Firebird after first trying to resolve alpha.local (and timing out) a few times. I tried putting alpha.local in /etc/hosts. That lengthened connection times to a minute and a half or so.
Starting up the VM caused the name to resolve quickly and my Firebird connections to proceed at full speed. Shutting down the VM reverted connection times to 20 seconds again.
I nuked the VM from VMware. Still no dice.
Grepping around in various DNS-related files for alpha.local, I found the clue I needed. A forgotten NFS mount I had once used to edit a website on the VM using TextMate.
Disk Utility -> File -> NFS Mounts. Kill it. Dead. All better!
Firebird enumerates NFS mounts to ensure the database being attached does not reside on a network share, because NFS file locking is unreliable.
Next time I think I'll use Transmit if I must edit the site with TextMate. Otherwise I'll just use Vim.
2008-11-23
2008-10-21
Chess Clock for iPhone
Ready/Paused
In Play (white to move)
Time Expired
Setup Screen
2008-04-27
Looking for the Mouse
Great article by Clay Shirky.
I avoided Twitter for a long time, thinking it was the level of hell below Facebook. I gave it a second look because some guys I respect said they were on it.
After nearly three weeks, my conclusion is that yes, it is another time sink and source of interruptions, joining e-mail, IM’s and blogs, and yes there is a certain amount of drivel, like “I’m eating a cheese sandwich.” But, it’s an interactive time sink and the people I follow are, for the most part, interesting people doing interesting things. Their default activity is not sitting on the couch watching the boob tube. They are traveling, writing code, making presentations at conferences and user groups, taking pictures, playing chess, reading interesting articles and sharing them.
Of course there have always been people who never went into a TV stupor. My parents didn’t have a TV when I was growing up, forcing me outdoors during the day and into books at night, but the common understanding was that I was deprived—disconnected from The Source of popular culture. Now, the feeling is that TV is tired and it is the alternate activities that are hip.
