This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use HTTP::Status; | |
use Term::ANSIColor qw(:constants); | |
use URI; | |
my %users; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<key>CFBundleURLTypes</key> | |
<array> | |
<dict> | |
<key>CFBundleURLName</key> | |
<string>com.innerfence.ChargeDemo</string> | |
<key>CFBundleURLSchemes</key> | |
<array> | |
<string>com-innerfence-ChargeDemo</string> | |
</array> | |
</dict> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IFChargeRequest* chargeRequest = | |
[[[IFChargeRequest alloc] init] autorelease]; | |
chargeRequest.amount = @"50.00"; | |
chargeRequest.description = @"Test transaction"; | |
chargeRequest.invoiceNumber = @"321"; | |
[chargeRequest submit]; |