Skip to content

Instantly share code, notes, and snippets.

View redsquirrel's full-sized avatar
🐿️

Dave Hoover redsquirrel

🐿️
  • Flexa, Inc.
  • Evanston, IL
  • 16:21 (UTC -05:00)
  • X @davehoover
View GitHub Profile
class CarController < ApplicationController
def car
layout = nil
@scripts = []
@stylesheets = []
@car = Car.find(params[:id])
layout = CarPresenter.present(@car, @stylesheets, @scripts)
render :action => find_view, :layout => layout
##
# HACKER: Dave Hoover
#
# AUTHORS: Geoffrey Grosenbach http://nubyonrails.com
# Also http://p.ramaze.net/1887
#
# RUN:
# script/console
# paste the following and make sure an exception is thrown
# Bad old stuff
class KDOrders < ActiveRecord::Base
belongs_2 :cart
end
class Cart < ActiveRecord::Base
set_primary_key "cart_id"
can_haz :cart_items
end
class CartItem < ActiveRecord::Base
set_primary_key "cart_item_id"
arr = [1,1,2,2,3,3,4,5]
require 'set'
dups = Set.new
arr.each_with_index { |n, i| dups << n if n == arr[i+1] }
dups # [1, 2, 3]
# Using ActiveRecord's trunk as of Oct 3, 2008, this fails with
# active_record/connection_adapters/abstract/connection_pool.rb:158:in `checkin': undefined method `run_callbacks' for nil:NilClass (NoMethodError)
config = {
:adapter => "mysql",
:host => "localhost",
:username => "root",
:database => "jackgroundrb_development"
}
Index: app/models/theme.rb
===================================================================
--- app/models/theme.rb (revision 2075)
+++ app/models/theme.rb (revision 2076)
@@ -43,13 +43,6 @@
def border_color
handle_native(:border_color, "EFEFEF")
end
-
- # This will eventually become a first-class property and take over outer_background_color.
class SymbolReplacer {
protected String stringToReplace;
SymbolReplacer(String s) {
this.stringToReplace = s;
}
String replace() {
Pattern symbolPattern = Pattern.compile("\\$([a-zA-Z]\\w*)");
int startingPosition = 0;
import java.util.Date;
public class Worker implements Runnable{
long executionMillis = -1;
public void run() {
for(int i=0; i<100; i++) {
import org.junit.Test;
import static org.junit.Assert.*;
public class WatcherTest {
@Test
public void testJavaVersion() {
assertEquals("1.5.0_16", System.getProperty("java.version"));
import org.junit.Test;
import static org.junit.Assert.*;
public class WatcherTest {
@Test
public void testJavaVersion() {
assertEquals("1.5.0_16", System.getProperty("java.version"));