Skip to content

Instantly share code, notes, and snippets.

@pakman198
pakman198 / experimentInterceptor.js
Created August 22, 2020 18:02
axios interceptors
import axios from 'axios';
export const experimentsInterceptor = () => {
const getExperiments = () => {
const [, params] = window.location.search.split('?');
const experiments = params.split('ex.');
const values = experiments.reduce((tally, item) => {
if (item.match(/^[A-Z][A-Z][A-Z]\d\d/)) {
const newItem = item.replace('&', '');
@pakman198
pakman198 / commit-msg_hook.sh
Created March 16, 2020 00:52
git commit-msg hook
#!/bin/bash
MSG_FILE=$1
FILE_CONTENT="$(cat $MSG_FILE)"
# Initialize constants here
red='\033[0;31m'
green='\033[0;32m'
yellow='\033[0;33m'
no_color='\033[0m'
@pakman198
pakman198 / data-structures.js
Last active January 14, 2020 21:07
Algorithms / Data Structures
// Array Chunking
/*
Produces an output of an array with nested arrays of n given size
chunk([1,2,3,4,5], 2) ===> [ [1,2], [3,4], [5 ]
*/
function chunk(arr, size) {
const chunked = [];
let index = 0;
@pakman198
pakman198 / Families.js
Last active January 13, 2020 21:40
Coding Exercise
/*
Suppose we have some input data describing a graph of relationships between parents and children over multiple
generations. The data is formatted as a list of (parent, child) pairs, where each individual is assigned a unique
integer identifier.
For example, in this diagram, 3 is a child of 1 and 2, and 5 is a child of 4:
1 2 4
\ / / \
3 5 8