This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
def fail(msg) | |
puts msg | |
puts | |
exit | |
end | |
fail "Usage: line [filename] [lineno]" if !ARGV[0] || !ARGV[1] || !File.file?(ARGV[0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
TAB_STOP = 2 | |
$directories_only = false | |
$use_color = true | |
class Tree | |
attr_reader :word, :branches |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
class Autotester | |
MONITOR_MATCH_PATTERN = "**/*.rb" | |
TEST_COMMAND = "rspec spec" | |
def cache | |
@cache ||= {} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set :deploy_to, "public_html" # the remote path where the gem index lives | |
set :build_command, "bundle exec rake build" # the command to build the gem locally | |
set :user, "rubygems" # the user to log in to the server with | |
# the rubygems server to deploy to | |
server "gems.example.com", :app | |
desc "Deploy the gem and rebuild the index" | |
task :deploy do | |
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :assets do | |
task :check => :environment do | |
paths = ["app/assets", "lib/assets", "vendor/assets"] | |
paths.each do |path| | |
dir_path = Rails.root + path | |
if File.exists?(dir_path) | |
dir_files = File.join(dir_path, "**") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parse = (str) -> | |
vec = str.split /,\s*/ | |
return [ parseFloat(vec[0]), 0.0, parseFloat(vec[1]) ] | |
Jax.getGlobal()['Dungeon'] = Jax.Model.create | |
addTorches: (world) -> | |
if @map | |
for z in [0...@map.length] | |
row = @map[z] | |
for x in [0...row.length] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Dice | |
def initialize(count, sides) | |
@count, @sides = count, sides | |
end | |
def roll | |
@count.times.inject(0) { |a,i| a + rand(sides) } | |
end | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REST request | CRUD request | Action | |
----------------|----------------------|------- | |
POST /posts | /posts/create | Create | |
GET /posts/1 | /posts/show/colin | Read | |
PUT /posts/1 | /posts/update/colin | Update | |
DELETE /posts/1 | /posts/destroy/colin | Delete |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Jax.getGlobal().ApplicationHelper = Jax.Helper.create | |
patch_world: -> | |
Jax.World.prototype.pick_all_visible = () -> | |
context = this.context | |
w = context.canvas.width | |
h = context.canvas.height | |
data = new Uint8Array(w*h*4) | |
data.w = w | |
data.h = h | |
data.f = f = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("canvas").remove(); | |
c = document.createElement('canvas'); | |
c.width = c.height = 300; | |
$(document.body).append(c); | |
$(c).css("width", "300px"); | |
$(c).css("height", "300px"); | |
$(c).css("position", "absolute"); | |
$(c).css("top", "0px"); | |
$(c).css("left", "0px"); | |
$(c).css("border", "1px solid #000"); |
OlderNewer