Skip to content

Instantly share code, notes, and snippets.

View iarie's full-sized avatar
🏠
Working from home

Yaroslav Litvinov iarie

🏠
Working from home
View GitHub Profile
@iarie
iarie / fix_stucked_shipments.rb
Last active June 10, 2020 10:21
all in one gist
interval = Date.new(2020, 5, 1)..Date.new(2020, 6, 7)
module FixStuckShipments
FINAL_STATES = %w[
shipped
canceled
].freeze
SHIPMENT_STATUS_MAP = {
'Complete' => 'shipped',
# Get Status
get_status = -> (po_number) do
r = Supplier::Alphabroder::OrderStatusV2::GetOrderStatus.new.call(po_number)
doc = Nokogiri::XML(r.body)
nodes = doc.xpath("//order[not(shipstatus)]")
pnode = Supplier::Alphabroder::OrderStatusV2::OrderXmlNode.new(nodes)
pnode.ship_method_nodes.map do |n|
{
number: n.shipper_number,
@iarie
iarie / find_stuck_processing_shipments.rb
Last active June 8, 2020 13:35
Find stuck shipments by criteria: shipment should have similar
# May
interval = Date.new(2020, 5, 1).all_month
stock_location_ids = Spree::Supplier.alphabroder.stock_location_ids
order_ids = Spree::Order.joins(:shipments).where(
completed_at: interval,
spree_shipments: {
state: 'processing',
stock_location_id: stock_location_ids
}
# frozen_string_literal: true
module AssignmentsBenchmark
@@zip = '02026'
@@orders = {}
@@ready = false
def self.prepare
generator = OrderGenerator.new(500)
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@iarie
iarie / _download_button.html.erb
Last active July 19, 2017 09:47
RoR: catch send_file via cookies
<!-- Using ladda-button plugin and bootsrtap -->
<!-- setting data-attributes to link with unique token -->
<%= link_to download_products_event_path(event, format: :xlsx), class: "download-file-btn",
data: { token_value: SecureRandom.hex, token_name: "products_download_token_#{event.id}"} do %>
<button class="btn btn-outline btn-primary dim ladda-button" type="button" data-style="zoom-out">
<i class="fa fa-file-excel-o"></i> Download
</button>
<% end %>
<!-- @TODO: we could also check if token exists to disable button