Skip to content

Instantly share code, notes, and snippets.

View codahale's full-sized avatar
🦆
Look at all these chickens

Coda Hale codahale

🦆
Look at all these chickens
View GitHub Profile
@codahale
codahale / gist:41459
Created December 30, 2008 00:45 — forked from damon/gist:41453
def whack(objects)
return Hash[*objects.map{ |o| [o.send("table_name"), o.send("delete_all")] }.flatten]
end
#!/usr/bin/env ruby
# Written by Coda Hale <coda.hale@gmail.com>. MIT License. Go for it.
def include_pattern(filename)
core = filename.gsub(/_spec/, "").gsub(/\Aspec\//, "")
return Regexp.quote(core)
end
if ARGV.empty? || ARGV == ["--help"] || ARGV == ["-h"]
STDERR.puts("Usage:")
--- LastFM - Ban Current Track
set previousApp to name of (info for (path to frontmost application))
tell application "Last.fm" to activate
tell application "System Events" to keystroke "b" using command down
open location "x-launchbar:hide"
tell application previousApp to activate
# coda@lunchbox /L/R/G/1/specifications> less jsonpretty-1.0.0.gemspec
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{jsonpretty}
s.version = "1.0.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Nick Sieger"]
s.date = %q{2009-02-19}
#!/usr/bin/env ruby
$existing_methods = []
def print_methods(library)
new_methods = [].methods.sort - $existing_methods
for method in new_methods
puts "Array##{method}"
end
puts "(total: #{new_methods.size} added by #{library})\n\n"
@Path("/hello")
@Produces(MimeType.TEXT_PLAIN)
public class HelloResource {
@GET
public Response sayHello(@DefaultValue("stranger") @QueryParam("name") String name) {
return Response.ok("Hello, " + name).build();
}
}
@RunWith(Enclosed.class)
public class ThingTest {
public static class An_Empty_Thing {
private Thing thing;
@Before
public void setup() throws Exception {
this.thing = new Thing();
}
lunchbox /tmp> ministat -w 60 iguana chameleon
x iguana
+ chameleon
+------------------------------------------------------------+
|x * x * + + x +|
| |________M__|___A____________M__A___________________| |
+------------------------------------------------------------+
N Min Max Median Avg Stddev
x 7 50 750 200 300 238.04761
+ 5 150 930 500 540 299.08193
tell application "Mail"
set selectedMessages to the selection
set mailboxMap to {{accountName:"Work", archive:"All Mail"}, {accountName:"Gmail", archive:"All Mail"}}
repeat with mapItem in mailboxMap
set archiveMailbox to the mailbox (archive of mapItem) of account (accountName of mapItem)
set messagesToMove to {}
repeat with msg in selectedMessages
if name of the mailbox of msg is "INBOX" then
if name of the account of the mailbox of msg is (accountName of mapItem) then
val encoded = BERT(1, 2, 3).toArray
BERT.parse(encoded) match {
case BERT(Tuple(x, y, z)) => println("Parsed a tuple: " + x + ", " + y + ", " + z)
case e => println("Unable to parse a tuple: " + e)
}