Skip to content

Instantly share code, notes, and snippets.

View blangenfeld's full-sized avatar

Brian Langenfeld blangenfeld

View GitHub Profile
@blangenfeld
blangenfeld / gist:6737936
Last active November 22, 2017 09:40
An AngularJS directive for creating (and optionally binding) a Kalendae datepicker.
/**
* @ngdoc directive
* @name kf.directives:kalendae
* @restrict A
*
* @description
* The `kalendae` directive is used to attach a Kalendae datepicker to an element.
*
* @element ANY
* @param {string} kalendae options passed to the Kalendae datepicker; see http://github.com/ChiperSoft/Kalendae
@blangenfeld
blangenfeld / gist:6767372
Created September 30, 2013 17:41
AngularJS directives for formatting arrays of dates.
angular.module('kf.filters', []).
/**
* @ngdoc filter
* @name kf.filters:dates
* @function
*
* @description
* Passed an Array of Dates, returns a String joining them together with a delimiter. The dates
* themselves may be customized with an Angular `date` filter specifier.
*
@blangenfeld
blangenfeld / gist:6779807
Created October 1, 2013 14:58
An AngularJS filter for turning a date pair into an array containing all intervening dates.
angular.module('kf.filters', []).
/*
* Because ngScope $watchCollection uses === to evaluate whether a collection has changed, we
* need a way to return the same Date objects -- in the identity (not equality) sense -- to avoid
* a $digest death spiral.
*/
factory('DateCache', ['$cacheFactory', function($cacheFactory) {
return $cacheFactory('dateCache');
}]).
@blangenfeld
blangenfeld / server.py
Created April 12, 2016 19:56
Four line HTTPS server
import BaseHTTPServer, SimpleHTTPServer, ssl
httpd = BaseHTTPServer.HTTPServer(('localhost', 4443), SimpleHTTPServer.SimpleHTTPRequestHandler)
httpd.socket = ssl.wrap_socket (httpd.socket, certfile='./localhost.pem', keyfile='./localhost.key', server_side=True)
httpd.serve_forever()
@blangenfeld
blangenfeld / drip-fetch-all.sh
Last active December 5, 2018 18:12
Bash script for fetching ALL of a Drip account's "whatevers". Echoes results to stdout as a JSON array as they come in. Not fancy, but it works.
#! /bin/bash
# Bash script for fetching ALL of a Drip account's whatevers to file.
# Not fancy, but it works.
#
# Usage: ./drip-fetch-all.sh <resource>
#
# brian@knotfield.com
RESOURCE=$1 # subscribers, campaigns, tags, ...
@blangenfeld
blangenfeld / drip-deauthorize-all-apps.js
Created September 14, 2017 15:29
Got tired of deauthorizing connected apps one by one during development.
$('.applications-list li a.button--red').each(function() {
$.post($(this).attr('href'), {
_method: 'delete',
authenticity_token: $('meta[name=csrf-token]').attr('content')
});
});