Skip to content

Instantly share code, notes, and snippets.

View NigelThorne's full-sized avatar

Nigel Thorne NigelThorne

View GitHub Profile
module UISpec
class UI < UIDefinition
def initialize(out)
super(out, "", "x.exe")
end
has_tab :slide_setup, {:name => "Slide Setup Tab", :action => show(:slide_setup_screen) }
has_screen :slide_setup_screen do
require 'ruby2ruby'
def refactor(type, method, new_method)
m2 = Ruby2Ruby.translate(type, method).gsub("def #{method}", "def #{new_method}")
type.class_eval("remove_method method\n#{m2}")
end
class X
def z
5
# I want to say all four tabs have the same set of fields
has_dialog :add_reagent_dialog do
def is_a_staining_tab # I don't like this!
has_drop_down :default_staining_protocol1
has_drop_down :default_staining_protocol2
has_drop_down :default_staining_protocol3
has_drop_down :default_staining_protocol4
end
# this fails "Mock 'x' expected :a with (any args) once, but received it twice"
x = mock("x")
x.should_receive(:a).ordered
x.should_receive(:b).ordered
x.should_receive(:a).ordered
x.a
x.b
x.a
Given I am logged in as <Role>
And I have a Protocol <Initial Protocol Details>
When I clone the protocol
Then the new protocol will contain <Cloned Protocol Details>
Examples:
*| Role | Initial Protocol Details ||| Cloned Protocol Details |||
*| | Name | Urgent | Description | Name | Urgent | Description |
Given I am a <role>
And I am on the entity list screen
When I <action> an <state> entity
Then control1 is <control1>
And control2 is <control2>
And control3 is <control3>
Examples:
| role | action | state | control1 | control2 | control3 |
| Admin | [Edit|View] | [new|expired] | Enabled | Enabled | Disabled |
@NigelThorne
NigelThorne / allfast
Created April 24, 2009 06:58
mp3faster - listen to mp3s quicker
find *.mp3 | ruby -e 'while(x=gets) do `mp3faster \"#{x.chomp}\"`;end'
#\ -w -p 8765
use Rack::Reloader, 0
use Rack::ContentLength
use Rack::ShowExceptions
map "/cuce" do |path|
run Proc.new{
command = "cucumber.bat features/nav.feature -f html"
out = `#{command} 2>&1`
[ 200, {'Content-Type' => out=~/\<html/ ? 'text/html' : 'text/plain'}, out ]
require 'memcached'
# Provides a hybrid of memoization and memcacheing. Designed for storing an entire (small)
# table in memory, in every instance of the app. Works well for reference-type tables
# (e.g., Category) which won't ever get big or change often, but are read-heavy. This
# allows you to avoid joins, but also avoid the n+1 queries antipattern.
#
# A pure memoization solution fails when the data *does* change -- all app instances have
# to be restarted for the in-memory caches to be correct. A pure memcached solution solves
# that, but requires a largish amount of data to be retrieved from memcached for every
@NigelThorne
NigelThorne / StringToLambda
Created July 9, 2009 01:22
Helper macro to be used with StoryQ
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Public Module Module1
Sub StoryQConvert()
Dim textSelection As String