See https://www.youtube.com/watch?v=4_RJu_TrqO0&feature=youtu.be&t=8h6m40s
$ ruby dilute.rb fib.rb
def fi n
if n < 3
1
else
fib(n-1 + ib(n
end
See https://www.youtube.com/watch?v=4_RJu_TrqO0&feature=youtu.be&t=8h6m40s
$ ruby dilute.rb fib.rb
def fi n
if n < 3
1
else
fib(n-1 + ib(n
end
define_behavior :fades do | |
requires :director | |
setup do # |opts| | |
fade_out_time = 3_000 | |
actor.has_attributes total_fade_time: fade_out_time, fade_time: fade_out_time | |
director.when :update do |time_ms, secs| | |
actor.fade_time -= time_ms | |
alpha = 255 * actor.fade_time / actor.total_fade_time | |
actor.remove if actor.fade_time <= 0 |
define_stage :demo do | |
requires :tween_manager | |
curtain_up do | |
@player = spawn :player, x: 10, y:30 | |
tween = tween_manager.tween_properties @player, {x: 600, y:750}, 6_000, Tween::Sine::InOut | |
# tweens can be canceled if need be, or they will clean themselves up when finished | |
timer_manager.add_timer :foo, 3_000, false do | |
tween.cancel! | |
end |
Imma turn this into a blog post soon but in the meantime wanted to give the Google index a hit on
cannot load such file -- grape-swagger
The grape-swagger gem is forked right now (2015-01-23). If you simply follow the docs, you're going to get a require error.
In Gemfile
, change gem "grape-swagger-rails"
to this: gem "grape-swagger-rails", github: "BrandyMint/grape-swagger-rails"
require 'rubygems' | |
require 'eventmachine' | |
class Handler | |
include EventMachine::Deferrable | |
def takes_long_time(seconds = 5) | |
sleep(seconds) | |
puts "Awoke after #{seconds} seconds." | |
succeed(seconds) |
if __FILE__ == $0 | |
puts "Run with: watchr #{__FILE__}. \n\nRequired gems: watchr rev" | |
exit 1 | |
end | |
# -------------------------------------------------- | |
# Convenience Methods | |
# -------------------------------------------------- | |
def run(cmd) | |
puts(cmd) |
require 'rubygems' | |
require 'dm-core' | |
DataMapper.setup(:default, "mysql://localhost/examples") | |
DataMapper.setup(:logs, "mongo://localhost/examples") | |
class LoggedEvent | |
include DataMapper::Mongo::Resource | |
def self.default_repository_name; :logs; end |
class LoggedEvent | |
include DataMapper::Mongo::Resource | |
property :id, ObjectID | |
property :type, Discriminator | |
property :message, String | |
property :custom_attributes, Hash | |
property :created_at, DateTime | |
end |
# Python boolean fail | |
# Or how to redefine True and False and win any argument on the internet! | |
# Love, @tlehman | |
from unittest import TestCase | |
class BoolFail(TestCase): | |
def test_false(self): | |
True = False | |
assert True == False |
A very simple Sudoku puzzle solver written in Ruby. This script is free every | |
way you look at it. | |
## Example usage | |
$ cat puzzle | |
15 2 | |
7 8459 | |
8 4795 6 | |
5 6 |