Skip to content

Instantly share code, notes, and snippets.

View paultannenbaum's full-sized avatar

Paul Tannenbaum paultannenbaum

View GitHub Profile
@paultannenbaum
paultannenbaum / order_flow.md
Last active July 9, 2025 20:31
SH Order Flow

Order Flow

1. Validate cart at checkout request
   ↓
2. Show checkout form if valid
   ↓
3. Cart Submission (Radar rejected rules will fail here)
   ↓
4. Validate that order is still valid
@paultannenbaum
paultannenbaum / to-be-investigated.js
Created May 21, 2025 22:53
Orders that need to be investigated
[
{
"orderId": 7258,
"customerEmail": "lost_romantic1986@yahoo.com",
"eventDate": "2025-03-16",
"expectedAmountInAvalara": 328
},
{
"orderId": 7336,
"customerEmail": "LB1361@GMAIL.COM",
@paultannenbaum
paultannenbaum / bad-order.js
Created May 21, 2025 22:52
Orders that need to be corrected in Avalara
[
{
"orderId": 7703,
"orderDate": "2025-03-19",
"customerEmail": "maddilinsteadt@yahoo.com",
"eventDate": "2025-05-16",
"transactionId": 85765039502945,
"lineItemAmount": 444,
"expectedAmount": 148
},
@paultannenbaum
paultannenbaum / cart_with_variant_data.js
Last active March 31, 2017 20:44
Shopify cart object with detailed variant data. Adds a 'variant' object to each 'item' object in the cart.js GET response
// Assumes jQuery is available
// Call getCartJSON() to get the cart object with additional variant data
// Do not call this function, let the `getCartJSON` function call this
var _addProductVariantJSONToCart = function(cart) {
var uniqueProducts = cart.items.map(function(item) {
return item.handle;
}).filter(function(handle, index, self) {
return self.indexOf(handle) === index;
});
@paultannenbaum
paultannenbaum / viewport-relative-mixins.scss
Created March 15, 2017 21:15
Viewport Relative Utils
@function calculate-rem($size) {
// transform px to em
$remSize: $size / 16px;
@return $remSize * 1rem;
}
@function get-vw($target, $viewport-width) {
// Transform px to vw
$vw-context: ($viewport-width*.01);
@return ($target/$vw-context) * 1vw;
@paultannenbaum
paultannenbaum / recursive_file_search.md
Created August 18, 2015 23:06
Linux: search current directory and sub directories for file

find . -print | grep -i my_filename

@paultannenbaum
paultannenbaum / interview-question-3.js
Last active August 29, 2015 14:22
Question: Using Javascript, create a function that can tell whether a number is happy number or not by logging it to the console. You can use a library like underscore or jQuery for utility methods if desired.
/*
A happy number is a number defined by the following process:
Starting with any positive integer, replace the number by the sum of the squares of its digits,
and repeat the process until the number equals 1 (where it will stay),
or it loops endlessly in a cycle which does not include 1.
Those numbers for which this process ends in 1 are happy numbers,
while those that do not end in 1 are unhappy numbers (or sad numbers).[1]
For example, 19 is happy, as the associated sequence is:
@paultannenbaum
paultannenbaum / interview-question-2.js
Last active August 29, 2015 14:22
Question: Tell us the 10 most frequent letters, in order, occurring in the 1000 most common words listed on this page: http://www.giwersworld.org/computers/linux/common-words.phtml. Bonus points if you can do this in vanilla js (no jQuery).
/** Steps **/
// 1.) First Grab the 1000 words and put into an array:
var wordArray = document.getElementsByTagName('pre')[0].innerHTML.split("\n");
var characterArray = document.getElementsByTagName('pre')[0].innerHTML.replace(/\n/g,'').split('');
// 2.) Create an object which stores character by frequency, and create a sorting function
var characterObj = {};
var populateCharacterObjByFrequency = function(string) {
for (var i=0; i<string.length; i++) {
@paultannenbaum
paultannenbaum / interview-question-1.js
Last active August 29, 2015 14:20
Question: Given a set of people that lived sometime between 1900 - 2000, find the year(s) when the most people were alive.
/*
Assuming the 'people' set looks as follows: [{birth: 1910, death: 1986}, {birth: 1930, death: 1993}, etc]
*/
var people = [...]; // predetermined
var yearArray = [];
var aliveInYearSet = [];
var mostPopulousYears = [];
// populate year array
@paultannenbaum
paultannenbaum / unique-intro.md
Last active March 31, 2017 20:39
The Unique Introduction - Math Riddle

Four couples and one single person attend a party. At the time they enter, none of the guests know anyone else besides their partners, if they came with one. Once in the room, everyone wanders around individually and mingles, and if they meet someone new they introduce themselves. After a few hours, a buzzer goes off and everyone stops talking. Every person has made a unique number of introductions ranging from zero to eight. With this info, how many introductions has the single person made?

Facts for clarity:

  • 9 people total, 4 couples and one stag
  • Each person has a unique introduction count, ranging from 0 - 8
  • Couples do not introduce themselves to their partners