Skip to content

Instantly share code, notes, and snippets.

View timting's full-sized avatar

Timothy Ting timting

View GitHub Profile
def build_address_lines(record)
lines = []
%w{store_name address1 address2 address3}.each do |field|
lines << record[field].strip unless record[field].blank?
end
last_line = ''
%w{city state zip country}.each do |field|
last_line << ' ' + record[field].strip unless record[field].blank?
end
lines << last_line unless last_line.blank?
Started POST "/amf" for 127.0.0.1 at 2012-01-12 19:41:28 +0000
DEPRECATION WARNING: ref is deprecated and will be removed from Rails 3.2. (called from get_service at /var/elastic/skillet/shared/bundle/ruby/1.9.1/bundler/gems/rails3-amf-c8e6239f2c3d/lib/rails3-amf/request_processor.rb:59)
DEPRECATION WARNING: new is deprecated and will be removed from Rails 3.2. (called from get_service at /var/elastic/skillet/shared/bundle/ruby/1.9.1/bundler/gems/rails3-amf-c8e6239f2c3d/lib/rails3-amf/request_processor.rb:59)
DEPRECATION WARNING: get is deprecated and will be removed from Rails 3.2. (called from get_service at /var/elastic/skillet/shared/bundle/ruby/1.9.1/bundler/gems/rails3-amf-c8e6239f2c3d/lib/rails3-amf/request_processor.rb:59)
Processing by DocumentsController#create as AMF
Parameters: {0=>{"versionCreatedWith"=>"3.1.042", "region"=>"A01", "updatedBy"=>"Elastic", "totalPriceRetail"=>4000, "dateCreated"=>1326397272.86, "totalPriceWholesale"=>2000, "createdBy"=>"Elastic", "dateUpdated"=>1326397299.305,
# encoding: utf-8
module Mongoid #:nodoc:
# Include this module to add automatic sequence feature
# usage:
# Class KlassName
# include Mongoid::Document
# include Mongoid::Sequence
# ...
# field :number, :type=>Integer
# sequence :number
@timting
timting / updating documents
Last active December 19, 2015 22:09
Changing product numbers, color codes, or UPCs
# Product numbers:
Document.skip_callback(:save, :before, :create_fields!)
Document.skip_callback(:save, :before, :can_save?)
trans = {"CB31" => "AAZZ", "CB32" => "A8WW", "CB35" => "AAZX", "CB36" => "A3EX", "CB34" => "AZFJ"}
Document.where(:'pages.page_products.product_number'.in => trans.keys).each do |doc|
p "Working on document #{doc.number}"
doc.pages.each do |page|
p "Page #{page.name}"
page.page_products.each do |pp|
if trans[pp.product_number]
I am attesting that this GitHub handle timting is linked to the Tezos account tz2JmZ9V4jEndEViNZz4K3ZPk3vv7wp3FrYu for tzprofiles
sig:spsig1aztbBEk8TBckSd8Y67sSZBejfhvLE9FZ7C4nfy8cHYfhSvSuh22Lpk1RjxUB8o8bCYS113HRaH3jUbHrby974y3DxvtDs