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
window = 14
latest = Time.parse('12:00 AM')
earliest = today - window.days
issues = Issue.find(:conditions => ['updated_at > ? AND updated_at < ?', yesterday, today])
issues_by_day = Hash.new { |key| self[key] = [] }
issues_by_day = issues.injecting(issues_by_day) do |buckets, issue|
buckets[issue.updated_at.strftime('%m/%d')] << issue
@therealadam
therealadam / with.rb
Created August 26, 2008 22:00
'with' keyword for Ruby, if that's your thing
module Kernel
def with(obj, &block)
obj.instance_eval(&block)
end
end
with 'Hi' do
length # => 2
upcase # => "HI"
downcase # => "hi"
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
def dateChosen(sender)
puts 'action!'
end
def makeCalendar
frame = calendarView.frame
@datePicker = NSDatePicker.alloc.initWithFrame(frame)
datePicker.frameOrigin = NSMakePoint(1, 0)
datePicker.datePickerStyle = NSClockAndCalendarDatePickerStyle
#
# 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'
@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
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
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);
require 'test/unit'
require 'rubygems'
require 'activesupport'
require 'shoulda/test_unit'
module ShouldaExtensions
def self.included(klass)
klass.class_eval do
include FixmeMethods