Skip to content

Instantly share code, notes, and snippets.

View msassak's full-sized avatar

Mike Sassak msassak

View GitHub Profile
@msassak
msassak / demo.clj
Last active August 29, 2015 13:56
core.async demo
(ns demo
(:require [clojure.core.async :as a :refer [go
go-loop
chan
>!
<!
close]]))
(defn int-producer
"Return a channel containing the integers from 0 to n.
@msassak
msassak / eunit_run.erl
Created April 8, 2014 17:10
eunit test runner script
#!/usr/bin/env escript
-define(dbg(X), io:format("DEBUG: ~p~n", [X])).
-record(args, {primitives = [],
patha = [],
pathz = [],
unrecognized = [],
verbose = false,
help = false}).
start = Time.now
puts "Starting to read file ..."
num = 0
File.open(ARGV[0]) do |f|
f.each { |l| num += l.split.length }
end
puts "The number of tokens is: #{num}."
puts "It took #{(Time.now - start) * 1000} ms"
# tags without a newline after them
# 1a) currently legal:
@hello Feature: foo
@goodbye Scenario: bar
Given baz
# 1b) proposed:
@hello
Feature: foo
@goodbye
# config.ru
require 'appengine-rack'
AppEngine::Rack.configure_app(
:application => 'testapp',
:version => 2)
require 'testapp.rb'
run Sinatra::Application
# testapp.rb
require 'rubygems'
@msassak
msassak / bad_gherkin.features
Created September 16, 2009 16:00
Possible Gherkin error scenarios
# It's difficult to decide what is invalid Gherkin, so I made this gist to try and figure it out
# Empty feature
Feature:
# Feature with GWT in desc
Feature: Suspicious
Given this is bad form
Whenever I do this
Then you should be suspicious because
irb(main):001:0> require 'cucumber'
=> true
irb(main):002:0> sm = Cucumber::StepMother.new
=> #<Cucumber::StepMother:0x1192ca0 @programming_languages=[], @adverbs=["Given", "When", "Then", "And", "But"], @unsupported_programming_languages=[], @language_map={}>
irb(main):003:0> sm.load_code_files("./cuke_steps.rb")
D, [2009-09-16T17:09:05.531395 #8769] DEBUG -- : Code:
D, [2009-09-16T17:09:05.535501 #8769] DEBUG -- : * ./cuke_steps.rb
D, [2009-09-16T17:09:05.535807 #8769] DEBUG -- :
# This will work
x = nil
a = lambda {
if x.nil?
"x is nil, as it should be"
else
"somehow x = #{x}"
end
}
class CommandParser
%%{
machine wire_command_parser;
action parse_error {
@sess.parse_error
}
action command {
command = data[0..p].pack("c*")
msassak@xanthippe:~/Work/gherkin(benchmarks) $ rake bench:tt
(in /Users/msassak/Work/gherkin)
grep Feature /Users/msassak/Work/gherkin/tasks/bench/generated/* | wc -l
1999
grep Scenario /Users/msassak/Work/gherkin/tasks/bench/generated/* | wc -l
10095
grep Given /Users/msassak/Work/gherkin/tasks/bench/generated/* | wc -l
60722
user system total real
183.780000 0.590000 184.370000 (185.416678)