Skip to content

Instantly share code, notes, and snippets.

View lenary's full-sized avatar

Sam Elliott lenary

View GitHub Profile
@auser
auser / paparazzi.conf.erb
Created November 14, 2008 21:10
Sample PoolParty rails spec
include_recipe "apache2"
include_recipe "passenger"
include_recipe "sqlite"
node[:rails][:version] = "2.3.2"
include_recipe "rails"
gem_package "sqlite3-ruby"
gem_package "rake" do
version "0.8.4"
end
@avdi
avdi / example.rb
Created October 30, 2009 22:28
Rack::Stereoscope
require 'sinatra'
require 'json'
require 'addressable/uri'
require File.expand_path('rack_stereoscope.rb', File.dirname(__FILE__))
configure do
use Rack::Reloader;
use Rack::Lint;
use Rack::Stereoscope;
end
#!/usr/bin/env ruby
# Usage:
#
# gt-or-eq.rb hitimes-1.0.4
#
require 'open-uri'
require 'rubygems'
base_url = "http://rubygems.org/quick/Marshal.4.8"
@mnutt
mnutt / Instrument Anything in Rails 3.md
Created September 6, 2010 06:50
How to use Rails 3.0's new notification system to inject custom log events

Instrument Anything in Rails 3

With Rails 3.0 released a few weeks ago I've migrated a few apps and I'm constantly finding useful new improvements. One such improvement is the ability to log anything in the same way that Rails internally logs ActiveRecord and ActionView. By default Rails 3 logs look slightly spiffier than those produced by Rails 2.3: (notice the second line has been cleaned up)

Started GET "/" for 127.0.0.1 at Mon Sep 06 01:07:11 -0400 2010
  Processing by HomeController#index as HTML
  User Load (0.2ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 3) LIMIT 1
  CACHE (0.0ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 3) LIMIT 1

Rendered layouts/_nav.html.erb (363.4ms)

#! /usr/bin/env ruby
status = DATA.flock(File::LOCK_EX | File::LOCK_NB)
if status == 0
puts "we have the lock..."
sleep
else
@tenderlove
tenderlove / campfire.rb
Created February 16, 2011 23:43
This only works on 1.9.2
require 'uri'
require 'psych'
require 'net/http'
require 'meme' # Install meme_generator
module Campfire
class API
attr_reader :uri, :token, :pass
@ltw
ltw / best_model.rb
Created February 21, 2011 01:29
Order of a standard Model
class Model < ParentModel
include Foo::Bar
extend Bar::Baz
acts_as_authentic
dsl_specific_flags
module InternalModule
...
end
@lenary
lenary / template.rb
Created April 14, 2011 22:43
My App Template
# Copyright 2011 Sam Elliott
# Released under MIT Licence
app_name = File.basename(Dir.pwd)
git :init
# Remove rails.png and index.html
remove_file("public/index.html")
remove_file("public/images/rails.png")
create_file("public/images/.gitkeep")

This is a distillation of a technique we use internally at Basho to reduce the pain of cloning some of our larger repos. It relies a bit on shell scripts and environment variables, but it can be run more directly, as I show below.

  1. Create a bare git repository in some directory, e.g. /var/lib/gitcache.

    git init --bare /var/lib/gitcache
  2. Add all repositories you want to cache as remotes to the git repository, e.g.

@macintux
macintux / presentation-tips.md
Last active November 28, 2022 01:03
Public speaking tips