Skip to content

Instantly share code, notes, and snippets.

View tkadauke's full-sized avatar

Thomas Kadauke tkadauke

View GitHub Profile
class Array
def index_of(&block)
each_with_index do |item, index|
return index if yield(item)
end
end
end
def print_these_strings(&block)
block.inspect =~ /#<Proc:.*?@(.*?):(.*?)>/
@tkadauke
tkadauke / gist:4078751
Created November 15, 2012 13:57
Goto in Ruby :-)
LABELS = {}
def label(name)
LABELS[name] = callcc { |cc| cc }
end
def goto(name)
LABELS[name].call LABELS[name]
end
@tkadauke
tkadauke / gist:5313277
Created April 4, 2013 19:15
ActiveSupport in RubyMotion :-)
Thomas-Kadaukes-Mac-Pro:activesupport tkadauke$ rake -f Rakefile.rubymotion
================================================================================
A new version of RubyMotion is available. Run `sudo motion update' to upgrade.
================================================================================
Build ./build/iPhoneSimulator-6.0-Development
Compile /Users/tkadauke/code/rails/activesupport/lib/active_support/inflector/inflections.rb
Compile /Users/tkadauke/code/rails/activesupport/lib/active_support/inflector/methods.rb
Compile /Users/tkadauke/code/rails/activesupport/lib/active_support/inflector/transliterate.rb
Link ./build/iPhoneSimulator-6.0-Development/MotionSupport.app/MotionSupport
@tkadauke
tkadauke / Berksfile
Created May 30, 2014 08:00
vagrant-berkshelf bug
# can be empty
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
@tkadauke
tkadauke / exception_loop.rb
Created August 18, 2016 05:25
Endless loop in Ruby without "while"
def loop
yield
raise
rescue
retry
end
loop do
puts "yippie"
end