Skip to content

Instantly share code, notes, and snippets.

View xn's full-sized avatar

Christian Trosclair xn

View GitHub Profile
### Keybase proof
I hereby claim:
* I am xn on github.
* I am garbhoch (https://keybase.io/garbhoch) on keybase.
* I have a public key whose fingerprint is EB80 940E 4C61 D7BB 933F D98C 5B16 C2DA F588 12F1
To claim this, I am signing this object:
@xn
xn / string.rb
Created July 1, 2014 20:27
Format String
person = {name: "Bob", age: "23"}
"name: %{name}, age: %{age}" % person
[credential]
helper = osxkeychain
[core]
editor = sublime -n -w
excludesfile = ~/.gitignore
whitespace = trailing-space,space-before-tab
quotepath = false
[alias]
a = add
aa = add --all
@xn
xn / nombom.sh
Created June 7, 2015 21:20
npm, bower, Why hast thou forsaken me?!?!
alias nombom='echo "(╯°□°)╯︵ ┻━┻ " && npm cache clear && bower cache clean && rm -rf node_modules bower_components && npm install && bower install'
@xn
xn / gist:714891
Created November 25, 2010 04:16
home_run failing with subtraction using ActiveSupport and DateTime
irb(main):001:0> require 'active_support/core_ext'
=> true
irb(main):002:0> x = Date.new(2001)
=> Mon, 01 Jan 2001
irb(main):003:0> x - 1.second
=> 2000-12-31 23:59:59 -0500
irb(main):004:0> y = DateTime.new(2001)
=> Mon, 01 Jan 2001 00:00:00 +0000
irb(main):005:0> y - 1.second
TypeError: expected numeric or date
p Hash[(instance_variables - [:@options]).map { |i| [i, instance_variable_get(i)] }]
@xn
xn / gist:853172
Created March 3, 2011 17:49
ideas for specing
describe 'get /projects' do
context 'when user logged in' do
it "returns a list of projects scoped by user"
end
end
@xn
xn / gist:875262
Created March 17, 2011 22:31 — forked from leshill/gist:870866
# Add this to more_web_steps.rb
# Selenium docs: http://code.google.com/p/selenium/wiki/RubyBindings#Javascript_Alert/Confirm today!
When /^I (accept|dismiss) the "([^"]*)" alert$/ do |action, text|
window = page.driver.browser.window_handle
alert = page.driver.browser.switch_to.alert
alert.text.should == text
alert.send(action)
page.driver.browser.switch_to.window window
end
@xn
xn / preftools.rb_stacktrace
Created April 26, 2011 18:59
segfault in perftools.rb
In a sinatra app:
use ::Rack::PerftoolsProfiler, :default_printer => 'gif', :mode => 'objects'
?profile=true&times=1
Linux anjaneya 2.6.35-28-generic #50-Ubuntu SMP Fri Mar 18 18:42:20 UTC 2011 x86_64 GNU/Linux
#0 0x00007f30be71b2a3 in select () from /lib/libc.so.6
#1 0x00007f30bf2c954a in rb_thread_select (max=<value optimized out>, read=0x7fff9c5bd5a0, write=0x0, except=0x0, timeout=<value optimized out>) at eval.c:11462
#2 0x00007f30bf2e1f3c in rb_f_select (argc=<value optimized out>, argv=<value optimized out>, obj=<value optimized out>) at io.c:4946
#3 0x00007f30bf2c2d14 in rb_call0 (klass=<value optimized out>, recv=<value optimized out>, id=<value optimized out>, oid=<value optimized out>, argc=<value optimized out>, argv=<value optimized out>, body=0x7f30bf76bde8, flags=0) at eval.c:5928
#4 0x00007f30bf2c2f03 in rb_call (klass=139847347388680, recv=139847347388720, mid=3769, argc=4, argv=0x7fff9c5bd970, scope=0, self=139847234679040) at eval.c:6176
@xn
xn / gist:943214
Created April 26, 2011 21:30
response
{"series":[{"refresh_changes":true,"refresh_chart":true,"success":true},{"growl":"Started Tracking Enform. Updates should appear on your dashboard shortly."},{"closemodal":false},{"replaceFrom":{"action":"/projects/2bukd1sbny18j7485xi/trackers/2bxqzjtzjepicuudkp0/tracked_projects/add","selector":"#maintain-a-tracker"}}]}