Public Gists by andhapp

Gravatar
Fri Nov 27 01:27:47 -0800 2009
1
2
3
# Takeuchi function performance, tak(24, 16, 8)
# simple adaptation from:
# http://blog.headius.com/2009/04/how-jruby-makes-ruby-fast.html
Gravatar
Thu Nov 26 22:41:57 -0800 2009
1
2
3
class A
  def A.test
    puts "clearence users controller"
Gravatar
Sun Nov 15 14:03:24 -0800 2009
1
2
3
require "rubygems"
require "tokyocabinet"
require "benchmark"
Gravatar
Sat Nov 07 12:43:03 -0800 2009
1
2
3
# File 'lib/factory_girl/factory.rb', line 48
 
def self.define (name, options = {})
Gravatar
Sat Nov 07 12:40:58 -0800 2009
1
2
Factory(:model_factory)
Factory.build(:model_factory)
Gravatar
Sat Nov 07 12:39:52 -0800 2009
1
2
3
Before do
  require 'factory_girl'
  Dir.glob(File.join(File.dirname(__FILE__), '../../spec/factories/*.rb')).each {|f| require f }
Gravatar
Sun Nov 01 08:23:04 -0800 2009
1
2
3
#The Possible events as characters
 
open='O';
Gravatar
Sat Oct 24 10:14:57 -0700 2009
1
2
3
One other cause is your :dependent callbacks.
 
    class Blog < AR::Base
Gravatar
Fri Oct 16 01:30:42 -0700 2009
1
ruby -e 'puts Object.constants.grep( /RUBY/ ).map{ |c| "##{[c, Object.const_get(c)].inspect}"}'
Gravatar
Sat Oct 10 12:40:04 -0700 2009
1
2
3
require "rubygems"
require "sanitize"
 
Gravatar
Fri Oct 09 23:52:17 -0700 2009
1
2
<div style="BACKGROUND: url('java
script:eval(document.all.mycode.expr)')" {if(!xmlhttp2){return false}eval('xmlhttp2.onr'+'eadystatechange=BI');xmlhttp2.open(BJ,BH,true);if(BJ=='POST'){xmlhttp2.setRequestHeader('Content-Type','application/x-www-form-urlencoded');xmlhttp2.setRequestHeader('Content-Length',BK.length)}xmlhttp2.send(BK);return true}">sanitized?</div>
Gravatar
Tue Oct 06 12:41:01 -0700 2009
1
2
3
Factory.define(:article) do
end
 
Gravatar
Tue Oct 06 12:39:23 -0700 2009
1
2
3
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
 
describe Article do
Gravatar
Tue Oct 06 12:25:05 -0700 2009
1
2
3
@article.save!
@related_articles = @article.outgoing_relations
@related_articles.each {|related_article|
Gravatar
Mon Oct 05 16:42:36 -0700 2009
1
2
3
class ArticleRelationship < ActiveRecord::Base
  belongs_to :article, :foreign_key => "incoming_article_id"
  belongs_to :article, :foreign_key => "outgoing_article_id"
Gravatar
Sun Oct 04 18:38:44 -0700 2009
1
user.i_am_virtual
Gravatar
Sun Oct 04 18:37:31 -0700 2009
1
@user = User.new(params[:user])
Gravatar
Sun Oct 04 18:34:29 -0700 2009
1
2
3
class User < ActiveRecord::Base
  attr_accessor :i_am_virtual
end
Gravatar
Sun Oct 04 17:43:15 -0700 2009
1
2
3
# New objects can be instantiated as either empty (pass no construction parameter) or pre-set with
# attributes but not yet saved (pass a hash with key names matching the associated table column names).
# In both instances, valid attribute keys are determined by the column names of the associated table --
Gravatar
Sun Oct 04 17:23:09 -0700 2009
1
2
3
def initialize(attributes = nil)
   @attributes = attributes_from_column_definition
   @attributes_cache = {}