Displaying articles with tag rails

CouchDB: Frankie Says Relax

Posted by code_monkey_steve, Tue May 12 11:49:00 UTC 2009

I’m falling in love (or at least lust) with CouchDB, especially after seeing this presentation at AAC and this presentation for the BBC. My summary: JSON document storage, sliced-and-diced with Javascript MapReduce, all served on a RESTful platter.

As a long-time XML fanboy, the lack of schema in JSON makes me a bit twitchy, and using Javascript as a query language just looks a lttle wrong. But I see the advantages to the document-centric model (versioning, replication, access control) and MapReduce is definitely the Wave of the Future Present. It looks like you can encapsulate all of your model logic in views, so I’m not sure if an explicit schema is really even necessary. The more I learn about That Way of doing things, the more it grows on me.

So how do we make CouchDB play nicely with Rails? I first tried activecouch, but found its lack of Ruby-type casts and one-database-per-model scheme irritating. couch_potato definitely looks slicker, but there seems to be quite a few other CouchDB interfaces out there that might be just as good or better. I see this as a good sign that many others also see CouchDB’s potential, and are experimenting with ways to deal with it in a Ruby Way.

0 comments | Filed Under: | Tags: rails

ODIN: Secure P2P on the Web

Posted by code_monkey_steve, Mon Sep 25 09:11:00 UTC 2006

The first thing you need to understand for this to make sense is that the magic of OFF is all in the block encoding which turns meaningful bits into ownerless, quasi-random blocks identified by their SHA1 hashes. Once this transformation is performed, there is no way for anyone to know the content of a block on the network, as it has no meaning until it’s combined with other blocks (and, in that way, may actually “belong” to multiple files, simultaneously).

The thing that first screamed “Rails app!” to me is the fact that, once the content has been OFF-encoded into blocks, any transport mechanism can be used to move these blocks around, allowing for a network-agnostic peer-to-peer system. Using HTTP, I could write my own smart, caching web peer (with combined web UI) in Rails, but since it’s using HTTP, I could also use dumb web server file servers as mass block stores (no CGI required!). Eventually, I could add (trivial) support to talk to the existing OFF network (also HTTP, AFAIK). If I watned to get really crazy, I could make the app a 3-way network bridge with BitTorrent (which also uses SHA1-identified data blocks).

This is an extension of earlier musings about extending HTTP (or coming up with some other standard) for enumerating mirrors of a particular web resource, something like a per-directory MIRROR file (in XML). A local web-proxy/daemon would cache the status, speed, and locality of various mirrors, and attempt to provide the best location for a particular resource (Use Case #1: Linux RPM repositories). Throw in resource discovery, and you have a basic peer-to-peer network, all over HTTP. While this project assumes that each peer is serving OFF-encoded blocks, there’s no reason why this assumption couldn’t be refactored-out, leaving a generic HTTP P2P system.

To date I’ve already completed most of the functionality of ODIN: fast block encoding (more on that later), file insertion and extraction, basic file transfer and peer discovery. I’ll post more when I have something to show-off. ;)

0 comments | Filed Under: Projects | Tags: rails

Typo w/ Rails Installer: The New Hotness

Posted by code_monkey_steve, Thu Jul 20 02:49:33 UTC 2006

So I had this very long and in-depth article almost-completely written article, detailing the nifty hacks I used to deploy this website on top of Typo, using Capistrano and a litle script to symlink them together. It was beautiful and elegant … and now completely useless thanks to Typo 4 .

The magic is in the Rails Installer, a handy little gem for doing end-user installs. Makes my elegant little hacks a little silly.

sigh

0 comments | Filed Under: | Tags: rails

A Few of My Favorite Things

Posted by code_monkey_steve, Sun Jul 02 09:33:33 UTC 2006

Ruby Development

The barest of essentials. If you don’t already have Ruby and RubyGems, you’ve come to the wrong place.

I highly recommend the KDevelop IDE for all of your bit-flinging needs. I grew to love it when doing C++ code, and it works just as well for Ruby. For times when you just want to tweak a config file, and a full IDE is overkill, nano is your best bet. An excellent lightweight text editor with syntax highlighting, multiple file buffers, and search-n-replace.

Finally, Subversion is by far the best source control system I’ve ever used (including CVS, SourceSafe, Continuus, and Perforce). Aside from its sane handling of symlinks and binary files, the ability to include external Subervsion repositories by reference makes it a must for including Rails plugins.

Rails

The only-slightly-nude essentials. I don’t bother with EdgeRails as I’m still playing catch-up trying to grok all the spiffy features in 1.1.

If you only use one Rails plugin … you’re an idiot. But if it’s assert_valid_markup, at least you’re an idiot with standards-compliant web sites. Adding assert_valid_markup to your functional tests ensures that the XHTML content validates using the W3C validator. I’ve also added an assert_val id_css function to validate stylesheets as well (need to get that added, one of these days).

If you’re running multiple websites, you’ll also want the request_routing plugin. It makes it easy to create routes that look at things like domain (for virtual hosting). Very handy.

Databases

I use MySQL almost exclusively, only because it’s th easiest to setup and administer for small sites. PostgresQL is good for that grown-up, Oracle feeling, but also comes with that Oracle footprint.

With Web Services being all the rage these days, big monolithic databases are looking more and more like they’re more trouble than they’re worth. What’s wrong with nimble, embedded DBS? And sure, tables work great for accounting, but if you want that juicy XQuery goodness, BDB XML is the new hotness.

Administration

So you’ve got your Google-killing website writen, tested, validated, and checked-in. Now you actually need to get it on the IntarWeb. First you need a webserver (what, you want Rails to do everything?). I’ve used Apache for many many moons, but recently made the switch to Lighttpd, and haven’t looked back. With memory usage less than one-tenth of Apache, is a must for shared/leased hosts where memory is scarce. It supports virtual hosting, SSL, FastCGI, rewrite/redirect, anti-deep-linking measures, and all with a config format that’s simple and pleasantly script-like.

Now that we have our website and web server, we need to get the former onto the later. That’s where Capistrano comes in. With a simple Ruby config file, you can easily deploy your website to any number of web/db/application host machines (and then roll it back when you discover some horrific bug). No professional Rails setup should be without it.

The IntarWeb

I have residential DSL services through Speakeasy, on which I run my secondary web server. Speakeasy has good prices and service, especially for geeks who have outrageous demands like static IPs.

Once I hit the critical mass of websites such that I didn’t want to host them on my home server, I looked around for a decent hosting company, and discovered RimuHosting. They provide virtual servers, with your choice of OS, for dirt-cheap (e.g. $20/mo.). In fact, I just upgraded my server (MySQL is such a RAM-hog), and they threw in another 32MB free, just because they could. We like free stuff (and companies that aren’t afraid to give it). I recommend highly.

0 comments | Filed Under: | Tags: rails