Skip to content

Instantly share code, notes, and snippets.

View F1LT3R's full-sized avatar
🌱
Growing Things

Alistair MacDonald F1LT3R

🌱
Growing Things
View GitHub Profile
@F1LT3R
F1LT3R / await-promise.js
Created February 27, 2019 16:54
Awaiting a promise that may throw an error
var wait = (ms) =>
new Promise((resolve, reject) => {
if (Math.random() > 0.5) {
return reject('NOPE!');
}
setTimeout(() => {
resolve('Done!');
}, ms);
});
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@F1LT3R
F1LT3R / proxy.js
Created April 28, 2018 04:08 — forked from fracasula/proxy.js
Node.js basic example for proxy to http server
/**
* Once this is running open your browser and hit http://localhost
* You'll see that the request hits the proxy and you get the HTML back
*/
'use strict';
const net = require('net');
const http = require('http');
@F1LT3R
F1LT3R / .ackrc
Last active April 4, 2018 17:18
.ackrc
--no-group
--color
--ignore-directory=is:node_modules
--ignore-file=is:Markserv.log
--ignore-file=is:npm.debug.*
--type-set=css:ext:less
--type-set=css:ext:scss
@F1LT3R
F1LT3R / aws-config.js.env
Last active September 15, 2017 14:26 — forked from ddewaele/simple-cognito-auth.js
AWS Cognito Auth for Node.js
module.exports = {
"AWS": {
"Region": "us-east-1",
"ClientId": "304laiduvj1ld6ls8s2lsjfipa",
"UserPoolId": "us-east-1_aaksjfhTo",
"IdentityPoolId": "us-east-1:018b7af4-9384-8afe-019d-013cc0192d001",
"LoginEndpoint": "cognito-idp.us-east-1.amazonaws.com/us-east-1_aaksjfhTo"
}
}
@F1LT3R
F1LT3R / binary-search-core.ts
Last active August 27, 2017 00:25
Binary Search Typescript
enum FailExits {
ologn,
nochop
}
let exit = FailExits.ologn
let iterCount:number
let maxIterations: number
const compare = (target: number, ary: number[], start: number, end: number): number[] | number | boolean => {
@F1LT3R
F1LT3R / Karabiner-Elements-Caps-Move-Vim-complex_modifications-rules.json
Last active August 10, 2017 16:28
Karabiner-Elements - Caps Move Vim - complex_modifications rules
{
"title": "Caps Move Vim",
"rules": [
{
"description": "Change Capslock + H/J/K/L to Arrow Keys",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "i",
@F1LT3R
F1LT3R / sha1-hash-node.js
Created August 1, 2017 04:09
sha1 hash node.js
const crypto = require('crypto')
const sha1 = path => new Promise((resolve, reject) => {
const hash = crypto.createHash('sha1')
const rs = fs.createReadStream(path)
rs.on('error', reject)
rs.on('data', chunk => hash.update(chunk))
rs.on('end', () => resolve(hash.digest('hex')))
})
@F1LT3R
F1LT3R / leaf.js
Last active June 7, 2017 05:26
Carlton Quadtree
/**
* Carlton Quadtree
* - A Quad Tree implementation in ESNext
* - Alistair MacDonald (f1lt3r)
* - MIT License
*
* Demos: http://f1lt3r.github.io/carlton-quadtree
*
* Example:
*
@F1LT3R
F1LT3R / special chats scrub delete terminal.js
Created March 2, 2017 05:03
special chats scrub delete terminal.js
const blinkOn = '\x1b\x5b\x35\x6d';
const blinkOff = '\x1b\x5b\x30\x6d';
const scrubSeq = '\x1b\x5b\x44';