Skip to content

Instantly share code, notes, and snippets.

View mattwynne's full-sized avatar

Matt Wynne mattwynne

View GitHub Profile
@mattwynne
mattwynne / -
Created February 14, 2014 13:15
bower_components/jquery
bower_components/jquery/.bower.json
bower_components/jquery/dist
bower_components/jquery/dist/jquery.js
bower_components/jquery/dist/jquery.min.js
bower_components/jquery/dist/jquery.min.map
bower_components/jquery/MIT-LICENSE.txt
bower_components/jquery/src
bower_components/jquery/src/ajax
bower_components/jquery/src/ajax/jsonp.js
@mattwynne
mattwynne / readme.md
Created February 24, 2014 09:52
SRC2014 Workshop - Writing a Game in Ruby

SRC 2014 Workshops

Writing a Game in Ruby

Session leader: Mike Moore (@blowmage)

About this session

Creating games is crazy fun and dirt simple with Ruby. You will leave this workshop with a working game; no previous game development experience necessary. We will introduce basic concepts of game programming and show how to implement them using the Gosu library. This includes the game loop, sprites, animation and hit detection. We will build a complete game, so bring your laptop and follow along.

@mattwynne
mattwynne / gist:11234400
Created April 23, 2014 22:16
Two websocket logs
# When it works:
[:client, :starting]
[:server, :starting]
[:server, :open]
[:client, :open]
[:socket, :send, {:body=>{:status=>:passed}}]
[:server, :message, "{\"body\":{\"status\":\"passed\"}}"]
[:client, :message, "ok"]
[:client, :close]
[:server, :close]
require 'cucumber/core'
test_case = Cucumber::Core::Test::Case.new([ Cucumber::Core::Test::Step.new([]).with_action { fail } ], [])
class Report
def before_test_case(test_case)
end
def before_test_step(test_step)
end
package shouty.web;
import com.mockrunner.mock.web.MockFilterConfig;
import com.mockrunner.mock.web.MockHttpServletRequest;
import com.mockrunner.mock.web.WebMockObjectFactory;
import com.mockrunner.servlet.ServletTestModule;
import org.junit.Before;
import spark.servlet.SparkApplication;
import spark.servlet.SparkFilter;
# Responsible for mapping a hash of parameters that will typically be POSTed to a controller into a hash that can be sent to find(:all)
# containing SQL clauses in :conditions / :order.
# This helps us decouple the view / controller layers from any database specific stuff.
class Venue::QueryAdapter < Hash
def initialize(params)
parse params
self.merge!(get_find_params)
@mattwynne
mattwynne / gist:11764
Created September 20, 2008 15:46
undefined
# put this in your features/steps/env.rb to clean up any AR objects created during a scenario before the next one runs
module CleanUp
class << self
attr_accessor :log
end
def self.record(obj)
@objects ||= {}
@objects[obj.class] ||= []
require 'rubygems'
require 'spec'
class Team
def initialize(game)
@game = game
end
def do_substitution
def within_list(css_class)
css_selector = css_class.gsub(/ /, '.') #stack the css classes for selection
list = current_dom.at("ol.#{css_selector}") || current_dom.at("ul.#{css_selector}") # Could add an opt param to the method to make this explicit - for now we don't care
assert_not_nil(list, "Expected to find a ul or li tag matching the css class '#{css_class}'")
yield list
end
Then /^I should see the text "(.*)" in the "(.*)" list$/ do |text, css_class| #"
within_list(css_class) do |list|
matching_list_items = list.search("li").select{ |li| strip_html_tags_from(li.inner_html) =~ escape_text_for_regexp(text) }
#
# Here is a (simplistic) example of a class with, arguably, too many responsibilites.
# Methods are clustered together in the file to maintain a semblance of cohesion, but there is no enapsulation of these
# behaviours. A class like this will grow ugly and over-complex.
#
# Forcing yourself to order the methods alphabetically would be one way to alert you to these multiple responsibilities,
# because you would feel uncomfortable breaking up the cohesive clusters of methods in order to sort them by this
# arbitrary rule.
#
class BloatedUser