Skip to content

Instantly share code, notes, and snippets.

View cherring's full-sized avatar
💭
Why do we even need this?

Chris Herring cherring

💭
Why do we even need this?
View GitHub Profile
@cherring
cherring / d.rb
Created September 13, 2011 05:37
Using libdevil to thumbnail and watermark
# Gem: http://rubygems.org/gems/devil
# Library: http://openil.sourceforge.net/
# Images for use with this: http://dl.dropbox.com/u/363740/images.zip
# To install on snow leopard with homebrew:
# 1. brew install devil
# 2. gem install devil
# 3. ???
# 4. Profit!
================================================================
= Trusting an .rvmrc file means that whenever you cd into this =
= directory, RVM will run this .rvmrc script in your shell. =
= =
= If the contents of the file change, you will be re-prompted =
= to review the file and adjust its trust settings. You may =
= also change the trust settings manually at any time with =
= the 'rvm rvmrc' command. =
= =
= Now that you have examined the contents of the file, do you =
@cherring
cherring / helper.js
Created June 7, 2011 00:14 — forked from jobwat/helper.js
Resize text font-size to fit in parent element width
Helpers.updateResizeInput = function(el, text){
if(el.localName == "input" || el[0].localName == "input"){ // inputs are a pain
el.parent().prepend('<span id="test" />');
var theSpan = $('span#test', el.parent());
theSpan.value = text;
Helpers.updateResizeInput(theSpan, text);
el.css('font-size', theSpan.css('font-size'));
el.css('margin-top', theSpan.css('margin-top'));
el[0].value = text;
theSpan.remove();
require 'steak'
require 'capybara'
require 'capybara/dsl'
require 'rack/test'
RSpec.configure do |config|
def app
Capybara.app
end
config.include Capybara
Before do
Capybara.default_host = 'example.com'
DatabaseCleaner.start
end
After do
DatabaseCleaner.clean
FileUtils.rm_r(Dir.glob("#{Rails.root}/tmp/uploads/*"))
FileUtils.rm_r(Dir.glob("#{Rails.root}/uploads/test*"))
FileUtils.rm_r(Dir.glob("#{Rails.root}/public/uploads/tmp/*"))
# Postgres backup script
# mynameisrufus
#
# Cron tab examples:
#
# daily keeping the last 5 days (run at 1:00AM, 2 minutes after the hour)
#
# 02 1 * * * postgres /script/db_backup.sh daily /var/backups/db $DATABASE_OWNER 5 >> /var/backups/db/backup.log 2>&1
#
#
## This is just mangled out of the resque repo
check process resque with pidfile /path/to/pidfile.pid
start program = "/bin/sh -c 'cd /path/to/app/current; /usr/bin/env RAILS_ENV=production /usr/bin/env QUEUE="*" VERBOSE=1 /usr/bin/rake environment resque:work & > log/resque.log && echo $! > tmp/pids/resque.pid'" as uid rails and gid rails
stop program = "/bin/sh -c 'cd /path/to/app/current && kill -s QUIT `cat tmp/pids/resque.pid` && rm -f tmp/pids/resque.pid; exit 0;'"
if totalmem is greater than 100 MB for 10 cycles then restart # eating up memory?
group resque_workers
⚡ rake spec
rake aborted!
dlsym(0x1027f1510, Init_libxml_ruby): symbol not found - /Users/chris/.rvm/gems/ruby-1.8.7-p330/gems/libxml-ruby-1.1.4/lib/libxml_ruby.bundle
class KlassB
def do_something
save
send email or some such thing
end
end
.input
= f.text_area :body
= f.hidden_field :commented_by, :value => current_user.email