Skip to content

Instantly share code, notes, and snippets.

View deecewan's full-sized avatar

David Buchan-Swanson deecewan

View GitHub Profile
@deecewan
deecewan / test.js
Created March 12, 2016 11:38
console.slack tests
var slack = require('./console-slack');
slack.options = {
webhook : '<redacted>',
channel : '#testing-ground',
}
console.slack('Hello, World!', '#testing-ground', function(resp, status){
console.slack("Response is: " + resp);
console.slack("Status is: " + status);
document.addEventListener('keydown', function(e){
if (e.ctrlKey || e.metaKey){
if (String.fromCharCode(e.which).toLowerCase() != 's') return;
e.preventDefault();
console.log('Trying to save');
}
});
/**
* This is a little, useless script that will highlight your Javadoc methods green when you click them.
* I made it because I kept looking at the wrong one when I was implementing it.
*
* Just copy and paste this into your browsers JS console. Changing tabs will break functionality. You'll have to redo it
*/
[].forEach.call(document.querySelectorAll('h3'), function(tag){
if (tag.parentNode.tagName == 'LI'){
var theUl = tag.parentNode.querySelectorAll('ul.blockList, ul.blockListLast');

Keybase proof

I hereby claim:

  • I am deecewan on github.
  • I am deecewan (https://keybase.io/deecewan) on keybase.
  • I have a public key whose fingerprint is BE67 AC11 5662 B306 2C21 84FE E304 77EF 73F6 6487

To claim this, I am signing this object:

@deecewan
deecewan / server.js
Created October 28, 2016 09:17
@ghiculescu beat me to it by 10 minutes 😥🚀💯
import Express from 'express';
let db = {};
const app = new Express();
app.post('/clear_data', (req, res) => {
db = {};
res.sendStatus(200);
});
@deecewan
deecewan / api.js
Created February 17, 2017 01:19
Proxies to easily make requests to an API
function wrapInProxy(target) {
return new Proxy(target, {
get: (target, name) => {
target.endpoint = target.endpoint || [];
const fn = (data) => dispatch => dispatch(makeRequest(name, target.endpoint.join('/'), data));
fn.endpoint = [...target.endpoint, name];
return wrapInProxy(fn);
}
});
}
@deecewan
deecewan / testbg.js
Created March 12, 2017 01:57
Simple script to test Google Cloud Functions background functions
#!/usr/bin/env node
const join = require('path').join;
const read = require('fs').readFileSync;
const args = process.argv.slice(2);
const fnName = args[0];
const payload = args[1];
const fileBuffer = read(join(__dirname, 'payloads', `${payload}.json`));
@deecewan
deecewan / .babelrc
Created March 13, 2017 23:24
The files it takes for me to start a new JS lib
{
"presets": [["env", {
"targets": {
"node": 6.9
}
}], "stage-0"],
"plugins": [
"babel-plugin-syntax-trailing-function-commas",
"babel-plugin-transform-class-properties",
"babel-plugin-transform-flow-strip-types",
@deecewan
deecewan / .zshrc
Created March 14, 2017 08:32
Store all your brew formula and reload in case of emergency
# ...
brw() {
brew $@
brew list --versions | perl -pe 's/([\w-(@\d\.\d)]+).*/$1/' > $CONFIG/brew_installed.txt
}
restore_from_brew() {
cat $CONFIG/brew_installed.txt | xargs brew install
}
@deecewan
deecewan / Makefile
Created June 3, 2017 05:15
Makefile for a pandoc project converting markdown to latex
SHELL=zsh
.PHONY: all copy clean
all: copy out/main.tex
clean:
rm -r out/*
copy:
zsh -c 'setopt extendedglob; cp -r src/^(template.tex|*.md) out/'