Skip to content

Instantly share code, notes, and snippets.

View MikeyBurkman's full-sized avatar

Michael Burkman MikeyBurkman

  • Truebill
  • Washington, DC, USA
View GitHub Profile
@MikeyBurkman
MikeyBurkman / set.js
Last active April 22, 2020 19:00
A set implementation that allows for more than just primitive types
'use strict';
const newSet = (idFn, initialValues) => {
if (!idFn) {
idFn = (x) => x;
}
const init = initialValues ?
initialValues.map((x) => [idFn(x), x]) :
@MikeyBurkman
MikeyBurkman / launch.json
Last active November 5, 2019 20:18
Default mocha test debugging in VS Code
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Start",
"type": "node",
"request": "launch",
@MikeyBurkman
MikeyBurkman / promise-lock.js
Last active December 13, 2022 03:23
Simple promise-based lock implementation
'use strict';
module.exports = {
createSingleLock: createSingleLock,
createKeyedLock: createKeyedLock
};
// Maintains a list of locks referenced by keys
function createKeyedLock() {
const locks = {};
@MikeyBurkman
MikeyBurkman / example.js
Last active June 29, 2017 20:30
Angular Directive Testing
'use strict';
describe('my-foo-directive', function() {
var testDirective;
var directive;
beforeEach(module('app.test.directive'));
beforeEach(module('app.templates'));
beforeEach(module('app.components.myFooDirective'));
@MikeyBurkman
MikeyBurkman / set.js
Last active June 9, 2017 20:15
JS Set implementation without prototype nonsense
'use strict';
// A drop-in replacement for Set.
// Why?
// 1) newSet() can be called as a regular function (no need for new)
// 2) None of the functions on it use `this`, which means they can be used as higher-order functions
function newSet(initialValues) {
const s = new Set();
@MikeyBurkman
MikeyBurkman / each.js
Last active October 20, 2017 19:27
Parallel each() promise implementation (since Bluebird does not have one)
'use strict';
module.exports = function each(items, fn, concurrency) {
if (items.length === 0) {
return Promise.resolve();
}
return new Promise((resolve, reject) => {
let error = false;
@MikeyBurkman
MikeyBurkman / index.html
Last active April 27, 2017 19:24
Angular Currency Input
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script>
</head>
<body ng-app="fooApp">
@MikeyBurkman
MikeyBurkman / blah.ts
Last active September 23, 2016 17:57
TS Example
const foo = [{
id: 1,
name: 'Mike'
}, {
id: 2,
name: 'Tom'
}, {
id: 3,
name: 'Sally'
@MikeyBurkman
MikeyBurkman / requestPromise.js
Created June 13, 2016 15:40
Request Promise Example
var request = include('request-promise', '3.0.0');
var restify = include('restify', '4.1.0');
var server = restify.createServer({
name: 'myapp',
version: '1.0.0'
});
server.get('/foo', function (req, res, next) {
@MikeyBurkman
MikeyBurkman / esclear.js
Created June 10, 2016 22:04
Clear Elasticsearch Index
#! /usr/bin/env cecil
// Usage:
// ./esclear.js http://your-elasticsearch-host.com
var elasticsearch = include('elasticsearch', '^11.0.0');
var index = 'testindex';
var host = process.argv[2];