Skip to content

Instantly share code, notes, and snippets.

View kbaribeau's full-sized avatar

Kevin Baribeau kbaribeau

  • Test Double
  • Saskatoon, SK, Canada
View GitHub Profile
class Foo
Object = nil
def getBinding()
binding()
end
end
Foo::Object #returns nil
Object #returns Object
@kbaribeau
kbaribeau / gist:1297273
Created October 19, 2011 01:34
explicit requires, fast specs, and crazy dependencies
#foo.rb
class Foo < Bar
end
#bar.rb
class Bar < ActiveRecord::Base
#all sorts of crazy code that depends on a bunch of wacky stuff my tests don't care about
end
@kbaribeau
kbaribeau / gist:1677180
Created January 25, 2012 16:43
Git branch cleanup
git branch -r | grep kbaribeau | grep -v ${stuff_to_keep} | cut -d '/' -f 2-9 | sed -e 's/^/:/' | xargs git push origin
@kbaribeau
kbaribeau / gist:2294333
Created April 3, 2012 18:13
Annoyances / Fixes when switching from vim to sublime

CTRL+O/CTRL+I (forward / back)

  • partial fix: add this to your user keybindings (this only works between files, not within a file)
    [
         { "keys": ["ctrl+o"], "command": "next_view_in_stack" },
         { "keys": ["ctrl+i"], "command": "prev_view_in_stack" }
    ]
ree-1.8.7-2011.03 :003 > hash = Hash.new([])
=> {}
ree-1.8.7-2011.03 :004 > hash[:asdf] << 1
=> [1]
ree-1.8.7-2011.03 :005 > hash[:fdsa]
=> [1]
ree-1.8.7-2011.03 :006 >
@kbaribeau
kbaribeau / gist:2936794
Created June 15, 2012 14:41
ugly line of js
var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
@kbaribeau
kbaribeau / gist:3123533
Created July 16, 2012 16:07
using custom ssl certs on osx
#see http://jjinux.blogspot.com/2012/02/ruby-working-around-ssl-errors-on-os-x.html
require 'open-uri'
require 'net/https'
module Net
class HTTP
alias_method :original_use_ssl=, :use_ssl=
def use_ssl=(flag)
window.CountCalculator=window.PriceCalculator=window.TaxCalculator=window.ShippingCaclulator = {
calculate: (num) -> (num == undefined ? 0 : num + 1) }
ChainsCalls =
chain: (dependencies, method) ->
_(dependencies).inject((memo, dependency) ->
dependency[method](memo)
, undefined)
Invoice =
@kbaribeau
kbaribeau / gist:3452778
Created August 24, 2012 16:48
Ruby style poll
#Do you prefer this?
merchant["thing"] = important_stuff.map { |important_thing| important_thing["units"] }.inject(&:+)
#Or this?
important_stuff.each { |important_thing| merchant["thing"] += important_thing["units"] }
#Why? Is it completely objective? Or are ruby's idioms/social mores/conventions the deciding factor?
@kbaribeau
kbaribeau / gist:3784044
Created September 25, 2012 19:51 — forked from nhajratw/gist:3783890
accessing functions??
var cycleTimeFunctionThatNeedsABetterName = function(acceptedDate, inProgressDate) {
var cycleTime = Math.round(Ext.Date.getElapsed(acceptedDate,inProgressDate) / 1000 / 60 / 60 / 24);
if (cycleTime === 0) cycleTime = 1;
return cycleTime;
};
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',