Skip to content

Instantly share code, notes, and snippets.

require 'date'
requrie 'yaml'
class DateTime
yaml_as "tag:ruby.yaml.org,2002:datetime"
def DateTime.yaml_new(klass, tag, val)
if String === val
self.parse(val)
else
require 'java'
require 'iText-2.1.3.jar'
module Java
import 'java.io.FileOutputStream'
import 'com.lowagie.text.pdf.PdfReader'
import 'com.lowagie.text.pdf.PdfStamper'
import 'com.lowagie.text.pdf.PdfWriter'
import 'com.lowagie.text.pdf.BaseFont'
end
#!/usr/bin/env ruby
results = ARGV.shift # input file from cli
measures_full = {'PROP 1A'=>'Safe, Reliable High-Speed Train Bond Act',
'PROP 2' =>'Standards for Confining Farm Animals',
'PROP 3' =>"Children's Hospital Bond Act. Grant Program.",
'PROP 4' =>"Parent Notif. Before Terminating Minor's Pregnancy",
'PROP 5' =>'Nonviolent Drug Offense. Sentencing, Parole, Rehab',
'PROP 6' =>'Police, Law Enforcement Funding. Criminal Laws.',
@chapados
chapados / quiz.rb
Created May 15, 2009 20:23 — forked from ryanb/quiz.rb
# COMMUNITY CHALLENGE
#
# How would you test this Quiz#problem method? Only two rules:
#
# 1. The tests should fail if any part of the application breaks.
# For example: If "gets" is moved before "puts" then the tests should
# fail since that breaks the application.
#
# 2. You cannot change the Quiz class. But you can use whatever framework
# and tools you want for the tests. (RSpec, Cucumber, etc.)
// shortcut.m
//
// compile:
// gcc shortcut.m -o shortcut.bundle -g -framework Foundation -framework Carbon -dynamiclib -fobjc-gc -arch i386 -arch x86_64
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
#import <Carbon/Carbon.h>
@interface Shortcut : NSObject
require "shortcut"
require 'hotcocoa'
class Application
include HotCocoa
def start
application :name => "Shortcut" do |app|
app.delegate = self
#!/bin/sh
#
# This script will install the python bindings for protobuf
#
# settings
PROTOBUF_VERSION="2.3.0"
PROTOBUF_DIR="protobuf-${PROTOBUF_VERSION}"
@chapados
chapados / yield-self.m
Created June 18, 2011 20:21
yield(self) pattern implemented with objective-C blocks
//
// yield(self) pattern implemented using objective-C blocks
// (not as pretty as Ruby...)
//
// compile:
// llvm-gcc-4.2 -o yield-self -framework Foundation yield-self.m
#import <Foundation/Foundation.h>
@class MyClass;

Welcome to Drift!

Drift is an always-already versioned, cloud-backed text editor. You can use it to take notes, and save them in the GitHub cloud.

Your gists are always saved locally, and any changes you make will get pushed to GitHub's servers.

To name a gist, touch its name in the toolbar.

You can use the share button at the top-right to copy a link to one of your gists, or view it on the web in Safari.

Welcome to Drift!

Drift is an always-already versioned, cloud-backed text editor. You can use it to take notes, and save them in the GitHub cloud.

Your gists are always saved locally, and any changes you make will get pushed to GitHub's servers.

To name a gist, touch its name in the toolbar.

You can use the share button at the top-right to copy a link to one of your gists, or view it on the web in Safari.