Skip to content

Instantly share code, notes, and snippets.

Avatar

Christian Trosclair xn

View GitHub Profile
View wikt.css
/* standard css for master page tables */
table.master {
width: 100%; /* Fill <div> */
}
table.master > tr > th,
table.master > tr > td,
table.master > * > tr > th,
table.master > * > tr > td {
vertical-align: top; /* Set valign variable */
}
View gist:6437855
require 'forwardable'
module Blah
include ::Forwardable
def self.extended(base)
base.send :def_delegators, :@list, :<<, :length # and anything else
end
end
class List
View beinning_of_month.rb
1.9.2p320 :001 > t = Time.new(2013,1,1,0,0,0,0)
=> 2013-01-01 00:00:00 +0000
1.9.2p320 :002 > t.beginning_of_month
=> 2013-01-01 00:00:00 -0800
1.9.2p320 :003 > t.beginning_of_month.utc
=> 2013-01-01 08:00:00 UTC
1.9.2p320 :004 > t.utc.beginning_of_month
=> 2013-01-01 00:00:00 UTC
@xn
xn / concise_transfers_controller.rb
Created Jan 3, 2013
The book `Clean Ruby` talks about locus of attention then offers this controller at the end of Chapter 1. To me, my eyes just roll off the create method. There is simply too much going on there to get everything in one gestalt. Here's my refactor:
View concise_transfers_controller.rb
class ConciseTransfersController < ApplicationController
respond_to :html
def create
respond_with account do |format|
format.html { redirect_to account_transfers_path(account) }
end
end
protected
@xn
xn / 0-readme.md
Created Feb 21, 2012 — forked from mickm/0-readme.md
ruby-1.9.3-p125 cumulative performance patch.
View 0-readme.md

Patched ruby 1.9.3-p125 for 30% faster rails boot

What is?

This script installs a patched version of ruby 1.9.3-p125 with patches to make ruby-debug work again (#47) and boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84).

Huge thanks to funny-falcon for the performance patches.

View pathy.rb
class Hash
#this is pseudocode
def locate_and_find_all(nodes*, &block)
enum = self
while !nodes.empty?
node = nodes.pop
if enum.has_key? node
enum = enum[node]
else
View gist:1174200
development:
adapter: postgresql
encoding: unicode
database: igb_development
pool: 5
username: some_user_name
password: some_password
# Connect on a TCP socket. Omitted by default since the client uses a
# domain socket that doesn't need configuration. Windows does not have
@xn
xn / gist:1153733
Created Aug 18, 2011
active_admin error
View gist:1153733
2011-08-18T09:02:49+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.1.1/lib/new_relic/rack/browser_monitoring.rb:42:in `autoinstrument_source'
2011-08-18T09:02:49+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.1.1/lib/new_relic/rack/browser_monitoring.rb:21:in `call'
2011-08-18T09:02:49+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/bundler/gems/barista-0d85a193da9c/lib/barista/server.rb:33:in `call'
2011-08-18T09:02:49+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/warden-1.0.5/lib/warden/manager.rb:35:in `block in call'
2011-08-18T09:02:49+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/warden-1.0.5/lib/warden/manager.rb:34:in `catch'
2011-08-18T09:02:49+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/warden-1.0.5/lib/warden/manager.rb:34:in `call'
2011-08-18T09:02:49+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/bundler/gems/rails-4b411c80cc96/actionpack/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
2011-08-18
View gist:1145752
- if hidden
%section#account_settings_profile.hidden
%h1
%span Profile
= form_for @user, :url => registration_path(@user) do |form|
%p
= form.label :first_name, 'First:'
= form.text_field :first_name
@xn
xn / gist:1077093
Created Jul 12, 2011
patched ruby
View gist:1077093
curl https://raw.github.com/gist/1008945/7532898172cd9f03b4c0d0db145bc2440dcbb2f6/load.patch > /tmp/load.patch
rvm get head # always good to make sure you're up to date with RVM
rvm reload
rvm install ruby-1.9.2-p180 --patch /tmp/load.patch -n patched
rvm use ruby-1.9.2-p180-patched