Skip to content

Instantly share code, notes, and snippets.

View natritmeyer's full-sized avatar
🧛‍♂️
Summoning code

Nat Ritmeyer natritmeyer

🧛‍♂️
Summoning code
View GitHub Profile
@natritmeyer
natritmeyer / integer_position_suffix.rb
Created January 6, 2012 14:59
Ruby monkeypatch: Integer#position_suffix
# 1.position_suffix => "st"
# 2.position_suffix => "nd"
# 3.position_suffix => "rd"
# 4.position_suffix => "th"
# 11.position_suffix => "th"
# 21.position_suffix => "st"
# 345678.position_suffix => "th"
class Integer
def position_suffix
@natritmeyer
natritmeyer / daily_readings_generator.rb
Last active September 29, 2015 02:38
Robert Roberts Daily Readings iCalendar file generator and output
=begin
Copyright (c) 2011, Nathaniel Ritmeyer
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
@natritmeyer
natritmeyer / tag_based_logic.rb
Created December 12, 2011 18:20
A cucumber formatter to allow doing stuff when a tag is first come across
#cucumber -f TestManagement::TagLogic -o /dev/null
module TestManagement
class TagLogic
#leave this alone...
def initialize(step_mother, io, options)
@old_tags = []
end
#leave this alone too...
@natritmeyer
natritmeyer / purge.rb
Created November 1, 2011 12:07
HTTP Purge, for use with Varnish
require 'rest-client'
class Net::HTTP::Purge < Net::HTTPRequest
METHOD = 'PURGE'
REQUEST_HAS_BODY = false
RESPONSE_HAS_BODY = true
end
module RestClient
def self.purge(url, headers={}, &block)
@natritmeyer
natritmeyer / Counter_03.cs
Created August 27, 2011 13:38
BDD example with WPF, cucumber, ironruby and bewildr; Part 4
public void reset()
{
currentCount = 0;
}
@natritmeyer
natritmeyer / Counter_02.cs
Created August 27, 2011 12:37
BDD example with WPF, cucumber, ironruby and bewildr; Part 3
namespace Counter
{
public class Counter
{
private int currentCount;
public Counter()
{
currentCount = 0;
}
@natritmeyer
natritmeyer / Counter_01.cs
Created August 27, 2011 11:22
BDD example with WPF, cucumber, ironruby and bewildr; Part 2
namespace Counter
{
public class Counter
{
private int currentCount;
public Counter()
{
currentCount = 0;
}
@natritmeyer
natritmeyer / Rakefile_01.rb
Created August 24, 2011 19:06
BDD example with WPF, cucumber, ironruby and bewildr; Part 1
require 'rubygems'
require 'rspec/core/rake_task'
require 'cucumber/rake/task'
include Rake::DSL
desc "Acceptance Tests"
RSpec::Core::RakeTask.new do |t|
t.pattern = "spec/**/*_spec.rb"
end
@natritmeyer
natritmeyer / monkeypatch.rb
Created June 5, 2011 17:17
RSpec monkeypatch to expose scenario outcome in after block with Example#passed? and Example#failed? methods
class RSpec::Core::Example
def passed?
@exception.nil?
end
def failed?
!passed?
end
end
@natritmeyer
natritmeyer / Program.cs
Created May 11, 2011 18:10
A tiny c# app that operates the Open File dialog using White. Useful if you're testing a WPF app with bewildr (http://www.bewildr.info) but the app you're testing uses the old Win32 dialog boxes. The compiled exe takes one arg; the value you want typed in
/*
Create a console app, add references to the various white libraries and use the following as a template for operating the Open Dialog window
Get the white binaries from here: http://white.codeplex.com/
*/
using System.Collections.Generic;
using System.Linq;
using System.Windows.Automation;
using White.Core;
using White.Core.UIItems;