Skip to content

Instantly share code, notes, and snippets.

# From http://github.com/jaymcgavren
# modified by http://twitter.com/jonhinson to include Test::Unit cases
# Save this as rcov.rake in lib/tasks and use rcov:all =>
# to get accurate spec/feature coverage data
require 'cucumber/rake/task'
require 'spec/rake/spectask'
require 'rcov/rcovtask'
namespace :rcov do
class Event < ActiveRecord::Base
belongs_to :creator, :class_name => 'Profile'
def pending_invites(emails)
c = self.creator
emails.each do |email|
p = Profile.find_by_email(email)
unless p.blank?
c.sent_messages.create(
:receiver => p,
checking ImageMagick MagickWand API configuration program... found in /Users/{user}/ImageMagick-6.5.3//bin/MagickWand-config
checking if ImageMagick version is at least 6.2.4... found version 6.5.3 Q16
checking for MagickWand.h header file... configure: error: Cannot locate header file MagickWand.h
// Referenced from https://developer.mozilla.org/en/DOM/document.createEvent
var simulateClick = function (el) {
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
el[0].dispatchEvent(evt);
}
simulateClick($('#somelink'));
@echo off
setlocal
set PATH=C:\Program Files\Git\bin;%PATH%
setlocal
set HOME=C:\Documents and Settings\Administrator
git pull origin master
--------------------------------------------------------
I'm trying to run the .bat script above using ASP.NET. When I output the errors, I get:
I'm using Nokogiri 1.3.3 for the following code snippet. When I try using 1.4, it takes very long to load the 250mb xml file and I run out of memory before it
finishes. Using 1.4, the process takes up 2.5gb+ of memory before it fails from out of memory errors. Using 1.3.3, the process takes up about 1gb of memory after
loading the XML file. It appears the xpath method fails on large files with a large number of nodes. The single_property.xml contains only the
first <Property> node and its child nodes found in the properties.xml.
doc = Nokogiri::XML(File.open("db/properties.xml"))
doc2 = Nokogiri::XML(File.open("db/single_property.xml"))
>> doc.xpath("//Property").size
=> 0
@jonhinson
jonhinson / gist:268626
Created January 4, 2010 16:24
Using paperclip with polymorphic associations. You can use http://www.webyfi.com/?p=222 to add some more functionality (adding multiple photo upload fields to a form using javascript).
We couldn’t find that file to show.
class Foo < ActiveRecord::Base
has_many :bars, :conditions => ["bars.source = ?", source]
...
end
module ActiveRecord
module Associations
module ClassMethods
private
@@valid_keys_for_belongs_to_association = [
:class_name, :primary_key, :foreign_key, :foreign_type, :remote, :select, :conditions,
:include, :dependent, :counter_cache, :extend, :polymorphic, :readonly, :joins, # added :joins key
:validate, :touch
]
@@valid_keys_for_has_many_association = [
jQuery(function() {
$.cookie('tz', (new Date()).getTimezoneOffset());
});