Skip to content

Instantly share code, notes, and snippets.

View rares's full-sized avatar
🌑

(╯°□°)╯︵ ┻━┻ rares

🌑
View GitHub Profile
In response to all the responses to:
http://twitter.com/rtomayko/status/1155906157
You should never do this in a source file included with your library,
app, or tests:
require 'rubygems'
The system I use to manage my $LOAD_PATH is not your library/app/tests
#!/usr/bin/env ruby
# The script that give you focus!
# Create a text file that contains sites want to give yourself
# access to only during certain times of day.
#
# The file will look like this:
# 12 news.ycombinator.com
# 11-13,19-21 twitter.com
#
@rares
rares / git-thanks
Created February 28, 2009 12:39 — forked from rtomayko/git-thanks
#!/bin/sh
# Usage: git-thanks <since>..<until>
#
# All commits on master, ever:
# git-thanks master
#
# All commits on master since the 0.9.0 tag:
# git-thanks 0.9.0..master
git log "$1" |
task :clean do
important_cleans = `git clean -n -d`.split("\n")
important_cleans.reject! { |file|
file =~ /~$/ or
file =~ /#/ or
file =~ /.beam$/
}
if important_cleans.size > 0
puts "Refusing to clean because:"
puts important_cleans.join("\n")
@rares
rares / deploy.rb
Created February 21, 2009 06:27 — forked from defunkt/deploy.rb
# deploy to staging from your current topic branch, with ease
set :branch, "origin/#{`git name-rev --name-only head`}"
@rares
rares / gist:60858
Created February 9, 2009 16:43 — forked from imbriaco/gist:60855
desc "Do rolling restarts of the Mongrel servers in pairs, at 90s intervals."
task :rolling do
servers = []
roles[:app].each do |server|
next unless server.options.fetch(:listener, true)
servers << [] if servers.first.nil? || servers.last.length > 1
servers.last << server.host
end
# at the very least, use inheritance!
class Object
alias_method :try, :send
end
class NilClass
def try(*args)
nil
end
# 1) Point *.example.com in your DNS setup to your server.
#
# 2) Setup an Apache vhost to catch the star pointer:
#
# <VirtualHost *:80>
# ServerName *.example.com
# </VirtualHost>
#
# 3) Set the current account from the subdomain
class ApplicationController < ActionController::Base

Lessons Learned

Be Confident

Tests build confidence. Write 'em. They'll save your ass, and they'll let you take a chainsaw to your code without being afraid of unintended consequences.

Be Lazy

@rares
rares / god.rb
Created November 18, 2008 18:52 — forked from defunkt/god.rb
rails_root = "/data/github/current"
20.times do |num|
God.watch do |w|
w.name = "dj-#{num}"
w.group = 'dj'
w.interval = 30.seconds
w.start = "rake -f #{rails_root}/Rakefile production jobs:work"
w.uid = 'git'