Skip to content

Instantly share code, notes, and snippets.

@knewter
knewter / order.rb
Created December 22, 2011 21:05 — forked from rthbound/order.rb
def self.statuses
Order.all.collect{|x| x.status}.uniq
end
# Currently : STATUSES = ["SHIPPED", "PROCESSING", "RECEIVED", "INCOMPLETE", "VOIDED", "REFUNDED", "FRAUDULENT", "ON HOLD"]
validates_inclusion_of :status, :in => statuses
statuses.map{|x| x.downcase.gsub(" ", "_")}.each { |s| named_scope s, :conditions => { :status => s } }
### JOSH PREFERS
named_scope :with_status, lambda{|s| { :conditions => { :status => s } } }
# Perhaps this
def run
last_id = CatProduct.find(:all, :limit => 1, :order => 'id DESC').first.id
last_id_run = 0
num = 0
while(last_id_run < last_id) do
this_batch = CatProduct.find(:all, :limit => 100, :offset => num, :order => 'id ASC')
GC.start
this_batch.each do |cp|
--($:~/work/subtle)-- hg diff -g Rakefile
diff --git a/Rakefile b/Rakefile
--- a/Rakefile
+++ b/Rakefile
@@ -20,15 +20,17 @@
#
# Options / defines {{{
@options = {
- "destdir" => "",
- "prefix" => "/usr",
function ScoreNetwork(score)
{
var self = this;
self.ws = null;
self.data = null;
self.score = score;
self.net = self;
self.initialize = function()
{
@knewter
knewter / gist:27340
Created November 21, 2008 03:47 — forked from anonymous/gist:27339
asdf" asdfasdf "
odfas
asdfas
>> FasterCSV.parse(s.gsub(/"/, '\"'))
FasterCSV::MalformedCSVError: Illegal quoting on line 1.
from /opt/local/lib/ruby/gems/1.8/gems/fastercsv-1.4.0/lib/faster_csv.rb:1650:in `shift'
from /opt/local/lib/ruby/gems/1.8/gems/fastercsv-1.4.0/lib/faster_csv.rb:1568:in `loop'
from /opt/local/lib/ruby/gems/1.8/gems/fastercsv-1.4.0/lib/faster_csv.rb:1568:in `shift'
from /opt/local/lib/ruby/gems/1.8/gems/fastercsv-1.4.0/lib/faster_csv.rb:1513:in `each'