Skip to content

Instantly share code, notes, and snippets.

View cromwellryan's full-sized avatar

Ryan Cromwell cromwellryan

View GitHub Profile
var bgcolorlist = ["#DFDFFF", "#FFFFBF", "#80FF80", "#EAEAFF", "#C9FFA8", "#F7F7F7", "#FFFFFF", "#DDDD00"];
document.body.style.background=bgcolorlist[Math.floor(Math.random()*bgcolorlist.length)];
# hello_world.rb
require 'rack'
require 'rack/server'
class HelloWorldApp
def self.call(env)
[ 200, {}, ['Hello World'] ]
end
end
@cromwellryan
cromwellryan / 0_reuse_code.js
Created February 14, 2014 15:01
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
# Step 1: Download this zip: https://github.com/daytoncleancoders/projects/raw/master/commandline/command-line-kata.zip
# (mac/nix hint: curl, wget)
# (windows hint: net.webclient)
if [ ! -d "site" ]
then
curl -O https://raw.github.com/daytoncleancoders/projects/master/commandline/command-line-kata.zip
# Step 2: Extract the zip
# (hint: tar)
def blah
yield 1
p "2 coming"
yield 2
end
blah { |x| p x }
def pmap(enum)
return to_enum(:pmap, enum) unless block_given?
enum.each_with_index.map { |e,i| Thread.new { sleep(Random.rand); p e; yield ({index: i, value:e }) } }.map(&:value)
end
p to_enum(:pmap, 1..10).sort_by { |hash| hash[:index] }.map { |hash| hash[:value] }
#p pmap(1..10) { |x| x }
require_relative 'dice'
require 'minitest/spec'
require 'minitest/autorun'
describe Dice do
before do
@new_roll = Dice.new
end
describe "rolling 5 dice" do
@cromwellryan
cromwellryan / warrior.js
Last active August 29, 2015 13:57
DCC 3.18.2014
jsWarrior.turn = function(warrior) {
enhance(warrior);
actions = [ attack_move, heal_move, walk_move ];
available_actions = actions.filter( function(action) { return action.can(warrior); } );
available_actions[0].act(warrior);
warrior.last_health = warrior.getHealth();

Keybase proof

I hereby claim:

  • I am cromwellryan on github.
  • I am cromwellryan (https://keybase.io/cromwellryan) on keybase.
  • I have a public key whose fingerprint is E31F A201 E2FA 4C3F A9DC 282F 544D 252A 05BE B4C3

To claim this, I am signing this object: