Discover gists
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
(rdb:1) e | |
#<NoMethodError: undefined method `product_id' for #<Shirt:0x3eafc60>> | |
(rdb:1) Shirt.properties | |
#<PropertySet:{#<Property:Shirt:id>,#<Property:Shirt:type>,#<Property:Shirt:code>,#<Property:Shirt:name>,#<Property:Shirt:description>,#<Property:Shirt:unit_price>,#<Property:Shirt:available_on>,#<Property:Shirt:is_discontinued>,#<Property:Shirt:slug>,#<Property:Shirt:vote_mean>,#<Property:Shirt:available>,#<Property:Shirt:designer_id>,#<Property:Shirt:created_by>,#<Property:Shirt:user_id>}> | |
(rdb:1) pp e.backtrace | |
["/opt/local/lib/ruby/gems/1.8/gems/dm-validations-0.9.3/lib/dm-validations/numeric_validator.rb:17:in `send'", | |
"/opt/local/lib/ruby/gems/1.8/gems/dm-validations-0.9.3/lib/dm-validations/numeric_validator.rb:17:in `call'", | |
"/opt/local/lib/ruby/gems/1.8/gems/dm-validations-0.9.3/lib/dm-validations/contextual_validators.rb:48:in `execute'", |
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
private string GetRandomRelatedViewID(string viewIDList) | |
{ | |
BaseGenericList<BrandEnsemble.Framework.RelatedItems.Components.RelatedItem> riList = BrandEnsemble.Framework.RelatedItems.RelatedItems.GetAllRelatedItems(); | |
riList.Filter(new string[] { "Caption" }, string.Empty, FilterOperand.NotEquals); | |
BrandEnsemble.Framework.RelatedItems.Components.RelatedItem rri = riList.RandomItem(); | |
while (viewIDList.IndexOf(rri.ViewID) >= 0) | |
{ | |
rri = riList.RandomItem(); | |
} | |
return rri.ViewID; |
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 Whatever < ActiveRecord::Base | |
class << self | |
def find_with_awesome(*args) | |
opts = args.extract_options! | |
if opts.has_key?(:awesome) | |
awesome = opts.delete(:awesome) | |
# process something here.... | |
end | |
find_without_awesome(*(args << opts)) |
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
public T RandomItem() | |
{ | |
int randomRI = 0; | |
Random random = new Random(); | |
lock (random) | |
{ | |
randomRI = random.Next(0, this.Count - 1); | |
} | |
return this[randomRI]; | |
} |
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
require 'generator' | |
g = Generator.new do |g| | |
n = 2 | |
p = [] | |
while true | |
if p.all? { |f| n % f != 0 } | |
g.yield n | |
p << n |
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
for i in 1..25 | |
puts g.next | |
end |
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
require 'rubygems' | |
require 'mq' | |
EM.run do | |
def log(*args) | |
p args | |
end | |
amq = MQ.new |
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
require 'pathname' | |
require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper' | |
if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES | |
describe "STI Resources" do | |
before do | |
class Product | |
include DataMapper::Resource | |
property :id, Integer, :serial => true |
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 Array | |
def to_json(options = {}, &block) #:nodoc: | |
"[#{map { |value| ActiveSupport::JSON.encode(value, options, &block) } * ', '}]" | |
end | |
end | |
module ActiveSupport | |
module JSON |
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
> git status | |
# On branch cpp | |
# Changed but not updated: | |
# (use "git add <file>..." to update what will be committed) | |
# | |
# modified: external_libs/llvm/Makefile | |
# modified: external_libs/llvm/Makefile.common | |
# modified: external_libs/llvm/bindings/Makefile | |
# modified: external_libs/llvm/bindings/ocaml/Makefile.ocaml | |
# modified: external_libs/llvm/examples/Makefile |