Skip to content

Instantly share code, notes, and snippets.

View IdahoEv's full-sized avatar

Evan Dorn IdahoEv

View GitHub Profile
module ClassRegistry
module ClassMethods
def registry
@registry ||= {}
end
def register(role_name, klass=self)
registry[role_name] = klass
end
describe 'static/index' do
let :mock_restaurant do
double(User, :meals_served => 5)
end
let! :array_of_restaurants do
[ mock_restaurant, mock_restaurant, mock_restaurant, mock_restaurant, mock_restaurant ]
end
before do
describe '/path/:id/other/:sub_id' do
# 536 cases recorded by Fluoride
# Exit code 200 success
# See example: 'exchange-2-69825934893380-24.yml'
describe "successful request" do
it "Should succeed " do
get 'path/__/other__'
# TODO
var GameWindow = (function () {
var my = {},
//privateVariable = 1,
canvas,
context,
width,
height,
scale = 16; // pixels per unit size. Tank height/width is 1.0 unit size.
//function privateMethod() {
@IdahoEv
IdahoEv / gist:ff47a95b901640519099
Created August 4, 2014 15:35
Elixir crash report with backtrace
Interactive Elixir (0.14.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> init. Starting timer
=ERROR REPORT==== 4-Aug-2014::08:34:38 ===
Error in process <0.244.0> with exit value: {[{reason,badarith},{mfa,{'Elixir.WebsocketHandler',websocket_info,3}},{stacktrace,[{'Elixir.WebsocketHandler',websocket_info,3,[{file,"lib/websocket_handler.ex"},{line,39}]},{cowboy_websocket,handler_call,7,[{file,"sr...
=ERROR REPORT==== 4-Aug-2014::08:34:38 ===
Ranch listener http had connection process started with cowboy_protocol:start_link/4 at <0.244.0> exit with reason: {[{reason,badarith},{mfa,{'Elixir.WebsocketHandler',websocket_info,3}},{stacktrace,[{'Elixir.WebsocketHandler',websocket_info,3,[{file,"lib/websocket_handler.ex"},{line,39}]},{cowboy_websocket,handler_call,7,[{file,"src/cowboy_websocket.erl"},{line,589}]},{cowboy_protocol,execute,4,[{file,"src/cowboy_protocol.erl"},{line,435}]}]},{msg,{timeout,#Ref<0.0.0.1351>,[]}},{req,[{socket,#Port<0.5614>},{transport,ranch_tcp},{connection,keepalive},{pi
18:51:37.888 [error] GenServer :tank_01 terminating
Last message: {:"$gen_cast", :accelerate}
State: %SimpleTank.Tank{name: :tank_01, physics: %SimpleTank.TankPhysics{last_updated: 1407203488.624242, position: %{x: 0, y: 0}, rotation: 0, speed: 0}, tank_list_pid: #PID<0.283.0>}
** (exit) bad cast: :accelerate
defmodule SimpleTank.Tank do
use GenServer
@update_interval 10000
defstruct physics: %SimpleTank.TankPhysics{},
name: :"",
tank_list_pid: 0
@IdahoEv
IdahoEv / gist:adfc01706bd50ef34d9a
Created August 12, 2014 16:15
Accurate decimal math in Ruby with BigDecimal
2.1.0 :009 > 0.3.class
=> Float
2.1.0 :010 > 0.3 - 0.1
=> 0.19999999999999998
2.1.0 :011 > require 'bigdecimal'
=> true
2.1.0 :012 > BigDecimal.new(0.3, 10) - BigDecimal.new(0.1, 10)
Request URL:http://dev.mindswarms.com/studies/827/responses?study_answer_ids%5B%5D=35460&study_answer_ids%5B%5D=35466&study_answer_ids%5B%5D=35467&study_answer_ids%5B%5D=35470&study_answer_ids%5B%5D=35471&study_answer_ids%5B%5D=35472&study_answer_ids%5B%5D=35473&study_answer_ids%5B%5D=35715&study_answer_ids%5B%5D=35716&study_answer_ids%5B%5D=35717&study_answer_ids%5B%5D=35718&study_answer_ids%5B%5D=35719&study_answer_ids%5B%5D=35720&study_answer_ids%5B%5D=35721&study_answer_ids%5B%5D=35494&study_answer_ids%5B%5D=35498&study_answer_ids%5B%5D=35500&study_answer_ids%5B%5D=35504&study_answer_ids%5B%5D=35505&study_answer_ids%5B%5D=35506&study_answer_ids%5B%5D=35507&study_answer_ids%5B%5D=35450&study_answer_ids%5B%5D=35451&study_answer_ids%5B%5D=35452&study_answer_ids%5B%5D=35453&study_answer_ids%5B%5D=35454&study_answer_ids%5B%5D=35455&study_answer_ids%5B%5D=35456&study_answer_ids%5B%5D=35477&study_answer_ids%5B%5D=35478&study_answer_ids%5B%5D=35479&study_answer_ids%5B%5D=35480&study_answer_ids%5B%5D=35482&study_a
// public page resource,
// found at /pages/:slug
{
contents: {
main: {
content_type: "text/html",
body: "Fourscore and <em>seven</em>"
},
headline: {
content_type: "text/html",