Skip to content

Instantly share code, notes, and snippets.

@dhh
dhh / gist:965746
Created May 11, 2011 01:33
Pjax helper
module Pjax
extend ActiveSupport::Concern
included do
layout ->(c) { pjax_request? ? false : 'application' }
end
private
def redirect_pjax_to(action, url = nil)
new_url = url_for(url ? url : { action: action })
kendall :: git/rbx » ruby scratch/bm_either.rb
Rehearsal ---------------------------------------------
includes? 4.410000 0.000000 4.410000 ( 4.421223)
either? 6.450000 0.000000 6.450000 ( 6.478906)
compare 2.040000 0.010000 2.050000 ( 2.044516)
----------------------------------- total: 12.910000sec
user system total real
includes? 4.470000 0.000000 4.470000 ( 4.479386)
either? 6.520000 0.000000 6.520000 ( 6.542424)
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class BuildStatusTest < ActiveSupport::TestCase
test "remove the old statii" do
assert_equal 2, BuildStatus.count
BuildStatus.expire_old
statii = BuildStatus.all
assert_equal 1, statii.size
assert statii[0].updated_at >= 30.days.ago
end
describe "GET current" do
before do
@request.cookies['hidden_notices'] = "1,#{notices(:permanent).id}"
get :current, :format => 'js'
end
it { should respond_with(:success) }
it { should set_cookie(:hidden_notices).to("#{notices(:permanent).id}") }
it { should render_template('notices/current') }
end
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-
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)
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
$ 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
# 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
@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