Skip to content

Instantly share code, notes, and snippets.

Avatar
Zapier is hiring!

Bryan Helmig bryanhelmig

Zapier is hiring!
View GitHub Profile
View immer-patches.js
var immer = require("immer");
var produce = immer.produce;
var patches = [];
var state0 = { a: 1 };
var state1 = produce(
state0,
function (draft) {
draft.b = 9;
},
@bryanhelmig
bryanhelmig / compare-pips.py
Created Dec 26, 2017
Compare pip freeze to requirements.txt for use in a bash script where pip may not be installed.
View compare-pips.py
#!/usr/bin/env python
import argparse
import subprocess
import sys
from packaging.version import parse as parse_version
def parse_dependencies(text):
@bryanhelmig
bryanhelmig / linty.sh
Created Sep 11, 2017
a zapier python lint command, put it on path!
View linty.sh
#!/usr/bin/env bash
CHANGED_PYTHON_FILES=`git diff-tree --diff-filter=ACMRT --no-commit-id --name-only -r origin/develop.. -- "*.py" | tr "\n" " "`
flake8 --exit-zero --format=pylint ${CHANGED_PYTHON_FILES}
pylint --py3k --disable=no-absolute-import --disable=round-builtin -sn --msg-template="{path}:{line}: [{msg_id}] {msg}" ${CHANGED_PYTHON_FILES}
@bryanhelmig
bryanhelmig / nintendo-switch-getter.py
Created Mar 23, 2017
A script that watches prime now for stock, sending a webhook to Zapier which you can configure to send you an SMS, Slack, whatever...
View nintendo-switch-getter.py
import time
import bs4
import requests
import logging
import sys
logger = logging.getLogger('switchlogger')
logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler(sys.stdout)
View keybase.md

Keybase proof

I hereby claim:

  • I am bryanhelmig on github.
  • I am bryanhelmig (https://keybase.io/bryanhelmig) on keybase.
  • I have a public key whose fingerprint is BC07 78B9 D1A4 3DBA DF36 F565 4429 102A 84CB 847F

To claim this, I am signing this object:

View decorator.go
package main
import (
"fmt"
)
func decorator(f func(s string)) func(s string) {
return func(s string) {
fmt.Println("Started")
@bryanhelmig
bryanhelmig / active_user_analysis.py
Last active Feb 8, 2017
Counts of users' events by day
View active_user_analysis.py
"""
users if active or not on a given day plus counts of events
"""
import os
import csv
from collections import defaultdict
from collections import Counter
UFILE = 'data/users.csv'
@bryanhelmig
bryanhelmig / detect_mashing.py
Last active Nov 4, 2016
A short snippet of Python that detects keyboard mashing like dsuyafgsgafiuyas.
View detect_mashing.py
import itertools
import math
def tokenize_keyboard(board):
return [list(row.strip()) for row in board]
def invert_grid(grid):
out = {}
for row_i, row in enumerate(grid):
for col_i, cell in enumerate(row):
@bryanhelmig
bryanhelmig / crushimg.sh
Created Jul 15, 2016 — forked from caiguanhao/crushimg.sh
Recursively crush/shrink/optimize/losslessly compress PNGs, JPEGs and GIFs.
View crushimg.sh
#!/bin/bash
# This is modifed from https://gist.github.com/caiguanhao/4528926
# This is an improved script of pngfix.sh (https://gist.github.com/404909)
# which can also crush/shrink/optimize/losslessly compress JPEGs and GIFs.
# It is recommended you backup your image files before executing this script.
# Operation will be skipped if output file is bigger in size.
#
# use chmod +x crushimg.sh to make it executable and then ./crushimg.sh to run, or
# bash ./crushimg.sh to run it directly
#
View food.json
[
{
"id": 6,
"name": "banana"
},
{
"id": 5,
"name": "burrito"
},
{
You can’t perform that action at this time.