Skip to content

Instantly share code, notes, and snippets.

require 'rubygems'
require 'sinatra'
require 'redis'
# To use, simply start your Redis server and boot this
# example app with:
# ruby example_note_keeping_app.rb
#
# Point your browser to http://localhost:4567 and enjoy!
#
@mrrooijen
mrrooijen / Capistrano-Deployment-Recipe.rb
Created July 29, 2009 09:34
a "base" Capistrano Rails Deployment Recipe. Use it to deploy your Rails application. It is also easily expandable. So feel free to grab this Recipe and add your own tasks/customization!
# Guide
# Configure the essential configurations below and do the following:
#
# Repository Creation:
# cap deploy:repository:create
# git add .
# git commit -am "initial commit"
# git push origin master
#
# Initial Deployment:
@jcsjcs
jcsjcs / grepr
Created September 20, 2009 14:55
grepr - simple grep for rails projects
#!/usr/bin/env ruby
class Grepr
def initialize(options, pattern)
@paths = []
@pattern = pattern
@noregex = options.include?('n')
@pattern = "'#{@pattern}'" if pattern.include?(' ')
options.each_char do |opt|
case opt
# Example of nested resource with CanCan
class CommentsController < ApplicationController
before_filter :load_and_authorize_resource
# ...
protected
def load_resource
@article = Article.find(params[:article_id])
# Guide
# Configure the essential configurations below and do the following:
#
# Repository Creation:
# cap deploy:repository:create
# git add .
# git commit -am "initial commit"
# git push origin master
#
# Initial Deployment:
module Awesomeness
extend ActiveSupport::Concern
included do
scope :awesome, where(:favorite_language => 'ruby')
end
module ClassMethods
def make_everyone_awesome
update_all(:favorite_language => 'ruby')
@nragaz
nragaz / unicorn.rb
Created July 12, 2010 03:34
unicorn.rb
# unicorn_rails -c /srv/myapp/current/config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'production'
working_directory (rails_env == 'production' ? "/srv/myapp/current" : `pwd`.gsub("\n", ""))
worker_processes (rails_env == 'production' ? 10 : 4)
preload_app true
timeout 30
if rails_env == 'production'
require "sinatra"
require "digest/sha1"
require 'rack-flash'
require 'mongoid'
require "sinatra-authentication"
use Rack::Session::Cookie, :secret => 'mongoid and sinatra does the body good'
use Rack::Flash
Mongoid.configure do |config|
@jonraasch
jonraasch / highlight.js
Created September 2, 2010 22:14
Live on-page text highlighting
/*
highlight v3 !! Modified by Jon Raasch (http://jonraasch.com) to fix IE6 bug !!
Highlights arbitrary terms.
<http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html>
MIT license.
require 'rubygems'
require 'sinatra'
require 'sinatra/base'
require 'my_trip/app'
require 'rack/test'
require 'rspec'
require 'mongoid'
set :environment, :test
set :run, false