Skip to content

Instantly share code, notes, and snippets.

View bryanhelmig's full-sized avatar
Zapier is hiring!

Bryan Helmig bryanhelmig

Zapier is hiring!
View GitHub Profile
@bryanhelmig
bryanhelmig / script_test.js
Last active November 24, 2016 05:15 — forked from billywhizz/script_test.js
record time spent on "each" run for nodejs or node vm module vs contextify, etc.
var vm = require('vm'),
Contextify = require('contextify'),
code = 'var square = n * n;',
fn = new Function('n', code),
script = vm.createScript(code);
n = 5;
benchmark = function(title, funk) {
var end, i, start, spins = 10000;
@bryanhelmig
bryanhelmig / parallel_runner.py
Created June 13, 2015 17:37
Really simple parallel Django test runner. Primarily for use with something like https://pypi.python.org/pypi/django-jux in Jenkins. BSD 3 clause licensed.
import importlib
from multiprocessing import Pool
from django.test.simple import DjangoTestSuiteRunner
from django.conf import settings
__doc__ = """
In settings.py do this:
JUXD_FILENAME = '/Code/project/junit.xml'
@bryanhelmig
bryanhelmig / default-lambda-eval.js
Last active August 2, 2018 01:41
The default function template for AWS Lambda in Zapier. Just create a Lambda function with this code named "zapier_eval" and we'll take care of the rest! This code is released to the public domain - feel free to customize, fork or repackage this.
'use strict';
var domain = require('domain');
var userMethod = 'handler';
var userCodeWrapper = function(userCode) {
return '\
"use strict";\n\
' + userCode + '\n\
try {\n\
@bryanhelmig
bryanhelmig / middleware.py
Last active March 16, 2016 18:21
This is how to disable the request_finished signal cache close connection behavior in Django.
class DisconnectCacheCloseSignal(object):
""" Add me to your settings.MIDDLEWARE_CLASSES """
def process_response(self, request, response):
from django.core.cache import caches, close_caches
signals.request_finished.disconnect(caches['default'].close)
signals.request_finished.disconnect(close_caches)
return response
@bryanhelmig
bryanhelmig / locations.json
Created March 18, 2016 06:01
some locations for a dev app!
[
{
"id": "222dcd03aed943a8676dc80e2427a40d",
"title": "The Headquarters",
"lat": 37.387617,
"long": -122.036132
},
{
"id": "a102c4a959dfe7efdd3a4e112bee0407",
"title": "A Sweet Beach",
[
{
"id": 6,
"name": "banana"
},
{
"id": 5,
"name": "burrito"
},
{
@bryanhelmig
bryanhelmig / crushimg.sh
Created July 15, 2016 21:33 — forked from caiguanhao/crushimg.sh
Recursively crush/shrink/optimize/losslessly compress PNGs, JPEGs and GIFs.
#!/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
#
@bryanhelmig
bryanhelmig / detect_mashing.py
Last active January 12, 2024 03:19
A short snippet of Python that detects keyboard mashing like dsuyafgsgafiuyas.
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 / active_user_analysis.py
Last active February 8, 2017 23:47
Counts of users' events by day
"""
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'
package main
import (
"fmt"
)
func decorator(f func(s string)) func(s string) {
return func(s string) {
fmt.Println("Started")