Skip to content

Instantly share code, notes, and snippets.

View pjlsergeant's full-sized avatar
🙇‍♂️
I don't really have time for this anymore

Peter Sergeant pjlsergeant

🙇‍♂️
I don't really have time for this anymore
  • Bangkok, Thailand
View GitHub Profile
// And then...
var square = c.func({
'input': function () {
this.assert( arguments.length == 1, Error("Wrong number of arguments" ) );
this.assert( typeof arguments[0] == 'number', Error('Argument is a number') );
},
'output': function () {
this.assert( typeof arguments[0] == 'number', Error('Output is a number') );
},
'body': function (target) {
Feature: Addition
In order to avoid silly mistakes # These are inline `comments` in the
As a math idiot # form of an Agile User Story. They're
I want to be able to add two numbers # printed out during test execution.
Scenario: Add two numbers # This is a test case
Given I have entered 50 in to the calculator # This is a test *step*
And I have entered 70 in to the calculator # So is this
When I press add # And this
Then the result 120 should be on the screen # And the final one
if ( shipment['gift_message'] ) {
print_gift_message( 'gift-message-printer', shipment['gift_message'] );
}
Given /I have entered (.*) into the calculator/ do |n|
calculator = Calculator.new # Create a new calculator object
calculator.push( n.to_i ) #
end
"TakeMeasurements": {
// Specify the inputs we require. `warehouse` and `product_measurable` are
// custom types defined elsewhere, where `warehouse` is an enumeration of
// the client's warehouses, and `product_measurable` is a boolean value
"inputs": ["Type::warehouse", "Type::product_measurable"],
// Guarantee the type we will return
"output": "Type::Boolean",
// The rule itself. Note how it neither gets or sets any values outside of
"Type::warehouse": {
"constraint": create_enum('WH1', 'WH2'),
"cucumber": {
"type": "Given",
"match" : qr/the warehouse is "(WH\d)"/,
"describe": "the warehouse is \"{0}\"",
}
},
"Type::product_measurable": {
Scenario:
Given the warehouse is WH1
Then we are not required to take measurements
Scenario:
When the product is not measurable
Then we are not required to take measurements
Scenario:
Given the warehouse is WH2
When the product is measurable
Then we are required to take measurements
@pjlsergeant
pjlsergeant / gist:1803656
Created February 11, 2012 19:07
Game of Life in 131 characters of Perl.
#!perl
use strict;
# Accepts a grid size, and a list representing the grid. 131
# characters. RUNS UNDER STRICTURES BABY YEAH.
my$life=sub{$a=shift;map{$b=$_[$_];my$n;$n+=$_[$_]for($_-$a-1..$_-$a+1,$_-1,$_+1,$_+$a-1..$_+$a+1);$n+$b==3||$b&&$n==4||0}0..$#_};
my $result = join '', $life->( 5, qw/
package Roman;
use Moose;
sub AUTOLOAD {
our $AUTOLOAD;
(my $digits = $AUTOLOAD) =~ s/.+:://g;
$digits =~ s/$_->[0]/$_->[1]/
for
[ IV => 'IIII' ],
# Table parsing, old friend... We have spent many long evenings together,
# working through your broken tables, talking about your issues with
# implicit thead elements, and your quirky tr/th heuristics. But ... but
# but it's time for us to move on. We can't keep doing this. It's not you,
# it's me...
#
# I've ... I've met someone new. She's beautiful, she's modern, and she's
# elegant. She's logical, she's clean, and she's well-structured, if you
# know what I mean...
#