Skip to content

Instantly share code, notes, and snippets.

{
"order_groups":{
"323534":{
"order_ids":[
444788
],
"log_ids":[
2550087,
2550068,
2550501
SHOW_INFO_ICON = $(shell printf "\033[34;1m▶\033[0m")
SHOW_SUCCESS_ICON = $(shell printf "\033[32;1m✔\033[0m")
.PHONY: test
test: setup_env
$(info $(SHOW_INFO_ICON) Initializing test ...)
@echo 'test test test'
$(info $(SHOW_SUCCESS_ICON) Test complete)
@mfalade
mfalade / sleepsort.js
Last active January 26, 2020 00:17
My play play draft implementation of the sleep sort algo. Would nap for a long time for really large numbers though.
const unsortedListOfNumbers = [5, 13, 3, 0, 1, 89, 1, 21, 34, 2, 55, 8];
const TIMEOUT_PADDING = 50;
const sleepSort = async listOfNums => {
const result = [];
const promises = listOfNums.map(
num =>
new Promise(resolve => {
setTimeout(() => {
result.push(num);
@mfalade
mfalade / objectPaths.js
Last active January 16, 2020 21:40
Get all the paths in an object.
import isPlainObject from 'lodash/isPlainObject';
function canTraverseNodes(obj) {
return isPlainObject(obj) || (Array.isArray(obj) && isPlainObject(obj[0]));
}
function getAllPaths(obj, basePath = '', paths = []) {
if (!canTraverseNodes(obj)) {
return paths;
}
@mfalade
mfalade / settings.php
Created August 4, 2019 21:25
Inbox of purpose settings backup
<?php
/**
* Boss Pro
*
* This file adds functions to the Boss Pro Theme.
*
* @package Boss
* @author Bloom
* @license GPL-2.0+
* @link http://my.studiopress.com/themes/boss/
@mfalade
mfalade / creditCardValidator.js
Last active March 6, 2019 15:03
A Javascript implementation of the Luhn Algorithm used for validating credit card numbers.
const isCardNumberValid = cardNumber => {
const normalizedStr = cardNumber.replace(/\s/g, '');
const tokens = Array.from(normalizedStr).map(Number);
const checkDigit = tokens.pop();
const nonCheckDigitsSum = tokens
.reverse()
.reduce((sum, token, i) => {
if (!(i % 2)) {
const strigifiedDouble = (token * 2).toString();
@mfalade
mfalade / myArrayReduce.js
Created September 8, 2018 06:37
A basic implementation of the Array.prototype.reduce method
Array.prototype.xreduce = myReduce;
function myReduce (action, defaultValue) {
var result = [];
var isObject = typeof defaultValue === 'object';
var initialAccVal = isObject ? (defaultValue.constructor === Object ? {} : []) : defaultValue;
var acc = isObject ? Object.assign(initialAccVal, defaultValue) : defaultValue;
@mfalade
mfalade / myArrayFilter.js
Created September 8, 2018 06:25
Basic Implementation of the array filter
Array.prototype.xfilter = myCustomArrayFilter;
function myCustomArrayFilter (action) {
var result = [];
for (var i = 0; i < this.length; i++) {
var args = [this[i], i, this];
if (action.apply(null, args)) {
result.push(this[i]);
}
}
@mfalade
mfalade / myArrayMap.js
Created September 8, 2018 06:23
Custom Array Map
Array.prototype.xmap = myCustomArrayMap;
function myCustomArrayMap (action) {
var result = [];
for (var i = 0; i < this.length; i++) {
var args = [this[i], i, this];
result.push(action.apply(null, args));
}
return result;
}
@mfalade
mfalade / db-fields.yml
Last active July 23, 2018 11:49
Yasmine's project fields
#### Models
user:
fields:
id:
type: string
required: true
requestType:
type: string
enum: [first-user, new-user, client-vip]
required: true