Skip to content

Instantly share code, notes, and snippets.

def triangle(a, b, c)
sides = [ a, b, c ]
unless sides.all? { |s| s > 0 }
raise TriangleError, 'Sides must be positive'
end
s1, s2, s3 = sides.sort
unless s1 + s2 > s3
raise TriangleError, 'Sides violate the triangle inequality'
end
my ( $numeral, $word, $last_group ) = m{
([0-9]) # $1 = a numeral
,[ ]
(\w+) # $2 = a word
[ ]
(
[(]
[^(]+
[)]
\s? # Explain here why we want to capture the optional space
#!/bin/bash
#
# mkv2m4v inputfile.mkv
#
# Given an MKV container with H.264 video and AC3 audio, converts
# quickly to an iPad-compatible MP4 container without re-encoding the
# video (so it must already be in an iPad-compatible resolution); the
# audio is downmixed to stereo with Dynamic Range Compression.
#
ME=$(basename $0)
#!/bin/bash
# I use this script to bootstrap the use of a couple of S3 tools, including
# - Net::Amazon::S3::Tools from CPAN, written in perl
# - s3sync rubygem (including the s3cmd utility)
# Put your access key here
export AWS_ACCESS_KEY_ID=accesskey
# This will prompt for the decryption passphrase
#!/usr/bin/env perl
use strict;
use warnings;
use HTTP::Status;
use Term::ANSIColor qw(:constants);
use URI;
my %users;
namespace :git do
task :check_heads do
my_head = run_locally( 'git ls-remote . refs/heads/master' )
origin_head = run_locally( 'git ls-remote origin refs/heads/master' )
if my_head != origin_head
raise "Your master is not in sync with origin"
end
end
end
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.innerfence.ChargeDemo</string>
<key>CFBundleURLSchemes</key>
<array>
<string>com-innerfence-ChargeDemo</string>
</array>
</dict>
IFChargeRequest* chargeRequest =
[[[IFChargeRequest alloc] init] autorelease];
chargeRequest.amount = @"50.00";
chargeRequest.description = @"Test transaction";
chargeRequest.invoiceNumber = @"321";
[chargeRequest submit];