Skip to content

Instantly share code, notes, and snippets.

@joerixaop
joerixaop / README.md
Last active August 29, 2015 14:10 — forked from botandrose/README.md
@shawn42
shawn42 / gamebox_fade.rb
Created January 3, 2015 23:05
fading text in gamebox
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
@shawn42
shawn42 / demo_stage.rb
Created January 6, 2015 02:14
tween usage in gamebox
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
@squarism
squarism / swagger.md
Created January 23, 2015 23:00
Swagger Grape Weirdness

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)
@rud
rud / watchr-runner.rb
Created February 8, 2010 14:17
watchr for rspec
if __FILE__ == $0
puts "Run with: watchr #{__FILE__}. \n\nRequired gems: watchr rev"
exit 1
end
# --------------------------------------------------
# Convenience Methods
# --------------------------------------------------
def run(cmd)
puts(cmd)
@solnic
solnic / mysql_and_mongodb_example.rb
Created March 3, 2010 11:11
This code uses dm-core from snusnu's active_support branch and dm-mongo-adapter from master
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
@tlehman
tlehman / boolfail.py
Created September 21, 2015 23:11
Redefine true and false in python
# 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
@luciferous
luciferous / README
Created September 6, 2010 22:55
Sudoku solver in Ruby
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