Skip to content

Instantly share code, notes, and snippets.

Phillip Calvin pnc

Block or report user

Report or block pnc

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
pnc / AppDelegate.m
Created Jan 10, 2012
Core Data -willSave example
View AppDelegate.m
- (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"];
pnc /
Created Aug 4, 2011
This is what happens when you work with Emacs users.
(for own key, value of assignable_attributes
attribute_scope = $('#reservation_' + key)
(for own key, value of ui.item.attribute_labels
pnc / deprecation.rb
Created Jul 26, 2011
Moar deprecation warnings
View deprecation.rb
set_trace_func( 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})"
pnc / ruby_block.rb
Created Jun 28, 2011
Ruby blocks and required parentheses
View ruby_block.rb
def group(symbol, &block)
symbol = :cheese
# Simple argument-and-block form:
group symbol do
puts "hello"
end # => "hello"
View gist:1017519
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)
pnc / gist:645582
Created Oct 25, 2010
Job scheduler using greedy algorithm
View gist:645582
(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))
pnc / delegate_proc.rb
Created Oct 23, 2010
Groovy's delegate method, implemented for Ruby Procs
View delegate_proc.rb
# 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}"
def self.child(name)
View spec_helper.rb
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 ="debug-tree")
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):
You can’t perform that action at this time.