Skip to content

Instantly share code, notes, and snippets.

@brianmhunt
brianmhunt / .profile
Created April 12, 2016 16:01 — forked from bmhatfield/.profile
Automatic Git commit signing with GPG on OSX
# In order for gpg to find gpg-agent, gpg-agent must be running, and there must be an env
# variable pointing GPG to the gpg-agent socket. This little script, which must be sourced
# in your shell's init script (ie, .bash_profile, .zshrc, whatever), will either start
# gpg-agent or set up the GPG_AGENT_INFO variable if it's already running.
# Add the following to your shell init to set up gpg-agent automatically for every shell
if [ -f ~/.gnupg/.gpg-agent-info ] && [ -n "$(pgrep gpg-agent)" ]; then
source ~/.gnupg/.gpg-agent-info
export GPG_AGENT_INFO
else
@brianmhunt
brianmhunt / dispatch.yaml
Last active October 22, 2020 20:13
ACME + AppEngine
application: some-dummy-app-name # overridden by -A
dispatch:
# Let's Encrypt ACME challenge service
- url: "*/.well-known/acme-challenge/*"
module: acme
@brianmhunt
brianmhunt / README.md
Last active August 29, 2015 14:25
MWE re. karma-browserify#137

Run npm install then gulp && karma start to try out the tests.

@brianmhunt
brianmhunt / trepid.py
Created January 3, 2015 20:27
Human UX strings mapping
"""
Human UX strings mapping
See http://stackoverflow.com/a/27459196
0 1 2 3 4 5 6 7 8 9 A B C D E F Hexadecimal
H M N 3 4 P 6 7 R 9 T W C X Y F Replacement
Y = U = V
C = G
@brianmhunt
brianmhunt / b-b.coffee
Last active August 29, 2015 14:09
Browserify transforms not working with paths
# << Any invalid Javascript character.
module.exports.hereiam = ->
console.log("0xDEADBEEF")
@brianmhunt
brianmhunt / models.py
Last active December 3, 2015 19:01
tags for ndb on Google App Engine / Python
"""
From blog post: http://brianmhunt.github.io/articles/ndb-tags/
License: MIT <http://brianmhunt.mit-license.org/>
"""
from google.appengine.ext import ndb
MAX_TAGS_FOR_TAGGABLE = 1000
POPULAR_PAGE_SIZE = 30
@brianmhunt
brianmhunt / credentials.py
Created January 25, 2014 19:09
Storing passwords using Python (on Google App Engine)
import Crypto.Random
from Crypto.Protocol import KDF
from google.appengine.ext import ndb
from datetime import datetime
class Credentials(ndb.Model):
"""Credentials to authenticate a person.
"""
# --- Class Variables ---
# Our pseudo-random stream - used for generating random bits for the
@brianmhunt
brianmhunt / flask-session-test.py
Created May 13, 2013 18:01
A substantial attempt at replicating an issue with the unit testing of Flask sessions
import os
import sys
import logging
import unittest
from pdb import set_trace
from google.appengine.ext import testbed
from flask import Flask, session
app = Flask('fs')
@brianmhunt
brianmhunt / gist:5512916
Last active December 16, 2015 23:19
A way to walk a namespace with a string in Coffeescript/Javascript; requires lodash/underscore
#
# Deep pluck
# ~~~~~~~~~~
# Pull a deeply nested element out based on an array of arguments
#
# e.g. array['abc'][0] == deepPluck(array, ['abc', 0])
#
deepPluck = (obj, array_or_string, _default=undefined) ->
if _.isString(array_or_string)
keys = array_or_string.split('.')
@brianmhunt
brianmhunt / pickadate-ko-binding.coffee
Last active December 16, 2015 19:10
Knockout binding for amsul/pickadate.js
# This is just a stub variable to keep track of multiple bindings.
# One could just have the bindings.date below directly link to
# ko.bindingHandlers, but then you would have to update the unit tests.
bindings = {}
# This gist depends on the inclusion of libraries:
#
# lodash (or underscore): http://lodash.com
# Used for _.isEqual, _.isDate, _.isString, _.defer
#