Skip to content

Instantly share code, notes, and snippets.

config.action_controller.asset_host = Proc.new do |source, request|
non_ssl_host = "http://asset#{source.hash % 4}.backpackit.com"
ssl_host = "https://asset1.backpackit.com"
if request.ssl?
case
when source =~ /\.js$/
ssl_host
when request.headers["USER_AGENT"] =~ /(Safari)/
non_ssl_host
def root(*args)
if defined?(RAILS_ROOT)
args.compact.empty? ? RAILS_ROOT : File.join(RAILS_ROOT, args)
end
end
#!/bin/sh
# git-create-remote-branch <branch_name>
if [ $# -ne 1 ]; then
echo 1>&2 Usage: $0 branch_name
exit 127
fi
set branch_name = $1
git push origin origin:refs/heads/${branch_name}
class Poller < Rails::Metal
def process(env)
if env["PATH_INFO"] =~ /^\/poller_rack/
return [200, {"Content-Type" => "text/html"}, ["Hello, World!"]]
end
end
end
# Implementation:
@dhh
dhh / gist:38672
Created December 21, 2008 12:02
case request.format
when :html then render
when :js then render
else head(:not_supported)
end
# vs
respond_to do |format|
format.html
# 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
# ServerAlias *.example.com
# </VirtualHost>
#
# 3) Set the current account from the subdomain
$ ruby ~/Code/rails/railties/bin/rails wonky --edge
create
create README
create .gitignore
create Rakefile
create config.ru
create Gemfile
create app
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb
envy17:wonky david$ ls -laR vendor/gems/
total 24
drwxr-xr-x 8 david staff 272 Jan 4 15:34 .
drwxr-xr-x 4 david staff 136 Jan 4 15:33 ..
drwxr-xr-x 12 david staff 408 Jan 4 15:34 cache
drwxr-xr-x 3 david staff 102 Jan 4 15:33 dirs
drwxr-xr-x 2 david staff 68 Jan 4 15:34 doc
-rw-r--r-- 1 david staff 8321 Jan 4 15:34 environment.rb
drwxr-xr-x 20 david staff 680 Jan 4 15:34 gems
drwxr-xr-x 20 david staff 680 Jan 4 15:34 specifications
class Notifier < ActionMailer::Base
delivers_from '[email protected]'
def welcome(user)
@user = user # available to the view
mail(:subject => 'Welcome!', :to => user.email_address)
# auto renders both welcome.text.erb and welcome.html.erb
end
def goodbye(user)
Dec 9 14:27:03 acc-db-01 [248740.420900] divide error: 0000 [#1] SMP
Dec 9 14:27:03 acc-db-01 [248740.428791] last sysfs file: /sys/devices/system/cpu/cpu15/cache/index2/shared_cpu_map
Dec 9 14:27:03 acc-db-01 [248740.444194] CPU 6
Dec 9 14:27:03 acc-db-01 [248740.450660] Modules linked in: btrfs zlib_deflate crc32c libcrc32c ufs qnx4 hfsplus hfs minix ntfs vfat msdos fat jfs reiserfs xfs exportfs nfs lockd nfs_acl auth_rpcgss sunrpc ipmi_devintf ipmi_si ipmi_msghandler autofs4 bonding fbcon tileblit font bitblit softcursor vga16fb vgastate bnx2 psmouse dell_wmi serio_raw joydev power_meter dcdbas lp parport ses enclosure usbhid hid megaraid_sas
Dec 9 14:27:03 acc-db-01 [248740.516499] Pid: 17864, comm: dsm_sa_snmp32d Not tainted 2.6.32-22-generic #33-Ubuntu PowerEdge R710
Dec 9 14:27:03 acc-db-01 [248740.538698] RIP: 0010:[<ffffffff8105621c>] [<ffffffff8105621c>] find_busiest_group+0x63c/0x900
Dec 9 14:27:03 acc-db-01 [248740.561223] RSP: 0018:ffff880604711b88 EFLAGS: 00010046
Dec 9 14:27:03 acc-