Skip to content

Instantly share code, notes, and snippets.

View timonv's full-sized avatar
🚀

Timon Vonk timonv

🚀
View GitHub Profile
@timonv
timonv / .vimrc.after
Last active December 14, 2015 16:29
Always show sign column so on syntastic/gitgutter it doesn't 'jump'
# Thanks to http://superuser.com/questions/558876/how-can-i-make-the-sign-column-show-up-all-the-time-even-if-no-signs-have-been-a
autocmd BufEnter * sign define dummy
autocmd BufEnter * execute 'sign place 9999 line=1 name=dummy buffer=' . bufnr('')
# For pretty oneliners. It just memoizes on nil, but accepts TrueClass as a value
def memoize(&block)
key = caller[0][/`.*'/][1..-2] # Get the method name of the caller
@_memoized ||= {}
@_memoized[key].nil? ? @_memoized[key] = block.call : @_memoized[key]
end
# memoize do
# ExpensiveOperation
# end
def wait_for(klass, objects, assert = Proc.new { |x| x.present? }, retries = 10)
retries.times do |i|
break if assert.call(klass.send(objects))
sleep i * 0.1
end
end
@timonv
timonv / remove remote merged branches
Created September 3, 2012 13:43
Remove merged branches from remote git
git branch -r --merged | grep -v 'master$' | sed "s/origin\///" | xargs -I% git push origin :%
@timonv
timonv / rvminfo
Created August 14, 2011 11:11
RVM info
ruby-1.9.2-p290@blog:
system:
uname: "Darwin Vainglory.local 11.0.0 Darwin Kernel Version 11.0.0: Sat Jun 18 12:56:35 PDT 2011; root:xnu-1699.22.73~1/RELEASE_X86_64 x86_64"
bash: "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin11)"
zsh: "/usr/local/bin/zsh => zsh 4.3.12 (i386-apple-darwin10.7.4)"
rvm:
version: "rvm 1.6.32 by Wayne E. Seguin ([email protected]) [https://rvm.beginrescueend.com/]"
@timonv
timonv / post.rb
Created August 14, 2011 10:16
Post model
class Post
include Mongoid::Document
include Mongoid::Timestamps
field :title, :type => String
field :content, :type => String
field :permalink, :type => String
belongs_to :user