Skip to content

Instantly share code, notes, and snippets.

View triskweline's full-sized avatar

Henning Koch triskweline

View GitHub Profile
### Keybase proof
I hereby claim:
* I am henning-koch on github.
* I am triskweline (https://keybase.io/triskweline) on keybase.
* I have a public key whose fingerprint is 17CF 7D9F 8992 66DA CB28 7332 9169 5476 8F13 232D
To claim this, I am signing this object:
@triskweline
triskweline / patterns.rb
Last active September 1, 2015 14:20
Regular expression to sanity check URLs
URL = %r{
\A # Beginning of string
(http|https) # $1: Scheme
:\/\/ # ://
([\w\-_]+(?:\.[\w\-_]+)*) # $2: Hostname. Does not begin or end with a dot. No two dots in a row.
(?::(\d+)) # $3: Port (without leading colon)
(/[^/\?\#]*) # $4: Path (with leading slash)
(?:\?([^\#]*)) # $4: Query (without leading question mark)
(?:\#(.*)) # $5: Hash (without leading hash)
\z # End of string
ul.tree
cursor: pointer
$self_color: desaturate($COLOR_MIDNIGHT_BLUE - 10, 20)
$darkening_per_level: 10
$indent: 28px
.self
background-color: $self_color
# Copy this to features/support/ssl_fix.rb to make Capybara work with sites that switch between HTTP and HTTPS
module Capybara::Driver::RackTest::SslFix
[:get, :post, :put, :delete].each do |method|
define_method method do |*args|
args[0] = path_to_ssl_aware_url(args[0])
super(*args)
end
end
@triskweline
triskweline / contact_spec.rb
Created July 5, 2012 21:20
Production example where factories are useful vs. a global set of fixtures.
describe Contract do
describe '.overlapping' do
it 'should match a contract partially overlapping the given contract' do
match = Contract.make(:start_date => Date.today + 5, :end_date => Date.today + 10)
given = Contract.new(:start_date => Date.today + 7, :end_date => Date.today + 12)
Contract.overlapping(given).all.should == [match]
end
- ofo
- bar
bam
- zzz
Test
- foo
- bar
baz
- bam
Foo
- foo
- bar
code
code
- baz
xml.instruct!
xml.rss :version => '2.0', 'xmlns:atom' => 'http://www.w3.org/2005/Atom' do
xml.channel do
xml.title "makandra cards for #{@user.public_name}"
xml.link sites_url
xml.language 'en'
xml.tag! 'atom:link', :rel => 'self', :type => 'application/rss+xml', :href => sites_url
for note in @notes