Skip to content

Instantly share code, notes, and snippets.

View bguiz's full-sized avatar

Brendan Graetz bguiz

View GitHub Profile
@bguiz
bguiz / git-dependency-install-and-build.sh
Created August 23, 2016 00:24
Installs a dependency from a git repo using info specified in pakage.json, then builds it
#!/bin/bash
# Installs a dependency from a git repo using info specified in pakage.json, then builds it
: <<"MultilineCommentDelimiter"
Place this file in ./devops/git-dependency/install-and-build.sh
Update package.json to add "config" and a a build step to "scripts"
{
"config": {
@bguiz
bguiz / catch-doesnt-stop-promise-chain.js
Last active July 1, 2016 05:37
`.catch()` doesn't stop the rest of a promise chain from executing
// returns a promise that always rejects
function myPromise() {
return new Promise((resolve, reject) => {
reject('error in myPromise');
});
}
// promise.catch(a).then(b).catch(c)
myPromise().catch(function a(err) {
console.log('a:', err);
@bguiz
bguiz / braintree-sdk.spec.js
Created June 16, 2016 01:23
Braintree SDK test demo'ing invalid nonces letting TXs through
'use strict';
const co = require('co');
const chai = require('chai');
const expect = chai.expect;
describe.only('[Braintree SDK]', function() {
this.timeout(5000);
@bguiz
bguiz / mocha-async-sequence.spec.js
Last active January 12, 2016 05:25
Proving that mocha executes async tests in sequence (and also shows how to use with generator functions)
'use strict';
let co = require('co');
let chai = require('chai');
let expect = chai.expect;
function waitFor(duration) {
return new Promise(function(resolve) {
setTimeout(resolve, duration);
});
@bguiz
bguiz / letsencrypt-help-all.txt
Created December 15, 2015 01:09
LetEncrypt command line manpage
$ letsencrypt-auto --help all
Updating letsencrypt and virtual environment dependencies.......
usage:
letsencrypt [SUBCOMMAND] [options] [-d domain] [-d domain] ...
The Let's Encrypt agent can obtain and install HTTPS/TLS/SSL certificates. By
default, it will attempt to use a webserver both for obtaining and installing
the cert. Major SUBCOMMANDS are:
(default) run Obtain & install a cert in your current webserver
@bguiz
bguiz / convert-angularjs-from-bower-globals-to-commonjs-require.js
Last active August 29, 2015 14:16
output a composition root from conventional bower based angularjs projects to a bundled browserified project using gulp
/* jshint node: true */
'use strict';
var gulp = require('gulp'),
bower = require('./bower'),
replace = require('gulp-replace'),
through2 = require('through2');
/**
@bguiz
bguiz / svg-9slice-scaling.svg
Created January 20, 2015 05:18
svg 9-slice scaling - +chrome + firefox -ie
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bguiz
bguiz / group-slice.svg
Created January 20, 2015 02:53
Demonstrates how to slice an SVG into a 3x3 grid using symbol with viewBox+preserveAspectRatio, and then reassmble into original
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bguiz
bguiz / quick-select-in-place.js
Created July 29, 2014 01:39
Quick select implementation in Javacript
/*
* Places the `k` smallest elements (by `propName`) in `arr` in the first `k` indices: `[0..k-1]`
* Modifies the passed in array *in place*
* Returns a slice of the wanted eleemnts for convencience
* Efficent mainly due to never performaing a full sort.
*
* The only guarantees are that:
*
* - The `k`th element is in its final sort index, if the array were to be sorted
* - All elements before index `k` are smaller than the `k`th element