Skip to content

Instantly share code, notes, and snippets.

@onedanshow
onedanshow / shopify_like_order.json
Last active February 6, 2019 12:41
A Shopify-like order for a Zapier zap
{
"order": {
"note": "This is a customer note made at checkout or similar that will be internally visiable to M&E personnel.",
"local_delivery_date": "2019/01/24", // must be in YYYY/MM/DD
"shipping_address": {
"address1": "123 Amoebobacterieae St", // required
"address2": "",
"city": "Ottawa", // required
"company": null,
"country": "Canada", // required
@onedanshow
onedanshow / 0_reuse_code.js
Created October 15, 2016 17:29
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@onedanshow
onedanshow / canadian_taxes.rb
Last active August 29, 2015 14:16
Setup Canadian taxes in Spree
if country = Spree::Country.find_by(name: 'Canada')
tax_cat = Spree::TaxCategory.create!(
name: "Canadian Tax",
description: "Products sold in Canada",
is_default: true)
gst_opts = {
name: 'GST',
amount: 0.05,
@onedanshow
onedanshow / order_updater_decorator.rb
Created November 26, 2014 02:22
Way to pick the best promotion between order adjustments and line item adjustments in Spree 2.2+
Spree::OrderUpdater.class_eval do
module BetterPromotions
# DD: called by 'update_adjustment_total' before setting totals on order
def recalculate_adjustments
# DD: first, calculate all_adjustments for Order, LineItem, and Shipment using Spree::ItemAdjustments
super
# DD: FYI: promo_totals are negative
@onedanshow
onedanshow / wombat.rake
Created August 15, 2014 19:37
Rake task to set back Spree::Order push timestamp by 12 hours for wombat.co
namespace :wombat do
desc "Push back Spree::Order push timestamp by 12 hours"
task reset_order_timestamp: :environment do
timestamps = Spree::Wombat::Config[:last_pushed_timestamps]
timestamps["Spree::Order"] = 12.hours.ago
Spree::Wombat::Config[:last_pushed_timestamps] = timestamps
end
end
@onedanshow
onedanshow / sync_magento_database.rb
Last active December 12, 2015 02:28
Capistrano task: Pull database for Magento to local machine
# DD: pull the MySQL database down
# DD: base code: http://stackoverflow.com/questions/13638112/how-to-create-a-capistrano-task-to-download-latest-database-backup-tgz-and-impor
# DD: base code: https://gist.github.com/1726896
require 'nokogiri'
require 'colored'
namespace :db do
desc 'Pull the DB from the server'
task :pull, :roles => :db, :only => { :primary => true } do
filename = "#{application}.dump.#{Time.now.to_f}.sql"
@onedanshow
onedanshow / server_side_sync.as
Last active September 25, 2015 07:48
Server-Side Actionscript to Sync Folders: After a user records his webcam video through Flash Media Server (FMS), this server-side actionscript can be used to compare two directories and sync the local recordings to the network location. Assumes you have a 'local_repo' and 'network_repo' virtual
application.onDisconnect = function(client) {
trace("\nLOG: Syncing webcam files to data storage...");
var localDir = new File("local_repo");
var backupDir = new File("network_repo");
if(localDir.isDirectory && backupDir.isDirectory) {
var lFiles = localDir.list();
var iFiles = networkDir.list();
for(var i = 0; i < lFiles.length; i++) {
var found = false;