Skip to content

Instantly share code, notes, and snippets.

@buffpojken
buffpojken / gist:736035
Created December 10, 2010 09:49
Roulette.
%w(rubygems json rest-client).map{|a|require a};puts"Amount betted:";a = gets;JSON.parse(RestClient.get("http://roulette.engineyard.com/")).each_pair{|k,v|v.eql?("13") ? (puts"You've won #{a.to_i*35}"):(puts "No winnings!")}
def ninja(&block)
if block_given?
block.call("ninja")
else
puts "laser"
end
end
ninja do |hugo|
puts "Block:"+hugo
/*
* A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
* in FIPS 180-1
* Version 2.2 Copyright Paul Johnston 2000 - 2009.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
* See http://pajhome.org.uk/crypt/md5 for details.
*/
/*
@buffpojken
buffpojken / gist:9811802
Created March 27, 2014 16:33
Motion crash
nightgaunt:VideoTestVLC buffpojken$ rake
Build ./build/MacOSX-10.9-Development
Compile ./app/menu.rb
Compile ./app/app_delegate.rb
Compile ./app/Controllers/video_controller.rb
Create ./build/MacOSX-10.9-Development/VideoTestVLC.app/Contents
Create ./build/MacOSX-10.9-Development/VideoTestVLC.app/Contents/MacOS
Link ./build/MacOSX-10.9-Development/VideoTestVLC.app/Contents/MacOS/VideoTestVLC
Create ./build/MacOSX-10.9-Development/VideoTestVLC.app/Contents/PkgInfo
Copy /Users/buffpojken/Projects/Motion/VideoTestVLC/VLCKit.framework
class ChannelListHeaderLayout < MotionKit::Layout
def layout
root :cell do
add UIImageView, :logo
end
end
def cell_style
background_color UIColor.whiteColor
class ChannelListHeaderLayout < MotionKit::Layout
def layout
root :cell do
context target.contentView do
add UIImageView, :logo
end
end
end
class TrueClass
def !
return !super
end
end
should_be_true = (1 == 1)
if !should_be_true
puts "I'm so not true..." # => I'm so not true...
class Array
alias_method :_each, :each
def each(&block)
cpy = Array.new(self)
cpy.pop
cpy._each{|n| block.call(n) }
end
end
a = [1,2,3]
class Array
alias_method :_each, :each
def each(&block)
cpy = Array.new(self)
cpy.pop
cpy._each{|n| block.call(n) }
end
end
a = [1,2,3]
class TrueClass
def !
return ((rand > 0.1) && Time.new.wday.eql?(1) ? super : !super)
end
end
should_be_true = (1 == 1)
# This will be correct ~ 10% of the cases if it's monday.
if !should_be_true