Skip to content

Instantly share code, notes, and snippets.

View avoidwork's full-sized avatar

Jason Mulligan avoidwork

View GitHub Profile
### Keybase proof
I hereby claim:
* I am avoidwork on github.
* I am jasonmulligan (https://keybase.io/jasonmulligan) on keybase.
* I have a public key whose fingerprint is A46E 0C2C 229C 5068 236E 4D1E FD34 0167 2668 CACA
To claim this, I am signing this object:
Wordlist ver 0.732 - EXPECT INCOMPATIBLE CHANGES;
acrobat africa alaska albert albino album
alcohol alex alpha amadeus amanda amazon
america analog animal antenna antonio apollo
april aroma artist aspirin athlete atlas
banana bandit banjo bikini bingo bonus
camera canada carbon casino catalog cinema
citizen cobra comet compact complex context
credit critic crystal culture david delta
dialog diploma doctor domino dragon drama
@avoidwork
avoidwork / filesize.js
Created March 24, 2012 01:05
filesize.js
filesize(500); // "3.91Kb"
filesize(500, true); // "3.9k"
filesize(1500); // "1.46KB"
filesize("1500000000"); // "1.40GB"
filesize("1500000000", 0); // "1GB"
filesize(1212312421412412); // "1.08PB"
filesize(1212312421412412, true); // "1.1P" - shorthand output, similar to *nix "ls -lh"
@avoidwork
avoidwork / gist:1423758
Created December 2, 2011 16:03
(Proof of concept) Facade for HTML5 dataset attributes with fallback to data- attributes
/**
* Data attributes facade
*
* @type {Object}
*/
var data = {
/**
* Getter
*
* @param {Object} obj Element to query
@avoidwork
avoidwork / gist:3749846
Created September 19, 2012 14:01
MySQL delimited insert
# The second SET statement is optional, and could be ignored if you have a well formed delimited string
SET @var = 'test, w00t, w00tz';
SET @var := REPLACE(@var, ' ', '');
SET @var := CONCAT("('", REPLACE(@var, ",", "'),('"), "')");
SET @sql := CONCAT('INSERT INTO table VALUES ', @var);
# Verify the query, exeute via prepared statement
SELECT @sql AS `query`;
@avoidwork
avoidwork / gist:6215773
Created August 12, 2013 22:08
groc test
<!DOCTYPE html><html lang="en"><head><title>test</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content=""><meta name="groc-document-path" content="test"><meta name="groc-project-path" content="src/test.js"><link rel="stylesheet" type="text/css" media="all" href="assets/style.css"><script type="text/javascript" src="assets/behavior.js"></script><body><div id="meta"><div class="file-path">src/test.js</div></div><div id="document"><div class="segment"><div class="comments doc-section"><div class="wrapper"><p><span class='doc-section-header'>Method renderChildViews </span></p>
<p>Renders collection child views.</p>
<p>Parameters:</p>
<ul>
<li><p><strong>collection must be an Array.</strong><br/>(- collection of child models who have views created.)</p></li>
<li><p><strong>$el must be an Object.</strong><br/>(- Element to append child view
@avoidwork
avoidwork / gist:6436452
Last active December 22, 2015 07:09
CAP sample shape
{
"identifier": "",
"sender": "",
"sent": "",
"status": "",
"msgType": "",
"scope": "",
"restriction": "",
"addresses": "",
"incidents": "",
@avoidwork
avoidwork / bin2dec.js
Last active April 28, 2016 20:27
Binary to decimal
function bin2dec (arg) {
let output = 0;
arg.split("").reverse().forEach((i, idx) => {
let v = Number(i);
if (v > 0) {
output += idx > 0 ? Math.pow(2, idx) : 1;
}
});
@avoidwork
avoidwork / curry.js
Created April 4, 2017 12:21
Curry example
function curry (fn, ...x) {
const lfn = fn.apply(fn, x);
return function (...y) {
return lfn.apply(lfn, y);
};
}
'/slack': (req, res) => {
if (req.query.code !== void 0) {
let form = new FormData();
form.append('code', req.query.code);
form.append('client_id', config.slack.client_id);
form.append('client_secret', config.slack.client_secret);
fetch('https://slack.com/api/oauth.access', {method: 'POST', body: form, headers: form.getHeaders()}).then(res => res.json()).then(data => {
if (data.ok) {