I ran into a couple weirdnesses setting up tokyocabinet and the Ruby API, so am adding this to my external memory. Hopefully it will help anyone else bumping into the same issue.
Assuming you install tokyocabinet at a non-standard location, such as /Users/brianm/.opt/tokyocabinet-1.4.27 and then want to build the ruby bindings for it via a gem, the trick is to add the bin/ directory for the tokyocabinet install dir to your $PATH (in my case, that is just export PATH=/users/brianm/.opt/tokyocabinet-1.4.27/bin:$PATH). The ruby API’s extconf.rb shells out to tc’s tcucodec to find paths to libraries, etc. Alternately you could modify the extconf.rb, which is very short and sweet, but I hate doing that for aesthetic reasons.
To build the gem, you need to build via extconf but not install. After the build, use the normal gem tokyocabinet.gemspec command to build a gem. Install the gem (in my case, via rip) and glod’s your uncle.
Now to figure out if anyone has done a convenience API wrapper around the table database in TC…
I am playing with new layouts, using Mark Reid’s wonderfully readable stylesheets as a basis. I’m going ahead and pushing it out, despite it being a work in progress. For now it is changed very little, in fact the main css is identical, but it will evolve as I have time.
I’ve taken another cue from him in using markdown for posts with code in them. Something about redcloth doesn’t play nicely with pygments processing of inline code, whereas the markdown processor does play nicely. So, not really caring about which one I use, I swapped out to markdown for posts with code. Yea!
[1,2,3].map { |i| i * i }.inject([]) { |a, i| a << i }.flatten.map {|i| i - 99}.select {|i| i + 99 == 0}
=begin
heh
=end
[1,2,3].map { |i| i * i }.inject([]) { |a, i| a << i }.flatten.map {|i| i - 99}.select {|i| i + 99 == 0}
I particularly like how Mark’s styling handles long code lines :-)
Along the way I killed the search box, it will come back, but it does highlight Toby’s comment that I should have actual, you know, links to my archives. Eventually…
Not long after the idea of dataflow programming clicked for me while reading the excellent Concepts, Techniques, and Models of Computer Programming (affiliate link) I have been trying to figure out the best way to apply it at the library level rather than the language level. Having it at the language level is fine and dandy, but I’m happy to sacrifice a little elegance for just being easy to use for building up a page or response in a webapp from a bunch of remote services.
When rendering (heh, originally typoed that rending, kind of appropriate) a typical page in Rails, PHP, JSP, whatever. If you are nice and clean you fetch all the data you need and shove it into some kind of container which is then used to populate a template. In a complex system it is not unusual to make 20+ remote calls to render a single response. These are to caches, databases, other services, and sometimes pigeons passing by with telegrams on their legs. A couple years ago, we used a reactor style dataflow tool Tim and I wrote for javascript. I rather miss having it when wiring together backend services.
I have done a number of ad-hoc versions in services for Java, using an executor and passing around references to futures, but I don’t have anything that really matches the rather nice push and react style thing we had in javascript there. I can imagine something using Doug Lea’s jsr166y fork/join tools, but every time I start to poke into them the… well, maybe mapping it into a library really is kind of ugly. It certainly is screaming for anonymous functions, oh well guess I am not holding my breath.
So, switching to the other languages I hack in nowadays, we have Ruby (oops, no threads), C (umh, no, wrong level of abstraction), and Lua (hey, actually not bad, particularly with how LuaSocket and coroutines play together…).
Properly, I should now shut up and go hack. On that note, off to hack!
Found a beauty I don’t know how I missed before:
bar = 'hello world'
foo =~ /#{bar}/
I didn’t realize you could do interpolation into regex literals. I don’t know how I lasted this long without finding out!
Added commenting via disqus — we’ll see how it works out. Just felt weird not having any comments, and they seem straightforward, provide a comment feed, etc.