Skip to content

Instantly share code, notes, and snippets.

View NigelThorne's full-sized avatar

Nigel Thorne NigelThorne

View GitHub Profile
@NigelThorne
NigelThorne / while.rb
Created January 18, 2013 11:43
Functional While look in ruby
class While
def initialize(&src_fn)
@src_fn = src_fn
end
def do
x = @src_fn.call
while(x)
yield(x)
x = @src_fn.call
@NigelThorne
NigelThorne / _step.erb
Last active December 11, 2015 12:38
Problem going to Rails 3
<li class='step'>
<%= sf.hidden_field :id %>
<%= sf.hidden_field :step_definition_id %>
<%= sf.hidden_field :position ,:class=>"position"%>
<%= sf.object.format_with_params { |param| render(:partial=>'scenarios/param' , :locals=>{:param=> param, :sf=>sf})} %>
<% if sf.object.new_record? %>
<%= link_to "Remove", '#', :onclick =>"$(this).parent('.step').remove()" %>
<% else %>
<%= sf.check_box '_destroy' %>
@NigelThorne
NigelThorne / gist:4718832
Created February 5, 2013 23:48
composing parslet parsers
require 'rubygems'
require 'parslet'
#This needs a few more 'as' calls to annotate the output
class JSONParser < Parslet::Parser
def initialize(number_parser)
@number_parser
end
rule(:space) { match('[\s\n]').repeat(1)}
@NigelThorne
NigelThorne / index.html
Last active December 17, 2015 19:29
POC for generating tests from template files.
<html>
<body>
<table width='100%'>
<tr>
<td>Select a TestTemplate File to Load:</td>
<td><input type="file" id="fileToLoad">
<td><a href="javascript:loadFileAsText()">Load Selected File</a><td>
</tr>
<tr>
<td colspan="3">
@NigelThorne
NigelThorne / dump_qc_to_folder.rb
Last active April 17, 2018 12:42
Runs on Windows. Assumes you have QC installed. The code needs some love, but does work.
$:.unshift File.expand_path(File.dirname(__FILE__))
require 'win32ole'
require 'qc_automation'
require 'qc_test'
require 'fileutils'
module QCIntegration
class TestFolder
attr_accessor :kids
@NigelThorne
NigelThorne / overlay_ESRB_in_Steam.js
Last active January 28, 2016 12:44
Add ESRB ratings icons to steam store. I used the "Control Freak" chrome extension to add the following script. Add a script for http://http://store.steampowered.com/ pasting the text below Add Jquery 2.0.2 (http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js) in the Libs section. Reload http://store.steampowered.com/
$(".tab_desc h4").each(function(e){
var self = $(this);
var game = $(this).text().split(" ").join("+");
// var data = {
// titleOrPublisher: self.text(),
// isIncluding: false,
// rating: "",
// ratingsCriteria: "",
// platforms: "",
@NigelThorne
NigelThorne / gist:7671000
Created November 27, 2013 05:18
I like duckduckgo.. but it bothers me that it's above my google results. So.. i moved it I use control freak google chrome plugin to run greasemonkey type scripts.
function move_duckduckgo(){
var node = document.getElementById('ddg_zeroclick');
if(node != null){
document.getElementById('rhs').appendChild(node);
} else {
setTimeout(move_duckduckgo, 10);
}
}
move_duckduckgo();
@NigelThorne
NigelThorne / Gemfile
Last active March 4, 2016 06:23
AutoHotKey_L script to TTS the currently selected text.
source "http://rubygems.org"
gem "eventmachine", "1.0.8"
gem "thin"
gem "win32-service"
gem "sinatra"
require 'parslet'
class Parslet::Atoms::FixedLength < Parslet::Atoms::Base
attr_reader :len, :parslet
def initialize(parslet, len, tag=:length)
super()
raise ArgumentError,
"Asking for zero length of a parslet. (#{parslet.inspect} length #{len})" \
if len == 0
@NigelThorne
NigelThorne / example.rb
Last active August 29, 2015 13:57
Parslet example of transforms with default values
require 'pp'
require 'parslet'
module Example # as in 'lots of insipid and stupid parenthesis'
class Parser < Parslet::Parser
rule(:ws) { match('[\s]').repeat(1) }
rule(:ws?) { ws.maybe }
rule(:number) { match('[0-9]').repeat(1) }
rule(:offset) { ws? >> str("[") >> number.as(:offset) >> str("]") }