Skip to content

Instantly share code, notes, and snippets.

View xn's full-sized avatar

Christian Trosclair xn

View GitHub Profile
@xn
xn / gist:1061991
Created July 3, 2011 06:05
Speeding up the asset pipeline
gem 'rails', '3.1.0.rc4', :git => "git://github.com/rails/rails", :branch => "3-1-stable"
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'pg'
# Asset template engines
gem 'sass', :git => "git://github.com/nex3/sass.git"
gem 'sprockets', :git => "git://github.com/xn/sprockets.git"
@xn
xn / gist:1077093
Created July 12, 2011 00:12
patched ruby
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
- 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:1153733
Created August 18, 2011 09:25
active_admin error
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
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 / pathy.rb
Created December 28, 2011 23:55 — forked from krainboltgreene/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
@xn
xn / 0-readme.md
Created February 21, 2012 11:24 — forked from mickm/0-readme.md
ruby-1.9.3-p125 cumulative performance patch.

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.

@xn
xn / concise_transfers_controller.rb
Created January 3, 2013 08:26
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:
class ConciseTransfersController < ApplicationController
respond_to :html
def create
respond_with account do |format|
format.html { redirect_to account_transfers_path(account) }
end
end
protected
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 / gist:6437855
Created September 4, 2013 14:38
gem idea
require 'forwardable'
module Blah
include ::Forwardable
def self.extended(base)
base.send :def_delegators, :@list, :<<, :length # and anything else
end
end
class List