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
require 'rubygems' | |
require 'bundler/setup' | |
require 'mongoid' | |
Mongoid.configure do |config| | |
config.master = Mongo::Connection.new('localhost', 27017, :logger => nil).db('mongoid-test') | |
end | |
class A | |
include Mongoid::Document |
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 ruby | |
require 'rational' | |
require 'bigdecimal' | |
PI = BigDecimal.new(" | |
3.141592653589793238462643383279502884197169399375105820974944592307816406286 | |
208998628034825342117067982148086513282306647093844609550582231725359408128481 | |
117450284102701938521105559644622948954930381964428810975665933446128475648233 | |
786783165271201909145648566923460348610454326648213393607260249141273724587006 |
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
# Some modular arithmetic helper methods useful for number theory or | |
# cryptography. | |
# | |
# # Examples | |
# | |
# Compute the greatest common denominator of 114 and 48: | |
# | |
# gcd(114, 48) #=> 6 | |
# | |
# Compute `a` and `b` such that `a*x + b*y = gcd(x, y)`: |
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 ruby | |
# | |
# http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/proposedmodes/ffx/ffx-spec.pdf | |
# http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/proposedmodes/ffx/ffx-spec2.pdf | |
# http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/proposedmodes/ffx/ffx-ad-VAES3.pdf | |
require 'openssl' | |
def radix_block_prepend(radix, n, block) |
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
alias server='open http://localhost:8000 && python -m SimpleHTTPServer' |
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 | |
# | |
# Prerequisites: brew install mpg123 vorbis-tools | |
for fm in "$@"; do | |
f="${fm%.mp3}" | |
if [ "$f" != "$fm" ] && [ -a "$fm" ]; then | |
mpg123 -w - "$f.mp3" | oggenc -o "$f.ogg" - | |
fi | |
done |
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 | |
# dependencies: | |
# sudo port install sox | |
TITLE="On the hour..." | |
MESSAGE="...where are you?" | |
SOUND="/System/Library/Sounds/Hero.aiff" | |
PLAY="/usr/bin/afplay" |
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/sh | |
for file in $*; do | |
advpng -z1 "$file" && optipng -i0 -o7 "$file" && advpng -z4 "$file" | |
done |
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 python | |
# prerequisites | |
# sudo easy_install markdown | |
# install https://code.google.com/p/wkhtmltopdf/ | |
WKHTMLTOPDF_PATH = "/usr/local/bin/wkhtmltopdf" | |
import sys, os, subprocess, re, urllib, tempfile | |
import markdown |
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/sh | |
for file in $*; do | |
jpegtran -optimize -progressive -copy none \ | |
"$file" > "$file.tran" | |
mv -f "$file".tran "$file" | |
done |
NewerOlder