Skip to content

Instantly share code, notes, and snippets.

@park-brian
park-brian / AdvancedWindowSnap.ahk
Last active February 6, 2024 21:53 — forked from AWMooreCO/AdvancedWindowSnap.ahk
Advanced Window Snap is a script for AutoHotKey that expands upon Windows built-in window-snapping hotkeys.
/**
* Advanced Window Snap
* Snaps the active window to a position within a user-defined grid.
*
* @author Andrew Moore <andrew+github@awmoore.com>
* @contributor jballi
* @contributor park-brian
* @contributor shinywong
* @version 1.2
*/
@park-brian
park-brian / index.html
Last active August 11, 2021 19:00
RWS Editor Test Latest
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>GistRun</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<input id="height" placeholder="Height">
<input id="width" placeholder="Width">
@park-brian
park-brian / importDynamoDBTable.js
Last active July 19, 2021 23:49
Uses parallel batchWrite requests to quickly load data into DynamoDB.
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
async function insertDynamoDBItems(documentClient, tableName, items) {
if (!items.length) return;
let responses = [];
let response = await documentClient
.batchWrite({
@park-brian
park-brian / index.html
Last active July 6, 2021 15:39
Breast Cancer QQ Plot
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>GistRun</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>PLCO QQ Plot</h1>
@park-brian
park-brian / fromCsv.js
Last active June 2, 2021 15:24
CSV utilities
/**
* A parser which handles any rfc4180 compliant csv file
* Configuration takes the following properties
* delimiter: specifies the field delimiter (default: ",")
* escape: specifies the escape character (default: ")
* skipLines: specifies the number of lines to skip (default: 0)
* transformRow: transform sthe default ouput from an array of strings to your custom format (eg: an array of objects)
* transformValue: transforms individual values (eg: for custom typecasting logic)
*/
@park-brian
park-brian / request.js
Last active May 5, 2021 19:07
Promise-based wrapper for space-constrained Node.js applications (aws lambda, gc functions, etc)
/**
* A Promise-based wrapper for the http/https.request function
* @param {string|URL} url - Strings are parsed as URL objects
* @param {Object} opts - A set of options for http.request - includes `body`
* @example let response = await request('http://jsonplaceholder.typicode.com/posts/1')
*/
function request(url, opts) {
return new Promise((resolve, reject) => {
if (!(url instanceof URL)) {
@park-brian
park-brian / index.html
Last active January 30, 2021 20:12
RWS Editor Test 2
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>GistRun</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<input id="height" placeholder="Height">
<input id="width" placeholder="Width">
@park-brian
park-brian / QuadTree.js
Last active October 12, 2020 21:53
A simple quadtree for rapidly fetching spatial data
/**
* A simple quadtree for rapidly fetching spatial data
* @param {number} xMin
* @param {number} xMax
* @param {number} yMin
* @param {number} yMax
*/
function QuadTree(xMin, xMax, yMin, yMax) {
// swap xMin/xMax and yMin/yMax if needed
if (xMin > xMax) [xMin, xMax] = [xMax, xMin];
@park-brian
park-brian / forEachPromise.js
Last active June 23, 2020 15:08
promise-utils
/**
* Sometimes, we need a plain es5 function to chain execution of promises (eg: when
* targeting older browsers using polyfills, while eschewing a build step). This function
* takes an array of promises or functions which return promises, and applies the supplied
* callback function against each promise sequentially, waiting for resolution before
* executing/resolving the next promise.
*
* Promises always resolve in their order of appearance. However, this function only
* defers execution of promises if functions which return promises are provided (eg:
* using .bind to create bound functions).
@park-brian
park-brian / validate.js
Last active June 23, 2020 15:00
A simple utility to validate objects (based off the Angular validation api)
function validate(object, rules) {
return Object.entries(object).reduce((errors, [key, value]) => {
let validators = rules[key];
if (!validators || validators.length === 0)
return errors;
if (typeof validators === 'function')
validators = [validators];