This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# 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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SymbolReplacer { | |
protected String stringToReplace; | |
SymbolReplacer(String s) { | |
this.stringToReplace = s; | |
} | |
String replace() { | |
Pattern symbolPattern = Pattern.compile("\\$([a-zA-Z]\\w*)"); | |
int startingPosition = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Date; | |
public class Worker implements Runnable{ | |
long executionMillis = -1; | |
public void run() { | |
for(int i=0; i<100; i++) { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")); |
OlderNewer