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
--- | |
host: twitter.com | |
scheme: http | |
auth: httpbasic | |
version: 2008-07-07T00:00:00-0800 | |
parameters: | |
id: | |
type: id | |
required: False | |
id_num: |
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 | |
# | |
# Little command-line utility for telling you stuff about your Mac without | |
# having to click around all over the place. Originally found here and | |
# then cleaned up significantly: http://gist.github.com/1617 | |
# | |
import sys | |
import commands | |
import plistlib |
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 | |
# vim:set ts=4 sw=4 et ai: | |
# Retrieve the SSH public key and install it for subsequent login attempts. | |
AUTHORIZED_KEYS=/root/.ssh/authorized_keys | |
TMP_KEY=/tmp/openssh_id.pub | |
CURL=/usr/bin/curl | |
CURLOPTS="--retry 3 --retry-delay 2 --silent --fail -o $TMP_KEY" | |
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
# vim:set ts=4 sw=4 et ai: | |
from __future__ import with_statement | |
""" | |
:Author: Toby DiPasquale <[email protected]> | |
:Copyright: Copyright (c) 2008 Toby DiPasquale. Free for use for any purpose | |
by anyone forever. | |
Introduction | |
============ |
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
/* | |
* Test for recursive, tail-recursive and iterative functions | |
* solving the same problem (factorial) to test execution speed | |
* on an X86 processor. | |
* | |
* Found: | |
* http://mpathirage.com/recursion-non-recursion-and-tail-recursion-test/ | |
* | |
* Cleaned up by Toby DiPasquale <[email protected]> | |
* |
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
if ENV['BENCHMARK_TESTS'] && ENV['BENCHMARK_TESTS'] == 'on' | |
class Test::Unit::TestCase | |
# Replaces the regular Test::Unit::TestCase#run method with one that | |
# does benchmarking of each test method in a test case | |
def run result | |
yield(STARTED, name) | |
@_result = result | |
begin | |
setup |
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
{:one => 1, :two => 2}.map {|k,v| k == :one ? v : nil}.compact |
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
(in /Users/toby/code/friendly) | |
All dependencies seem to be installed. | |
/opt/ruby-enterprise-1.8.6-20090201/lib/ruby/gems/1.8/gems/json-1.1.3/lib/json/common.rb:60: warning: already initialized constant State | |
.................................................................................FFFFFFF......................................................................................................................................... | |
1) | |
NoMethodError in 'Friendly::DataStore retrieving all based on a query gets the data from the dataset for the klass and makes it an arary' | |
undefined method `map' for nil:NilClass | |
/Users/toby/code/friendly/spec/../lib/friendly/data_store.rb:20:in `all' | |
./spec/unit/data_store_spec.rb:29: |
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 'yaml' | |
class Hash | |
def filter(*keys) | |
self.inject({}) {|h,(k,v)| h[k] = v if keys.include?(k); h} | |
end | |
end | |
test_hash = {'one' => 1, 'two' => 2, 'three' => 3} | |
puts test_hash.to_yaml |
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
# Power law (log tail) distribution | |
# Copyright(C) 2010 Salvatore Sanfilippo | |
# this code is under the public domain | |
# min and max are both inclusive | |
# n is the distribution power: the higher, the more biased | |
def powerlaw(min,max,n) | |
max += 1 | |
pl = ((max**(n+1) - min**(n+1))*rand() + min**(n+1))**(1.0/(n+1)) | |
max-1-pl.to_i |
OlderNewer