Skip to content

Instantly share code, notes, and snippets.

@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'
function ScoreNetwork(score)
{
var self = this;
self.ws = null;
self.data = null;
self.score = score;
self.net = self;
self.initialize = function()
{
--($:~/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",
# 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|
@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 } } }
@knewter
knewter / work.rb
Created January 12, 2012 17:24 — forked from rthbound/work.rb
Hot products
PartNumber.ordered_between(7.days.ago, Time.zone.now)
class PartNumber
named_scope :ordered_between, lambda{|start_time, end_time| { :conditions => ["orders.created_at BETWEEN ? AND ?", start_time, end_time], :include => [:order] }
end
class WorkUnit
scope :on_estimated_ticket, lambda{ include(:ticket).where("tickets.estimated_hours IS NOT NULL AND tickets.estimated_hours > 0") }
end
def project_completion_metric(project)
work_unit_hours_array = Array.new # Empty array to work with
# Take the summation of estimated_hours on a ticket from the project
estimated_hours = Ticket.for_project(project).sum(:estimated_hours)
# Generates the link to determine where the site bar switch button returns to.
def site_bar_switch_link(html_options = {})
admin? ? admin_switch_link(html_options) : frontend_switch_link(html_options)
end
def admin_switch_link(html_options = {})
link_to t('.switch_to_your_website', site_bar_translate_locale_args),
session[:website_return_to] || refinery.root_path(:locale => (Refinery::I18n.default_frontend_locale if Refinery.i18n_enabled?)),
html_options
end
7 def main_account_name(school)
8 "TEACHER#{id} MAIN SCHOOL#{school.id}"
9 end
10
11 def unredeemed_account_name
12 "TEACHER#{id} UNREDEEMED"
13 end
14
15 def undeposited_account_name
16 "TEACHER#{id} UNDEPOSITED"
it "issues credits to a student" do
@amount = BigDecimal("500.00")
@teacher.expects(:main_account_name).with(@school).returns(@teacher_account_name)
@credit_manager.expects(:transfer_credits).with("Issue Credits to Student", @teacher_account_name, @student_account_name, @amount).once
@credit_manager.issue_credits_to_student(@school, @teacher, @student, @amount)
end