Skip to content

Instantly share code, notes, and snippets.

View ryan-scott-dev's full-sized avatar

Ryan Scott ryan-scott-dev

View GitHub Profile
@ryan-scott-dev
ryan-scott-dev / gist:9480013
Created March 11, 2014 05:33
Easy Ruby Fileserver
require 'webrick'
server = WEBrick::HTTPServer.new :Port => 8000, :DocumentRoot => './'
server.start
@ryan-scott-dev
ryan-scott-dev / gist:9383147
Last active August 29, 2015 13:57
Flatten Nested JSON data to Form Data
flattenNestedFormJSON = function(json) {
if (typeof json === "string" ||
typeof json === "number" ||
typeof json === "boolean" ||
json === null) {
return json;
}
if (typeof json !== "object") {
return null;
@ryan-scott-dev
ryan-scott-dev / gist:7537452
Created November 18, 2013 23:42
Disable bootstrap tooltips in integration tests
def disable_tooltips
page.execute_script(
" \
var css = '.tooltip { display: none !important; }', \
head = document.getElementsByTagName('head')[0], \
style = document.createElement('style'); \
style.type = 'text/css'; \
if (style.styleSheet){ \
style.styleSheet.cssText = css; \
} else { \
class Player
def initialize
@direction = :forward
@health = 20
end
def play_turn(warrior)
@warrior = warrior
if nothing_interesting_ahead?
class Player
def play_turn(warrior)
@direction = :forward if @direction.nil?
if warrior.look(@direction)[1].empty? and warrior.health == @health or @health.nil?
warrior.walk!
elsif warrior.look(@direction)[1].empty? and warrior.health < @health
if warrior.look(@direction)[1].enemy?
warrior.shoot!
end
elsif warrior.feel(@direction).enemy?
/*
Copyright Alex Leone, David Nufer, David Truong, 2011-03-11. kathack.com
javascript:var i,s,ss=['http://kathack.com/js/kh.js','http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js'];for(i=0;i!=ss.length;i++){s=document.createElement('script');s.src=ss[i];document.body.appendChild(s);}void(0);
*/
var BORDER_STYLE = "1px solid #bbb",
CSS_TRANSFORM = null,
CSS_TRANSFORM_ORIGIN = null,
POSSIBLE_TRANSFORM_PREFIXES = ['-webkit-', '-moz-', '-o-', '-ms-', ''],
@ryan-scott-dev
ryan-scott-dev / bowling_test.hs
Created July 20, 2012 03:30
Haskell Bowling Score Calculator Harness
import System.IO
calculateScore x = 0
testDescription 1 = print "Testing score with [(1,5)] == 6"
testDescription 2 = print "Testing score with [(1,5), (3, 5), (7, 2)] == 23"
testDescription 3 = print "Testing a spare of [(1,5), (5, 5), (7, 2)] == 31"
testDescription 4 = print "Testing a strike with [(1,5), (10, 0), (7, 2)] == 34"
testDescription 5 = print "Testing a perfect game with 12 [(10,0)] == 300"
testDescription 6 = print "Testing a game with all spares with 10 (5,5) and one (5,0) == 150"
@ryan-scott-dev
ryan-scott-dev / gist:3140575
Created July 19, 2012 03:36
Haskell Notes
=============
Haskell
=============
http://learnyouahaskell.com/
Great resource for learning Haskell
=============
Language
@ryan-scott-dev
ryan-scott-dev / gist:2970586
Created June 22, 2012 05:47
Code Challenge - Paint Cans!!!
require 'benchmark'
CANS = [1, 2, 4, 10, 15]
PRICES = {1 => 4, 2 => 5, 4 => 6, 10 => 11, 15 => 15}
RANDOM = Random.new
class Mutation
attr_accessor :cans