Skip to content

Instantly share code, notes, and snippets.

Bill Burcham Bill

Block or report user

Report or block Bill

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:33df1cc70abb30964397
(ns progress-light.core
(:require [clj-progress.core :as progress]
[clojure.core.async :as async :refer [>!! timeout chan alt!! thread]])
(:gen-class))
(def tick-ch
(chan))
(def done-ch
(chan))
View rspec_context_method_override.rb
describe 'authenticated principal' do
before(:each) do
mock_valid_authentication
end
it 'should start with a new User object' do
get 'new'
assigns[:user].nil?.should == false
end
View gist:11679
# by Bill Burcham http://thoughtpropulsion.com
# do what you want with this
# Add :host variable extraction to Dan Webb's request_routing plugin
module Propel
module MultiDomainRouting
# include this module in RouteSet after request_routing plugin is loaded
module ExtractHostParameter
def self.included( other)
other.alias_method_chain :extract_request_environment, :host
View include_scripts_for_controller.rb
class FooController < ApplicationController
before_filter :include_scripts
protected
def include_scripts
include_tags = render_to_string( :partial => 'editor/head_elements' )
# um, see e.g. layout.rb line 254 in Rails 2.1.0. content_for variables have the form @content_for_<name>
@template.instance_variable_set("@content_for_head", include_tags )
View routes.rb
ActionController::Routing::Routes.draw do |map|
map.with_options :conditions => { :host => /^blog\.foo.com$/} do | blog |
blog.connect '', :controller => 'blog', :action => 'index', :conditions => {:method => :get}
blog.connect '/post/:id', :controller=>'post', :action=>'show', :conditions => {:method => :get}
... more blog stuff
end
map.with_options :conditions => { :host => /^foo.com$/} do | foo |
foo.connect '', :controller => 'foo_home', :action => 'index', :conditions => {:method => :get}
View recognize_path.rb
# This is an attempt at an improved version of params_for or rspec rails. It is meant to
# support recognition of paths when the Rails environment has been extended via patches like these:
# http://weblog.jamisbuck.org/2006/10/26/monkey-patching-rails-extending-routes-2
# http://svn.danwebb.net/external/rails/plugins/request_routing/trunk/README
# So instead of route :conditions having only :method, they may now have other data such as :domain
def recognize_path( path, options)
if options[:host].kind_of?( Array )
result = options[:host].collect{ | h | route( path, options.merge( :host => h) ) }
else
begin
View blogger_comment_block.html
<dl id='comments-block'>
<dt class='comment-author openid-comment-icon' id='c5069974981380830367'>
<a name='c5069974981380830367'></a>
<a href='http://meme-rocket.com/' rel='nofollow'>Bill</a>
said...
</dt>
<dd class='comment-body'>
<p>testing an OpenID comment</p>
</dd>
View seed-fu.rb.diff
===================================================================
--- vendor/plugins/seed-fu/lib/seed-fu.rb (revision 3419)
+++ vendor/plugins/seed-fu/lib/seed-fu.rb (working copy)
@@ -20,7 +20,7 @@
raise "You must set at least one constraint." if constraints.empty?
@constraints = []
constraints.each do |constraint|
- raise "Your constraint `#{constraint}` is not a column in #{@model_class}. Valid columns are `#{@model_class.column_names.join("`, `")}`." unless @model_class.column_names.include?(constraint.to_s)
+ raise "Your constraint `#{constraint}` is not a column in #{@model_class}. Valid columns are `#{@model_class.column_names.join("`, `")}`." unless @model_class.column_names.include?(constraint.to_s) || association = @model_class.reflect_on_association(constraint)
@constraints << constraint.to_sym
View Optimizing For Patches.rb
# BAD:
foo.bar = 25
foo.biz = 'Hello World'
foo.bazzle = 42
# GOOD:
foo.bar = 25
foo.biz = 'Hello World'
foo.bazzle = 42
View gist:95498
module Spec
module Rails
class ControllerContext < Rails::Context
module ContextEvalInstanceMethods
def setup_extra
(class << @controller; self; end).class_eval do
include ControllerInstanceMethods
end
@controller.integrate_views! if @integrate_views
@controller.session = session
You can’t perform that action at this time.