Skip to content

Instantly share code, notes, and snippets.

View piperchester's full-sized avatar
🏗️
Build

Piper piperchester

🏗️
Build
View GitHub Profile
def find_max_subarray(arr):
min_sum = max_sum = 0
for running_sum in itertools.accumulate(arr):
min_sum = min(min_sum, running_sum)
max_sum = max(max_sum, running_sum - min_sum)
return max_sum
@piperchester
piperchester / happo-ci.sh
Created August 29, 2019 17:58
Sample CI Happo script
#!/bin/bash
set -eu
# This should likely be the "baseline" of what's currently been recorded
# from master
export PREVIOUS_SHA=$(git rev-parse origin/master)
# This should likely be the newly introduced commit
export CURRENT_SHA="$(git rev-parse HEAD)"

Recursion examples

def fn1(n):
  """Linear."""
  return 1 if n <= 0 else 1 + fn1(n-1)

def fn2(n): """Linear."""

@piperchester
piperchester / samples.py
Created June 8, 2018 02:36
Code samples for problems
# matrix
matrix = [
[1,2,3],
[4,5,6]
]
@piperchester
piperchester / treeshaking.md
Created April 2, 2018 20:40
Treeshaking Example
// treeshaking - remove all nodes at height 3 if they're leaves

      *
    / | \
   *  *  *
        / \
       *  *
        /  \
 * *
@piperchester
piperchester / ultimate-ut-cheat-sheet.md
Last active March 23, 2018 00:18 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai and Sinon

The Ultimate Unit Testing Cheat-sheet

For Mocha, Chai and Sinon

using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies


@piperchester
piperchester / package.json
Last active January 12, 2018 14:21
Base package.json
{
"name": "piper.im",
"version": "2.0.0",
"description": "Personal website of Piper Chester",
"main": "index.html",
"dependencies": {
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-scripts": "1.0.17",
"http-server": "^0.10.0",
{
dependencies: {
prettier,
husky,
lint-staged,
}
}
@piperchester
piperchester / hoisting.js
Created July 7, 2017 13:18
Hoisting demo
// hoisting sample
'use strict';
console.log(bar); // undefined
var bar = 'bar';
console.log(bar); // 'bar'
// function decls hoisted as well (not func expressions though)
uptime
dmesg | tail
vmstat 1
mpstat -P ALL 1
pidstat 1
iostat -xz 1
free -m
sar -n DEV 1
sar -n TCP,ETCP 1
top