JDBC access with distributed ruby : Ewout blogt. JDBC, java database connectivity, is the standard database driver interface on the java platform. Since java is ubiquitous, most database vendors provide JDBC drivers to access their data. When a ruby application requires using a legacy data source, sometimes the only option is going through JDBC. The database toolkit Sequel can use JDBC data sources, but only when running on JRuby. Although JRuby is compatible with ruby 1.8.7, not every application can be run on it, especially when it depends on gems that define C extensions. Fortunately, distributed ruby exists. Both server-side and client-side code is pretty straightforward. # server side require 'drb' require 'java' require 'rubygems' require 'sequel' DRb.start_service ' Sequel # It might be needed to instantiate the driver here, # so it is available when a connection string is given. NativeException Inside the JDBC driver, native java exceptions can be raised. DRb::DRbUnknownError: NativeException
rubyrep: Home Building a Twitter Filter With CherryPy, Redis, and tweetstream Background all the code is available at Since reading this post by Simon Willison I've been interested in Redis and have been following its development. Tools tweetstream - provides the interface to the Twitter Streaming APICherryPy - used for handling the web app side, no need for an ORMJinja2 - HTML templatingjQuery - for doing the AJAXy stuff and visual effectsredis-py - Python client for RedisRedis - the "database", look here for the documenation on how to install it Retrieving tweets The first thing we need to is retrieve tweets from the Twitter Streaming API. Here is the code for the filter_daemon.py, which when executed as a script from the command-line will start streaming tweets from Twitter that contain the words "why", "how", "when", "lol", "feeling" and the tweet must end in a question mark. The important part of this class is the push method, which will push data onto the tail of a Redis list. Web App Thats it.
Finding your soulmate: autocomplete with Redis in Rails 3.1 Back in February the SeatGeek team open sourced a gem they call Soulmate that implements autocomplete using a Redis back end. “Soulmate finishes your sentences” as they say on their Github readme page. You can see it in action on SeatGeek.com. Soulmate is very useful: many of us need type ahead search behavior and using Redis is a great way to make it fast and snappy. But more importantly, Soulmate is a great example of how to create an index in Redis ahead of time, allowing for very fast lookups later. Take a few minutes to learn how Soulmate works; chances are you’ll be able to use the same approach in your own app with a completely different data set. I’ll get started today by showing you step by step how to setup a new Rails 3.1 app with Soulmate and Redis, using the jQuery UI autocomplete widget. How Soulmate was intended to work Here’s a conceptual diagram showing how you would normally use Soulmate: The Soulmate gem contains two components that you interact with directly: