Skip to content

Instantly share code, notes, and snippets.

View davidglassborow's full-sized avatar

David Glassborow davidglassborow

View GitHub Profile
# This method finds related articles using Jaccard index (optimized for PostgreSQL).
# More info: http://en.wikipedia.org/wiki/Jaccard_index
class Article < ActiveRecord::Base
def related(limit=10)
Article.find_by_sql(%Q{
SELECT
a.*,
( SELECT array_agg(t.name) FROM taggings tg, tags t
#!/bin/sh
#set -x
#
# chkconfig: 2345 99 01
# description: starts and stops torquebox
TORQUEBOX_JBOSS_USER=torquebox
if [ "$TORQUEBOX_JBOSS_USER" = "RUNASIS" ]; then
SUBIT=""
@davidglassborow
davidglassborow / application.rb
Created October 16, 2011 14:35
Rails 3.1 Template for DataMapper 1.2.0.rc2
# This needs to be called after one of the gemfile templates
apply 'http://datamapper.org/templates/rails/config.rb'
apply 'http://datamapper.org/templates/rails/database.yml.rb'
inject_into_file 'app/controllers/application_controller.rb',
"require 'dm-rails/middleware/identity_map'\n",
:before => 'class ApplicationController'
inject_into_class 'app/controllers/application_controller.rb',