Skip to content

Instantly share code, notes, and snippets.

View therealadam's full-sized avatar
🍔
Building Pingboard. Accepting JavaScript. Still loving Rails. Telling jokes.

Adam Keys therealadam

🍔
Building Pingboard. Accepting JavaScript. Still loving Rails. Telling jokes.
View GitHub Profile
# A shoulda macro for verifying a class has the writer attribute readers,
# writers and accessors. NOTE: I could be silly for wanting this. But it was
# there. So here it is.
#
# (c) Copyright 2009 Adam Keys. MIT license.
module AccessorMacros
def should_have_reader(name)
should "have an attribute reader for #{name.to_s}" do
require 'test/unit'
require 'rubygems'
require 'activesupport'
require 'shoulda/test_unit'
module ShouldaExtensions
def self.included(klass)
klass.class_eval do
include FixmeMethods
diff --git a/vm/compiler.c b/vm/compiler.c
index cfd6f57..64e098d 100644
--- a/vm/compiler.c
+++ b/vm/compiler.c
@@ -138,6 +138,9 @@ void TrCompiler_compile_node(VM, TrCompiler *c, TrBlock *b, TrNode *n, int reg)
TrCompiler_compile_node(vm, c, b, (TrNode *)v, reg);
});
break;
+ case AST_CLOWNCAR: {
+ PUSH_OP_A(b, CLOWNCAR, reg);
not_found do
'Bonk'
end
error(ActiveRecord::RecordNotFound) do
status(404)
'Aside not found'
end
require 'test/unit'
require 'rubygems'
require 'shoulda'
require 'factory_girl'
require 'dm-core'
require 'dm-validations' # Needed for save!
class User
@therealadam
therealadam / gist:41457
Created December 30, 2008 00:41 — forked from damon/gist:41453
def whack(objects)
objects.inject({}) { |results, o| result.update(o.send('table_name') => o.send('delete_all'] }
end
#
# I wanted to build a really common example app but use Git as the backend
# instead of a database or the filesystem. And so here we are.
#
# (c) Copyright 2008 Adam Keys. MIT licensed or some-such.
#
require 'fileutils'
require 'rubygems'
def dateChosen(sender)
puts 'action!'
end
def makeCalendar
frame = calendarView.frame
@datePicker = NSDatePicker.alloc.initWithFrame(frame)
datePicker.frameOrigin = NSMakePoint(1, 0)
datePicker.datePickerStyle = NSClockAndCalendarDatePickerStyle
#!/usr/bin/env ruby
#
# Seeking to answer man's eternal question "I wonder how many little Git
# repositories I have just floating around in my home directory. Further, I
# wonder how many actually have a remote somewhere."
#
# Usage:
#
# Search for Git repositories in the specified directory
# > ruby git_finder.rb some_dir another_dir ...
class Issue < ActiveRecord::Base
after_create :send_notification
def send_notification; end
end
class SomeMigration < ActiveRecord::Migration
def self.up
# Do stuff with Issue
end