Skip to content

Instantly share code, notes, and snippets.

@pnc
pnc / deprecation.rb
Created July 26, 2011 01:18
Moar deprecation warnings
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)
@pnc
pnc / ruby_block.rb
Created June 28, 2011 15:50
Ruby blocks and required parentheses
def group(symbol, &block)
block.call
end
symbol = :cheese
# Simple argument-and-block form:
group symbol do
puts "hello"
end # => "hello"
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
pnc / gist:645582
Created October 25, 2010 19:42
Job scheduler using greedy algorithm
(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
pnc / delegate_proc.rb
Created October 23, 2010 16:15
Groovy's delegate method, implemented for Ruby Procs
# 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)
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)
@pnc
pnc / generate.rb
Last active August 29, 2015 14:24
Declare Xcode project files
require 'xcodeproj'
# Avoid spaces, otherwise automatic crash symbolication breaks.
# To change how it appears to the user, set Bundle Display Name in the Info plist.
TARGET_NAME = "ExampleApp"
CONFIG = {"APP_BUNDLE_ID" => "com.example.example-app",
"ASSETCATALOG_COMPILER_APPICON_NAME" => {debug: "AppIconDevelopment",
release: "AppIcon"},
"ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME" => "LaunchImage"}

Here is a link

Bacon::Error: File comparison error `execution_output.txt` for install_custom_workspace:
--- DIFF -----------------------------------------------------------------------
Attempting to activate Reachability (3.1.0)
Activated Reachability at Reachability (3.1.0)
Requiring nested dependencies ()
- Creating possibility state for Reachability (3 remaining)
- Attempting to activate Reachability (3.1.1)
+ Creating possibility state for Reachability (4 remaining)
+ Attempting to activate Reachability (3.2)
Found existing spec (Reachability (3.1.0))
@pnc
pnc / gist:d6f84f65ea1dbc73367d
Created December 2, 2014 20:29
Build failures on 76c22f4959ff12ecef3c43c11af2394d31bfc8d4,
$ ruby --version
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0]
$ bundle exec rake
rm -rf banana-lib && tar zxf banana-lib.tar.gz
Using ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0]