Skip to content

Instantly share code, notes, and snippets.

View cherring's full-sized avatar
💭
Why do we even need this?

Chris Herring cherring

💭
Why do we even need this?
View GitHub Profile
def css_class(cat, name)
if cat == name
return "selected"
end
return ""
end
%a{ :href => name, :class => css_class(@category, name)
%span= name
<%= user.avatar.exists? ? image_tag(user.avatar.url(:thumb)) : image_tag("/images/person.gif") %>
server {
listen 80;
server_name www.domain.com;
rewrite ^/(.*) http://domain.com/$1 permanent;
}
server {
listen 80;
server_name domain.com;
}
describe Scorecard::Score::BusinessCapacityScore,"benchmark" do
before do
@business_capacity = Scorecard::Score::BusinessCapacityScore.new
@business_capacity.ues = false
@stream_fields = @business_capacity.assistance_type_stream_fields
end
@stream_fields.each do |stream_label|
it "should get the stream: #{stream_label}" do
@@valid_fields = %w(fields in here)
named_scope :between, lambda{ |start_date, end_date, field_name|
 field = (@@valid_fields.include?(field_name)) ? (field_name) : raise (ActiveRecord::StatementInvalid)
 {  :conditions => ["#{field} >= ? AND #{field} <= ?",  start_date, end_date]}
}
PHP 5.3.0 (cli) (built: Jul 19 2009 00:34:29)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies
class SomeClass < ActiveRecord::Base
include NumberToCurrency
end
module NumberToCurrency
def self.included(base)
base.extend ClassMethods
end
development: &global_settings
database: textual_development
host: 127.0.0.1
port: 27017
test:
database: textual_test
<<: *global_settings
production:
@cherring
cherring / gist:267320
Created January 2, 2010 00:36
Paperclip weirdness
## With this code instead of passing a file and being a file object in the params like:
## Parameters: {"commit"=>"Save changes", "authenticity_token"=>"CNHWuiMsSkwK4x3biFGogUnRU2kutvKuCfOTH2Y+PO4=", "painting"=>{"image"=>#<File:/tmp/RackMultipart20100102-3131-9c0z0-0>}}
## it passes just a name of the file like so:
## Parameters: {"action"=>"create", "authenticity_token"=>"atvaDTdf2yhQKea8t/VBhYyT2ENyK9B/ZYGQSRq9414=", "painting"=>{"title"=>"g", "height"=>"1", "picture"=>"Tweetie.gif", "width"=>"1"}, "controller"=>"admin/paintings"}
## Model
before_filter :clear_flash
protected
def clear_flash
flash[:notice] = nil
end