Skip to content

Instantly share code, notes, and snippets.

View eventualbuddha's full-sized avatar

Brian Donovan eventualbuddha

View GitHub Profile
@eventualbuddha
eventualbuddha / seed_file.rb
Created July 9, 2010 01:51
SeedFile, a helper for doing database setup in a Rails 3 app
# Helper class for importing files with records to the database.
class SeedFile
def self.import(path)
new(path).import
end
attr_reader :path
def initialize(path)
@path = Pathname(path)
diff --git a/lib/importer/wesabe.rb b/lib/importer/wesabe.rb
index 2b1e348..fc4b69d 100644
--- a/lib/importer/wesabe.rb
+++ b/lib/importer/wesabe.rb
@@ -418,7 +418,8 @@ class Importer
when false, nil
# nothing to do
else
- if transfer = txactions[datum['transfer']['id']][0]
+ transfer, = txactions[datum['transfer']['id']]
@eventualbuddha
eventualbuddha / db.rb
Created July 29, 2010 14:35
Screen sessions + databases on a per-project basis, isolated in separate volumes
#!/usr/bin/env ruby
require 'optparse'
begin
require 'open4'
rescue LoadError => ex
begin
require 'rubygems'
require 'open4'
rescue LoadError
@eventualbuddha
eventualbuddha / s.fish
Created August 20, 2010 03:21 — forked from indirect/s.sh
function s -d "Easy spec running"
if grep -q "Rspec.configure" spec/spec_helper.rb
echo "rspec2!"
if test -z "$argv"
rspec -fs -c spec
else
rspec -fs -c $argv
end
else
echo "rspec1!"
@eventualbuddha
eventualbuddha / Makefile
Last active September 24, 2015 06:28
simple node.js file server
serve.js: serve.jsnext.js
babel serve.jsnext.js -o serve.js
@eventualbuddha
eventualbuddha / gist:707019
Created November 19, 2010 19:37
A note to the TSA
This is really more about the blog in general. After reading a number of the blog articles, particularly http://blog.tsa.gov/2010/11/tsa-myth-or-fact-leaked-images.html, it seems that you guys are completely ignoring the comments on the blog. I get that. Most of them are really angry. I would hate my job if it involved trying to respond to all these people, many of whom won't listen to a thing you say.
Here's the problem: it looks bad, and is just making things worse. Though I'm sure this would be perceived negatively, I'd suggest turning off comments on the blog altogether. People have their own blogs and the can and do comment on your articles there. It raises the bar a bit so you end up with much fewer "TSA SUCKS" comments.
If you don't want to do that, then you'll have the bite the bullet and actually engage with people. Not all of them, and perhaps not individually, but address the major concerns. For example, on http://blog.tsa.gov/2010/11/tsa-has-not-will-not-and-our-advanced.html the title explicitl
@eventualbuddha
eventualbuddha / CPView-sizeToFit.j
Created December 4, 2010 00:46
Adds a sizeToFit method to CPViews that will resize a view to fit its subviews.
@import <AppKit/CPView.j>
@implementation CPView (sizeToFit)
- (void)sizeToFit
{
[self sizeToFitWithInset:[self hasThemeAttribute:@"content-inset"] && [self currentValueForThemeAttribute:@"content-inset"] || CGInsetMakeZero()];
}
- (void)sizeToFitWithInset:(CGInset)inset
@eventualbuddha
eventualbuddha / replay-proxy.js
Created January 6, 2011 16:16
Capture and replay HTTP requests and responses.
#!/usr/bin/env node
/**
* Capture or replay responses from an HTTP server.
*/
var sys = require('sys'),
path = require('path'),
args = process.argv.slice(2),
@eventualbuddha
eventualbuddha / CPObject+CPCodingExtensions.j
Created April 8, 2011 20:45
Allows you to selectively ignore undefined keys when setting a value by key.
@implementation CPObject (CPCodingExtensions)
- (void)setValue:(id)aValue forKey:(CPString)aKey ignoreUndefinedKey:(BOOL)ignoreUndefinedKey
{
if (!ignoreUndefinedKey)
{
[self setValue:aValue forKey:aKey];
}
else
{
@eventualbuddha
eventualbuddha / AppController.j
Created April 11, 2011 22:02
Simple Cappuccino app that demonstrates this bug: https://github.com/280north/cappuccino/pull/1225
/*
* AppController.j
* CPTableViewRetargetedDropBug
*
* Created by You on April 11, 2011.
* Copyright 2011, Your Company All rights reserved.
*/
@import <Foundation/CPObject.j>