November 2010
2 posts
Database views and models in Rails 3
Rails models can have a database view instead of a table, if you so desire. Just follow the pluralize convention: What won’t work out of the box is preloading associations, since views (at least in Postgres) don’t have primary keys. This means Rails can’t tell rows apart when calling #uniq on an array of results. Solution: define #hash and #eql? (actually, either one seems to...
Nov 10th
1 note
Nov 6th
June 2010
5 posts
Jun 23rd
Jun 21st
ObjectSpace::define_finalizer
# So, I just discovered ObjectSpace::define_finalizer a = "hello" ObjectSpace.define_finalizer(a, proc { puts "I die!"} ) # Let's eliminate the reference to our string. a = 1 # And garbage collect! GC.start # => I die! # Pretty neat! syntax highlighted by Code2HTML, v. 0.9.1
Jun 4th
Jun 1st
dictionary.rb
Macruby only, since we’re accessing Mac OS X’s dictionary services. For Macruby 0.6, /System/Library/Frameworks/CoreServices.framework/Frameworks/DictionaryServices.framework/Resources/BridgeSupport/DictionaryServices.bridgesupport needs to be edited. On line 20, change: <retval type64='{?=qq}' type='{?=ii}'/> to <retval type64='{_CFRange=qq}'...
Jun 1st
May 2010
1 post
Maglev and abort_transaction-ing on every request
The code: Running vanilla Rack::Lobster: Requests per second: 425.62 [#/sec] (mean) Time per request: 2.350 [ms] (mean) Time per request: 2.350 [ms] (mean, across all concurrent requests) Running Rack::Lobster and Maglev#abort_transaction-ing with each request: Requests per second: 404.73 [#/sec] (mean) Time per request: 2.471 [ms] (mean) Time per request: ...
May 19th
August 2009
2 posts
Rack::Probing
It’s been a fun summer, but with its end comes the wind down of Google’s Summer of Code ‘09 (GSoC). Sounds like an opportunity to talk about Rack::Probe. Rack::Probe packages a set of Dtrace probes for web applications in an easy-to-use and easy-to-love Rack middleware. Installation is a quick gem install rack-probe away. As part of my GSoC project, Rack::Probe provides the...
Aug 21st
Aug 19th
July 2009
1 post
Jul 17th
1 note
June 2009
16 posts
Jun 23rd
git push origin master
Finally pushed some code onto http://github.com/ecin/dtracy with a horribly uninformative README for starters. Won’t stay that way for long. Explanatory post coming up next!
Jun 19th
Sidetracked
I swear it was 1am two minutes ago… So you suffer from ADD? Can’t focus on your work for more than a split second? Be embarrassed no longer, for now you have tenplustwo 1 (must run Mac OS X and growl to be eligible, no purchase necessary, void where prohibited): ten + two. Get it? Ain’t Ruby neat? Funny thing is, I spent a good two hours writing that2. Effort better be...
Jun 18th
For the record, my mornings seem to be starting off at around midnight. More to come in the following hours.
Jun 18th
Dancing Threads with Thin and Ebb
I’ve been cleaning up the code for a release later in the day, pondering over whether it’d be worth it to take Sinatra out of the picture and go pure Rack… doubtful. But enough of that! Consider the JSONP long-polling problem. In order to keep a user’s experience constantly fresh with new content, we set up a javascript function that opens a request to the web server, and...
Jun 17th
dtrace.c explained →
An accompanying handbook to understanding what ruby-dtrace is doing.
Jun 14th
epic_sleep()
In trying to package up the Sinatra app that serves the visualization code with some Dtrace-probe-consuming code, I came across a fun realization: running an instance of Dtrace::Consumer in a thread alongside the app doesn’t make for a fun evening. In this case, the perpetrator wears the mask of Dtrace::Consumer#consume. Let me be more specific in pointing out where the banana peel has...
Jun 14th
Jun 12th
Jun 9th
Safari 4: fast, doesn't like overwritting methods
With its javascript debugger, Safari 4 gets to stand up against Firefox and its Firebug extension as a good browser for development. However, it’s a picky browser. Doesn’t like functions that could pretend to be others (taken from processing.js, line 370): So far I’m merely hacking it along by replacing import with importer in both instances. Seems to work thus far. Luckily,...
Jun 9th
Jun 3rd
Let's catch up
There are some things we need to discuss. Sit down for a moment, will ya? On architecture Take, for example, the following carefully rendered graph: Don’t take its elegant ASCII too seriously; it’s a 5 second draft. But between its pipes and backslashes, there are some questions to be pondered. On ?? process The ?? process sits on the same server as the web...
Jun 3rd
Jun 2nd
Jun 2nd
BDD everywhere
That previous javascript code really should be tested. JSpec to the rescue: edit: JSpec installs Commander v3.3.0, which for some reason or other isn’t working properly. v3.2.9 is dandy, though.
Jun 1st
Onwards towards JS
Here we stand, at the beginning of a javascript-flavored week:
Jun 1st
May 2009
7 posts
object-free go boom
Probing for the allocation and freeing of objects in a Ruby process seems like a good way to check for memory leaks. If your object count keeps increasing, somethings not right. But I’ve been foiled. The following code causes a segfault when running the garbage collector in an irb process with the default Ruby installation in Mac OS X Leopard: Not a new issue at all, though. It’s...
May 30th
On the need for a person to bounce ideas off of
ecin: Don't mind me though. I'm like a dog sniffing and making holes, and when I find something, I return it to you.
ecin: And it may be worthless, and you may have no idea what it is, but I need the pat on the head to continue sniffing and making holes until I do find something valuable.
May 28th
May 28th
GC.start
May 27th
Probing for Requests
May 27th
URLs and Timestamps
May 26th
Journey::start!
I got lost on the way to the start of my Summer of Code journey. The banners were big enough, but I had to find myself first. Luckily, a nice lady showed me the way with a book. “Secret methods to study yourself”, she said.
May 6th
April 2009
1 post
Rack::Dtrace Plus Pretty Graphs →
This is my Google Summer of Code proposal. It was the best one ever. It won me 3 apples and a tasty passion fruit.
Apr 30th