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 / 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
#
[
{
"id": 6,
"name": "banana"
},
{
"id": 5,
"name": "burrito"
},
{
@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",
@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 / 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 / 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 / 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;
#! /usr/bin/perl
# Written by Dormando.
# PUBLIC DOMAIN.
# No guarantees it won't eat your cat.
use warnings;
use strict;
use IO::Socket::INET;
use Time::HiRes qw/time sleep/;

hi

foreverasdasdasd

@bryanhelmig
bryanhelmig / middleware.py
Last active August 29, 2015 14:02
Skip sessions and user authentication middleware in Django (1.4).
from django.conf import settings
from django.core.handlers.base import BaseHandler
from django.core import urlresolvers
SILENT_EARLY_RETURN_FAIL = getattr(settings, 'SILENT_EARLY_RETURN_FAIL', True)
def return_early_decorator(view):
"""
In a view, return early, like so: