Skip to content

Instantly share code, notes, and snippets.

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

Brent Hoover zenweasel

🏠
Working from home
View GitHub Profile
import fs from "fs";
import { Blob } from "buffer";
import { Readable } from "stream";
import pkg from "@reactioncommerce/file-collections";
// import * as buffer from "buffer";
global.Blob = Blob;
const { FileRecord } = pkg;
# If a mirror repo is set up properly this will pull from the source repo
# and push to the mirror
# https://help.github.com/en/articles/duplicating-a-repository
git fetch -p origin
git push --mirror

Keybase proof

I hereby claim:

  • I am zenweasel on github.
  • I am zenweasel (https://keybase.io/zenweasel) on keybase.
  • I have a public key whose fingerprint is C6AE 7DA7 2837 C999 D311 720B 16EA 4EB1 5D65 9E6C

To claim this, I am signing this object:

@zenweasel
zenweasel / showSubs.js
Created March 7, 2016 00:22
snippet for logging all subscriptions
let subs = Meteor.default_connection._subscriptions; // all the subscriptions that have been subscribed.
Object.keys(subs).forEach(function(key) {
console.log(subs[key]); // see them in console.
});

Product test plan

Products grid

Non-admin user

Product Card display

  • Card should display Sold Out! label when inventory qty < min.inventory qty, but only if "Inventory Tracking" option is enabled.
  • if any product's variant.inventoryQuantity <= variant.lowInventoryWarningThreshold the card should display Limited Supply
  • if any product's !variant.inventoryManagement || variant.inventoryQuantity > 0 display Backorder
  • a product card should display a range of pricing from the lowest variant price to the highest variant price.
@zenweasel
zenweasel / escape_dict.py
Last active October 14, 2015 23:54
Escape all values in a recursive dictionary. Great for sanitizing JSON inputs
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def escape(s):
escaped = unicode(s)\
.replace('&', '&amp;')\
.replace('<', '&gt;')\
.replace('>', '&lt;')\
.replace("'", '&#39;')\
@zenweasel
zenweasel / timing.py
Created October 5, 2015 20:50
Used for timing module execution time. Put in in the site_packages directory and import it at the top of the module
import atexit
from time import clock
def seconds_to_str(t):
return "%d:%02d:%02d.%03d" % \
reduce(lambda ll, b: divmod(ll[0], b) + ll[1:],
[(t * 1000,), 1000, 60, 60])
line = "=" * 40
@zenweasel
zenweasel / timerange.py
Created September 30, 2015 00:41
TimeRange Object
#!/usr/bin/env python
# -*- coding: utf-8 -*-
class TimeRange(object):
"""
A basic structure to allow use to reason about non-contiguous dateranges in a single place
"""
def __init__(self, start_dt=None, end_dt=None, ranges=None):
self.start_dt = start_dt
@zenweasel
zenweasel / sorting_list_of_dictionaries.py
Created July 17, 2015 18:11
Sorting a list of dictionaries
sorted_locations = sorted(locations, key=lambda l: l['address']['distance'])
@zenweasel
zenweasel / random_characters.py
Created April 20, 2015 20:49
Create random characters for password
import random
def _create_random_password(num_chars):
"""
Create a string of random characters
:param num_chars:
:return:
"""
password_string = ''
seed = string.ascii_letters + string.digits + string.punctuation