const byProcedure = <T>(arrays: T[][], update: { i: number; j: number; value: T }) => {
const retArr: T[][] = [];
for (const i in arrays) {
retArr.push([]);
for (const j in arrays[i]) {
if (Number(i) === update.i && Number(j) === update.j) {
This file contains 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
import React from 'react'; | |
function HexagonSvg({ attrs = {}, position: [x0, y0], length }) { | |
const p1 = [-1 / 3, 0]; | |
const p2 = [-1 / 6, -1 / 3]; | |
const p3 = [1 / 6, -1 / 3]; | |
const p4 = [1 / 3, 0]; | |
const p5 = [1 / 6, 1 / 3]; | |
const p6 = [-1 / 6, 1 / 3]; | |
const M = ([x, y]) => `M ${x0 + length * x} ${y0 + length * y}`; |
This file contains 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
module.exports = { | |
'*.js': absolutePaths => { | |
return `jest ${absolutePaths.map(filename => filename.slice(0, -3) + '.test.js').join(' ')}` | |
} | |
} |
This file contains 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
import fs from "fs"; | |
import { uniq } from "lodash"; | |
import { parse } from "@babel/parser"; | |
import traverse from "@babel/traverse"; | |
const getRelevantFiles = (filename, relevantFiles = []) => { | |
if (relevantFiles.includes(filename)) return relevantFiles; | |
const ast = parse(fs.readFileSync(filename, "utf-8")); | |
traverse(ast, { | |
ImportDeclarations(path) { |
This file contains 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
{ | |
"scripts": { | |
"test": "jest" | |
}, | |
"lint-staged": { | |
"*.js": [ | |
"prettier --write", | |
"git add" | |
] | |
}, |
This file contains 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
class WorkRunner { | |
constructor(fork, { actionCreator, messageCreator }) { | |
this.fork = fork; | |
this.actionCreator = actionCreator; | |
this.messageCreator = messageCreator; | |
this.fork.on("message", this.actionCreator); | |
} | |
send(msg) { |
This file contains 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
import { isArray, isString, isFunction } from "lodash"; | |
const { performance } = require("perf_hooks"); | |
type Parameters<Fn> = Fn extends (...args: infer T) => any ? T : never; | |
const trampoline = <Fn extends (...args: any[]) => any>( | |
fn: Fn, | |
...args: Parameters<Fn> | |
) => { |
This file contains 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
public class RoachPopulation { | |
private static double initialPopulation; | |
RoachPopulation(double initialPopulation) { | |
this.initialPopulation = initialPopulation; | |
} | |
public void waitForIt() { | |
initialPopulation *= 2.0; | |
} |
JavaScript doesn't want to support mutual recursion within our testing environment. So, the below function fails while running our test suite.
const selectPersistedContext = (state: RootState) => {
const advisors = selectAdvisors(state); // selectAdvisors undefined
const context = selectPersistedContext(state); // selectPersistedContext undefined
const { fmid } = context;
if (fmid) {
const advisor = advisors.find(advisor => advisor.fmid === fmid);
This file contains 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
(setq org-capture-templates | |
'(("n" "Task" entry (file+headline "~/life/org/inbox.org" | |
"Inbox") | |
"* TODO %? \n%i - Task created on %U \\\\" :empty-lines 1) | |
("j" "Journal" entry (file+datetree "~/life/org/journal.org") | |
"* %<%H:%M> %?\n" :empty-lines 1))) |