Skip to content

Instantly share code, notes, and snippets.

View jeffschwartz's full-sized avatar

Jeff Schwartz jeffschwartz

View GitHub Profile
@jeffschwartz
jeffschwartz / metrics.js
Last active October 1, 2023 12:50
metrics.js uses Node's process.hrtime(time) for nano second precision. Public api: startTimer, stopTimer, forEachTimer, clearTimers.
/**
* Metrics uses process.hrtime(time) for nano second precision.
* public api: startTimer, stopTimer, forEachTimer, clearTimers, filterTimer
*/
import chalk from "chalk";
const timers = new Map();
const startTimer = (name, precision = 3) => {
@jeffschwartz
jeffschwartz / metrics.ts
Last active October 1, 2023 12:42
metrics.ts uses Node's process.hrtime(time) for nano second precision. Public api: startTimer, stopTimer, forEachTimer, clearTimers.
/**
* Metrics uses process.hrtime(time) for nano second precision.
* public api: startTimer, stopTimer, forEachTimer, clearTimers, filterTimer
*/
import chalk from "chalk";
interface Timer {
name: string,
precision: number,
@jeffschwartz
jeffschwartz / init.vim
Last active December 11, 2021 18:15
My ~/.config/nvim/init.vim
""
" init.vim
""
""
" Plugins via vim-plug
" Specify a directory for plugins
" - For Neovim: ~/.local/share/nvim/plugged
" - Avoid using standard Vim directory
" names like 'plugin'
@jeffschwartz
jeffschwartz / ProxyJS.js
Last active June 19, 2021 14:48
ProxyJS is a small JavaScript library that provides the ability to proxy any function or object property method. It includes an API and you can extend it with additional functionality to fit your particular use case. Enjoy!
function proxy(){
var proxyFactory = function(){
//The wrapped function to call.
var fnToCall = arguments.length === 2 ? arguments[0][arguments[1]] : arguments[0];
//A counter used to note how many times proxy has been called.
var xCalled = 0;
@jeffschwartz
jeffschwartz / trio.code-snippets
Last active November 10, 2019 14:45
Visual Studio Code User Snippets For Trio
{
// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
// Placeholders with the same ids are connected.
"Trio Front Matter": {
"scope": "html, markdown",
"prefix": "tfm",
/* http://meyerweb.com/eric/tools/css/reset/
v2.0-modified | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
@jeffschwartz
jeffschwartz / install-node.sh
Created December 7, 2018 22:49
install node without sudo and use without sudo on Linux
#!/bin/bash
VERSION=v10.1.14
DISTRO=linux-x64
mkdir ~/local
mkdir ~/local/lib
mkdir ~/local/lib/nodejs
tar -xJvf ~/Downloads/node-$VERSION-$DISTRO.tar.xz -C ~/local/lib/nodejs
mv ~/local/lib/nodejs/node-$VERSION-$DISTRO ~/local/lib/nodejs/node-$VERSION
@jeffschwartz
jeffschwartz / .eslintrc.json
Created August 25, 2018 12:03
.eslintrc.json
{
"extends": "standard",
"parserOptions": {
"sourceType": "module"
},
"rules": {
"indent": [
"error",
4
],
@jeffschwartz
jeffschwartz / init.vim
Created June 1, 2018 17:05
Neovim init.vim configuration file
" {{ Plugins via vim-plug
" Specify a directory for plugins
" - For Neovim: ~/.local/share/nvim/plugged
" - Avoid using standard Vim directory names like 'plugin'
"
call plug#begin('~/.local/share/nvim/plugged')
" Surround plugin
Plug 'tpope/vim-surround'
const curry = (fn) => {
var a = [];
var $curry = (...args) => {
var tooManyArgsException = n =>
`too many args exception: curry expected ${fn.length} args; found ${n} args`;
a = [...a, ...args];
// reset if already has fulfilled arity requirement