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/python | |
import socket | |
import struct | |
import sys | |
# We want unbuffered stdout so we can provide live feedback for | |
# each TTL. You could also use the "-u" flag to Python. | |
class flushfile(file): | |
def __init__(self, f): |
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 "tempfile" | |
require 'spec/runner/formatter/html_formatter' | |
require "cgi" | |
# When we're running specs, modify our class under test to create | |
# an image tag when it is inspected. | |
class Tree | |
def inspect | |
file = Tempfile.new("debug-tree") | |
self.to_image(file.path) |
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
# The idea here is to emulate Groovy's delegate= pattern for closures. | |
# We define a builder module. This will receive method calls | |
# from our builder. It could be an instance of an object if we wanted. | |
module FamilyBuilder | |
def self.parent(name) | |
puts "Parent: #{name}" | |
end | |
def self.child(name) |
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 racket/pretty) | |
(define (job start end) (list start end)) | |
(define (job-with-duration start duration) | |
(job start | |
(+ start duration))) | |
(define (job-end job) | |
(second job)) |
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
Nebula:mailcatcher(master) $ rake --trace | |
(in /Users/phil/Development/ruby/mailcatcher) | |
** Invoke default (first_time) | |
** Invoke build (first_time) | |
** Invoke build:sass (first_time) | |
** Execute build:sass | |
** Invoke build:coffee (first_time) | |
** Execute build:coffee | |
** Invoke build:rdoc (first_time) | |
** Invoke rdoc (first_time) |
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 group(symbol, &block) | |
block.call | |
end | |
symbol = :cheese | |
# Simple argument-and-block form: | |
group symbol do | |
puts "hello" | |
end # => "hello" |
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
set_trace_func(Proc.new do |event, file, line, id, binding, classname| | |
if rand > 0.999 | |
puts "warning: #{classname} is deprecated and will be removed in a future release" | |
puts " (called from: #{file}:#{line})" | |
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
(for own key, value of assignable_attributes | |
attribute_scope = $('#reservation_' + key) | |
attribute_scope.val(value) | |
attribute_scope.change() | |
) | |
(for own key, value of ui.item.attribute_labels | |
$(".reservation-label-#{key}").html(value) | |
) |
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
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
{ | |
NSError *error = nil; | |
// Load the data model | |
NSManagedObjectModel *model = [NSManagedObjectModel mergedModelFromBundles:nil]; | |
// Set up the SQLite store | |
NSURL *documentsDirectory = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]; | |
NSURL *storeURL = [documentsDirectory URLByAppendingPathComponent:@"Example.sqlite"]; |
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
--- 1.txt 2012-04-06 14:09:33.000000000 -0400 | |
+++ 2.txt 2012-04-06 14:09:45.000000000 -0400 | |
@@ -119,28 +119,35 @@ | |
} | |
//END:progressivelyMigrateURLFindModels | |
//See if we can find a matching destination model | |
//START:progressivelyMigrateURLFindMap | |
NSMappingModel *mappingModel = nil; |
OlderNewer