Skip to content

Instantly share code, notes, and snippets.

{:one => 1, :two => 2}.map {|k,v| k == :one ? v : nil}.compact
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
@codeslinger
codeslinger / gist:6389
Created August 20, 2008 15:21
Recursive, iterative and tail-recursive performance test for X86 (with factorial)
/*
* 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]>
*
# 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
============
@codeslinger
codeslinger / gist:3494
Created July 31, 2008 18:19
Robust script to retrieve SSH public key into authorized_keys for EC2 instances
#!/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"
@codeslinger
codeslinger / gist:1689
Created July 23, 2008 11:52
Utility to give system info about a Mac
#!/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
@codeslinger
codeslinger / gist:1513
Created July 23, 2008 03:42
YAML layout of Twitter API
---
host: twitter.com
scheme: http
auth: httpbasic
version: 2008-07-07T00:00:00-0800
parameters:
id:
type: id
required: False
id_num: