Skip to content

Instantly share code, notes, and snippets.

@giom
giom / item_inventory_state.rb
Last active April 11, 2018 20:47
This list the inventory and state of a product including waiting POs, received POs, sent QTYs, etc...
# ss is the list of sizes to analyze
csv_file = CSV.generate do |csv|
csv << ["SKU", "ITEM NO", "PRODUCT", "STYLE", "SIZE", "UPC", "STARTING QTY", "ADDED QTY", "PO RECEIVED QTY", "PO WAITING QY", "MERCEDES QTY", "SENT QTY", "TO SEND QTY", "SOLD QTY", "UPC SIZE QTY", "UPC SIZE EXPECTED QTY", "GLITCHED QTY", "RECEIVED POS #", "AWAITING POS #"]
ss.each do |s|
auc = s.associated_upc_size
a = []
a << s.retail_pro_id
a << s.product.item_no
@giom
giom / marshal_bug.rb
Created March 23, 2010 12:13
Strange bug with Marshaling
class Time
attr_accessor :test
end
t = Time.now
mt = Marshal.dump [t,t]
Marshal.load(mt) == [t,t] #=> true
t.test = t - 31557600
mt = Marshal.dump [t,t]
@giom
giom / gist:58005
Created February 4, 2009 07:41
Useful functions for sass
module Sass::Script
module Functions
# substitue text in a string
# @params
# str the string to substitute text from
# reg the regexp given to sub
# rep the replacement text
def sub(str, reg, rep = '')
Sass::Script::String.new(str.to_s.sub(/#{reg.to_s}/, rep.to_s))
end
@giom
giom / gist:45673
Created January 11, 2009 09:03
Quick braindump on how would one implement a mint store in rack:cache, I haven't tested this, so it probably doesn't work :-)
# NB: I just wrote this to see how one would go about writing a mint store in rack cache and
# how hard it would be. I haven't tested it or even runned it so it most probably doesn't work (I'll
# play with it when I have more time)
module Rack::Cache
class MetaStore
# Stores request/response pairs in memcached. Keys are not stored
# directly since memcached has a 250-byte limit on key names. Instead,
# the SHA1 hexdigest of the key is used.
# Uses the mint store algorithm