Skip to content

Instantly share code, notes, and snippets.

View kevinkace's full-sized avatar

Kevin Cameron kevinkace

View GitHub Profile
@kevinkace
kevinkace / timer.js
Last active June 17, 2021 20:12
see how long things take, without the fuckery of perf_hooks, so it's probably not terribly accurate, but it's easy
// usage:
// const timer = new Timer("timerName");
// doThing();
// timer.measure("didThing");
// await doThing2();
// timer.measure("didThing2");
// timer.report();
// ┌─────────┬─────────────┬───────────────┬──────────┬───────────┐
// │ (index) │ name │ time │ duration │ sincePrev │
// ├─────────┼─────────────┼───────────────┼──────────┼───────────┤
@kevinkace
kevinkace / someValue.js
Last active November 1, 2019 21:28
like [].find(), but return a value of your choosing
function findValue(collection, predicate) {
let value;
collection.some(c => {
const p = predicate(c)
if (p) {
value = p;
return true;
@kevinkace
kevinkace / object-reduce.js
Created October 24, 2019 04:32
Reduce an object
function objectReduce(obj, cb, acc) {
let idx = 0;
for (let key in obj) {
acc = cb(acc, { key, value : obj[key] }, idx++);
}
return acc;
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{
// prefix used to trigger the snippet
// body is the snippet
// $1, $2 for tab stops, $0 for the final cursor position
// ${1:label}, ${2:another} for placeholders
"Mithril Component": {
"prefix": "mesm",
"body": [
"import state from \"../state\";",
"",
@kevinkace
kevinkace / CodePen.css
Created August 2, 2018 16:20
Minimal CodePen Chrome
.main-header {
height: 29px;
min-height: 29px;
}
.main-header .button {
font-size: 0.7rem;
border: none;
padding: 0.2em;
}
@kevinkace
kevinkace / playback-speed.js
Last active July 24, 2018 21:52
tamper monkey script for youtube/netflix playback speed (to blast through movies @130%), numpad 1/3 to lower/increase speed by 10%
// ==UserScript==
// @name Netflix playback speed
// @namespace http://tampermonkey.net/
// @version 0.1
// @description numpad 1, 2, 3 for --0.1, 0, ++0.1
// @author Kevin Cameron
// @include https://www.netflix.com/*
// @grant none
// ==/UserScript==
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Attrs

  • Write a function to process an array of objects, running a function on each object based on it's attributes.
  • Each object can have up to 3 attributes, a, b, c
  • Each attribute can have a value of 0-2
  • The function called on each object is based on truthy attributes, eg:
    • obj = { a : 2, b : 1 } would run ab() (or ba(), name doesn't matter)
    • obj = { c : 1 } would run c()
  • The processing fns (a(), b(), etc) are provided.
  • Bracket Pair Colorizer 2
  • CSS Modules
  • ESLint
  • HTML Snippets
  • Material Icon Theme
  • Path Intellisense
  • Rainbox CSV
  • indent rainbow
  • REST Client
  • stylfmt?