Skip to content

Instantly share code, notes, and snippets.

View aselder's full-sized avatar

Andrew Selder aselder

View GitHub Profile
require 'spec_helper'
class ATesterDashboardController < TesterDashboard::ApplicationController
def index
render text: 'yes'
end
end
describe ATesterDashboardController do
context "logged in as a tester" do
@aselder
aselder / gist:6208328
Last active December 20, 2015 22:49
Calculate the number of suspensions a player receives in an IBL season
CHANCE_OF_WILD_PLAY = 0.011
CHANCE_OF_TEST_ON_WP = 0.015
CHANCE_TO_FAIL = 0.70
PAS_PER_GAME = (76..90)
SUSPENSION = { 1 => 50, 2 => 100, 3 => 100}
NUM_RUNS = 50000
def fail_game(pas)
(1..pas).any? {|pa_num| rand < (CHANCE_OF_WILD_PLAY * CHANCE_OF_TEST_ON_WP * CHANCE_TO_FAIL)}
end
nokogiri (>= 1.4.0)
arel (3.0.2)
awesome_print (1.1.0)
- bouncy-castle-java (1.5.0146.1)
+ bouncy-castle-java (1.5.0147)
builder (3.0.4)
capistrano (2.14.2)
highline
@@ -38,92 +38,94 @@ GEM
celluloid (0.12.4)
@aselder
aselder / gist:2766020
Created May 22, 2012 01:41
XML data for nokogiri race condition
<?xml version="1.0"?>
<ArrayOfTicket xmlns="http://schemas.datacontract.org/2004/07/RazorGator.Contract" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Ticket>
<AvailableBlocks xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:int>7</a:int>
<a:int>5</a:int>
<a:int>4</a:int>
<a:int>3</a:int>
<a:int>2</a:int>
<a:int>1</a:int>
@aselder
aselder / gist:2766012
Created May 22, 2012 01:39
Test script demonstrating Nokogiri thread safety
require 'open-uri'
require 'nokogiri'
MS_ARRAY_SCHEMA = "http://schemas.microsoft.com/2003/10/Serialization/Arrays".freeze
def job
begin
data = Nokogiri::XML(open("file.xml"))
rows = data.xpath(".//xmlns:ArrayOfTicket/xmlns:Ticket")
rows.each do |row|
@aselder
aselder / gist:1354274
Created November 10, 2011 06:35
HTML Fragment
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html><head><title>Statistics Report for HAProxy</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<style type="text/css"><!--
body { font-family: arial, helvetica, sans-serif; font-size: 12px; font-weight: normal; color: black; background: white;}
th,td { font-size: 10px;}
h1 { font-size: x-large; margin-bottom: 0.5em;}
h2 { font-family: helvetica, arial; font-size: x-large; font-weight: bold; font-style: italic; color: #6020a0; margin-top: 0em; margin-bottom: 0em;}
h3 { font-family: helvetica, arial; font-size: 16px; font-weight: bold; color: #b00040; background: #e8e8d0; margin-top: 0em; margin-bottom: 0em;}
@aselder
aselder / gist:1354268
Created November 10, 2011 06:32
Correct Document
#<Nokogiri::HTML::Document:0x3fefde0fafec name="document" children=[#<Nokogiri::XML::DTD:0x3fefde0fac7c name="HTML">,
#<Nokogiri::XML::Element:0x3fefde0fa4fc name="html" children=[#<Nokogiri::XML::Element:0x3fefde0fa2f4 name="head"
children=[#<Nokogiri::XML::Element:0x3fefde0fa0ec name="title" children=[#<Nokogiri::XML::Text:0x3fefde0f9ee4
"Statistics Report for HAProxy">]>, #<Nokogiri::XML::Element:0x3fefde0f9c64 name="meta"
attributes=[#<Nokogiri::XML::Attr:0x3fefde0f9c00 name="http-equiv" value="content-type">,
#<Nokogiri::XML::Attr:0x3fefde0efde0 name="content" value="text/html; charset=iso-8859-1">]>,
#<Nokogiri::XML::Element:0x3fefde0ef5e8 name="style" attributes=[#<Nokogiri::XML::Attr:0x3fefde0ef584 name="type"
value="text/css">] children=[#<Nokogiri::XML::CDATA:0x3fefde0eb010 "<!--\nbody { font-family: arial, helvetica,
sans-serif; font-size: 12px; font-weight: normal; color: black; background: white;}\nth,td { font-size: 10px;}\nh1 {
font-size: x-large; margin-bottom: 0.5em;}\nh2 { font-family: helve
@aselder
aselder / gist:1354253
Created November 10, 2011 06:20
Mangled Nokogiri Doc
#<Nokogiri::HTML::Document:0x..fdbc0ebe8 name="document" children=[#<Nokogiri::XML::DTD:0x..fdbc0e526 name="HTML">,
#<Nokogiri::XML::Comment:0x..fdbc0e4fe "\nbody { font-family: arial, helvetica, sans-serif; font-size: 12px; font-weight:
normal; color: black; background: white;}\nth,td { font-size: 10px;}\nh1 { font-size: x-large; margin-bottom: 0.5em;}\nh2
{ font-family: helvetica, arial; font-size: x-large; font-weight: bold; font-style: italic; color: #6020a0; margin-top:
0em; margin-bottom: 0em;}\nh3 { font-family: helvetica, arial; font-size: 16px; font-weight: bold; color: #b00040;
background: #e8e8d0; margin-top: 0em; margin-bottom: 0em;}\nli { margin-top: 0.25em; margin-right: 2em;}\n.hr
{margin-top: 0.25em; border-color: black; border-bottom-style: solid;}\n.titre\t{background: #20D0D0;color: #000000;
font-weight: bold; text-align: center;}\n.total\t{background: #20D0D0;color: #ffff80;}\n.frontend\t{background: #e8e8d0;}
\n.socket\t{background: #d0d0d0;}\n.backend\t{background: #e8e8d0;}\n.act
@aselder
aselder / gist:1331173
Created November 1, 2011 16:57
Compilation error under 1.3.5
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/andrew/.rvm/rubies/ruby-1.9.3-p0/bin/ruby extconf.rb
extconf.rb:7: Use RbConfig instead of obsolete and deprecated Config.
Touching aclocal.m4 in libmemcached.
touch -r libmemcached-0.32/m4/visibility.m4 libmemcached-0.32/configure.ac libmemcached-0.32/m4/pandora_have_sasl.m4 libmemcached-0.32/m4/aclocal.m4
Configuring libmemcached.
env CFLAGS='-fPIC -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Werror=pointer-arith -Werror=write-strings -Werror=shorten-64-to-32 -Werror=implicit-function-declaration -pipe -pipe' LDFLAGS='-fPIC -L. -L/usr/local/lib -L. -L/usr/local/lib -L/Users/andrew/.rvm/rubies/ruby-1.9.3-p0/lib' ./configure --prefix=/Users/andrew/.rvm/gems/ruby-1.9.3-p0/gems/memcached-1.3.5/ext --without-memcached --disable-shared --disable-utils --disable-dependency-tracking CC="clang" 2>&1
checking build system type... i386-apple-darwin11.2.0
@aselder
aselder / gist:1168728
Created August 24, 2011 18:08
Coverage blowup on EBay gem
/Users/andrew/.rvm/gems/ruby-1.9.2-p290/gems/ebay-1.1/lib/eBayMappingRegistry.rb:31220: [BUG] bug
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.1.0]
-- control frame ----------
c:0033 p:66249 s:0108 b:0108 l:000107 d:000107 CLASS /Users/andrew/.rvm/gems/ruby-1.9.2-p290/gems/ebay-1.1/lib/eBayMappingRegistry.rb:31220
c:0032 p:0039 s:0106 b:0106 l:000105 d:000105 TOP /Users/andrew/.rvm/gems/ruby-1.9.2-p290/gems/ebay-1.1/lib/eBayMappingRegistry.rb:4
c:0031 p:---- s:0104 b:0104 l:000103 d:000103 FINISH
c:0030 p:---- s:0102 b:0102 l:000101 d:000101 CFUNC :require
c:0029 p:0027 s:0098 b:0098 l:000097 d:000097 TOP /Users/andrew/.rvm/gems/ruby-1.9.2-p290/gems/ebay-1.1/lib/eBayDriver.rb:2
c:0028 p:---- s:0096 b:0096 l:000095 d:000095 FINISH