Skip to content

Instantly share code, notes, and snippets.

@peterc
peterc / on_update.task.rb
Created May 17, 2009 23:55
Rake task to automatically run something (i.e. specs) when code files are changed
# Rake task to automatically run something (i.e. specs) when code files are changed
# By Peter Çoopér
#
# Motivation: I couldn't get autotest to run on my Sinatra project for some reason but realized
# it didn't require overengineering. Just detect when a file is changed and then re-run the specs!
#
# Examples:
# # rake on_update "rake"
# # rake on_update "spec spec/user_spec.rb"
#
@mislav
mislav / template-uri.rb
Created September 27, 2009 15:31
URI templates are, like, super-useful
# https://github.com/sporkmonger/addressable/
require 'addressable/template'
# http://dev.twitter.com/doc/get/statuses/followers
template = Addressable::Template.new 'http://{host=twitter.com}' +
'/statuses/followers{-prefix|/|id}.{format=json}' +
'?{-join|&|user_id,screen_name,cursor}'
template.expand(:id => 'mislav')
# => http://twitter.com/statuses/followers/mislav.json?
# Main sinatra app
require 'sinatra'
require 'activerecord'
require 'activesupport'
include ActionView::Helpers::DateHelper # add the required helpers here.
require 'controllers.rb'
# controllers.rb
@nu7hatch
nu7hatch / Gemfile
Created August 4, 2010 09:32
Padrino authentication with Warden
# ...
gem 'padrino-warden', :git => "git://github.com/zmack/padrino-warden.git"
gem 'authtools'
<!DOCTYPE html>
<html>
<head>
<title>Site</title>
</head>
<body class="app">
<%= render :partial => 'layouts/flashes' %>
<%= yield %>
</body>
</html>
@phoet
phoet / rails_admin_without_devise.rb
Created December 17, 2010 15:35
Using RailsAdmin without devise
# add RailsAdmin to the Gemfile
# do NOT add devise
gem "rails_admin", :git => "git://github.com/sferik/rails_admin.git"
# run Bundler
bundle
# run the generator for RailsAdmin
# looks like it's broken, but it just does not install devise
# you may also remove the app/config/locales/devise.en.yml
@wtnabe
wtnabe / README.md
Created February 2, 2011 23:04
easy fabricator command for Ruby's fabrication library

Usage

Usage: easy_fabricator [options] FABRICATOR
    -n, --num NUM ( default 1 )
    -y, --output-yaml
    -c, --output-csv ( default )

Fabricator

@stefl
stefl / gist:867165
Created March 12, 2011 09:58
Redirect trailing slashes in Sinatra
get %r{(.+)/$} do |r| redirect r; end;
@seven1m
seven1m / sass_with_jammit.rb
Created April 13, 2011 20:59
SASS with Jammit
# hack to auto compile sass when Jammit runs in Dev/Test mode
require 'haml/util'
require 'sass/engine'
module Jammit
module Helper
SASS_TIMESTAMPS = {}
def include_stylesheets_with_sass(*packages)
@quinn
quinn / all_the_toys.rb
Created April 14, 2011 16:25
all the fun stuff i use in my default stack!
# data
gem 'carrierwave'
gem 'fog'
gem 'mini_magick'
gem 'resque'
gem 'mysql', group: :development
gem 'pg', group: :production
# controllers and views
gem 'haml-rails'