Skip to content

Instantly share code, notes, and snippets.

View swallowstalker's full-sized avatar

Pulung Ragil swallowstalker

  • Depok, Indonesia
View GitHub Profile
@swallowstalker
swallowstalker / gist:acc77fcbfd94c2f78c0853344b03ba10
Created December 23, 2019 12:23
Match lancelot stock > 0 with product data
ProductSkuWarehouseStock.where('available_qty', '>', 0).where.not(warehouse_id: 81).find_in_batches(batch_size: 500) do |stocks|
stocks.each do |stock|
p_list_inactive = Product.where(sku_id: stock[:product_sku_id], state: 0).pluck(:id)
p_list_active = Product.where(sku_id: stock[:product_sku_id], state: 1).pluck(:id)
if p_list_active.size == 0
puts "For SKU ID #{stock[:product_sku_id]}, warehouse ID: #{stock[:warehouse_id]} found inactive product ID: #{p_list_inactive}"
end
if p_list_inactive.size == 0
@swallowstalker
swallowstalker / keepalive.sh
Last active April 15, 2020 04:06
Keep alive connection, install this gist on cron every 1 minute
#!/bin/bash
# ping process detector. if no running ping process, execute it once
# to be called by cron (for checking and re-spawn) every 1 minute
# need to specify destination IP for ping first
if [[ -z $DEST_IP ]]; then
echo "Please set DEST_IP before calling this script"
exit 1
fi