- 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 runab()
(orba()
, name doesn't matter)obj = { c : 1 }
would runc()
- The processing fns (
a()
,b()
, etc) are provided.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// usage: | |
// const timer = new Timer("timerName"); | |
// doThing(); | |
// timer.measure("didThing"); | |
// await doThing2(); | |
// timer.measure("didThing2"); | |
// timer.report(); | |
// ┌─────────┬─────────────┬───────────────┬──────────┬───────────┐ | |
// │ (index) │ name │ time │ duration │ sincePrev │ | |
// ├─────────┼─────────────┼───────────────┼──────────┼───────────┤ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function findValue(collection, predicate) { | |
let value; | |
collection.some(c => { | |
const p = predicate(c) | |
if (p) { | |
value = p; | |
return true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function objectReduce(obj, cb, acc) { | |
let idx = 0; | |
for (let key in obj) { | |
acc = cb(acc, { key, value : obj[key] }, idx++); | |
} | |
return acc; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// 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\";", | |
"", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.main-header { | |
height: 29px; | |
min-height: 29px; | |
} | |
.main-header .button { | |
font-size: 0.7rem; | |
border: none; | |
padding: 0.2em; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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== |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
- Bracket Pair Colorizer 2
- CSS Modules
- ESLint
- HTML Snippets
- Material Icon Theme
- Path Intellisense
- Rainbox CSV
- indent rainbow
- REST Client
- stylfmt?
NewerOlder