This file contains hidden or 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
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' |
This file contains hidden or 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
function ScoreNetwork(score) | |
{ | |
var self = this; | |
self.ws = null; | |
self.data = null; | |
self.score = score; | |
self.net = self; | |
self.initialize = function() | |
{ |
This file contains hidden or 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
--($:~/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", |
This file contains hidden or 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
# 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| |
This file contains hidden or 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
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 } } } |
This file contains hidden or 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
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 |
This file contains hidden or 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 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) | |
This file contains hidden or 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
# 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 |
This file contains hidden or 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
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" |
This file contains hidden or 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
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 |
OlderNewer