- Parts of the code are under-tested
- Parts of the code are "hard to reason about"
- Parts of the code are slow
const state = {
<!doctype html> | |
<html> | |
<head> | |
<meta name="charset" content="utf-8"/> | |
<title></title> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/> | |
<meta name="author" content="Adam Beres-Deak"/> | |
<meta name="viewport" content="width=device-width"/> | |
<style> | |
body { |
const vehicleToHtml = obj => { | |
return `<div id="${obj.id}">${obj.name}</div>`; | |
}; | |
$.ajax({ | |
url: '/get/all/vehicles', | |
success: vehicles => { | |
const html = vehicles.map(vehicleToHtml); | |
// const html = vehicles.map(v => new Vehicle(v)).map(v => v.toHtml()); | |
document.querySelector('#list').innerHTML = html; |
Functional Programming Jargon in simple terms: | |
https://github.com/hemanth/functional-programming-jargon | |
Professor Frisby's Mostly Adequate Guide to Functional Programming (book): | |
https://drboolean.gitbooks.io/mostly-adequate-guide/content/ | |
A series on FP in JS from Eric Elliott: | |
https://medium.com/javascript-scene/the-rise-and-fall-and-rise-of-functional-programming-composable-software-c2d91b424c8c | |
Some introduction to Monads: |
# https://android.stackexchange.com/a/199496 | |
adb forward tcp:9222 localabstract:chrome_devtools_remote | |
wget -O tabs.json http://localhost:9222/json/list |
import interpolate from './interpolate'; | |
describe('Interpolate for Translations', () => { | |
// eslint-disable-next-line jest/no-commented-out-tests | |
// it('blah', () => { | |
// expect(interpolate('asdf')).toEqual('asdf'); | |
// expect(interpolate('Hello {0}', ['World!'])).toEqual('Hello World!'); | |
// expect(interpolate('Hello {0} {0}', ['World!'])).toEqual('Hello World! World!'); | |
// expect(interpolate('Hello {0} {1} {2}!', ['World!', 'Welcome', 'here'])).toEqual('Hello World! Welcome here!'); | |
// expect(interpolate('Hello {0} {1} {2}! {1} {2}!', ['World!', 'Welcome', 'here'])).toEqual( |
echo 1 | sudo tee /sys/class/backlight/intel_backlight/brightness
// https://leetcode.com/problems/lru-cache/submissions/ | |
class LRUCache { | |
obj: Record<number, { val: number; acc: number }>; | |
capacity: number; | |
size: number; | |
acc: number; | |
cache: Record<number, [val: number, acc: number, key: number]>; | |
c: Map<number, [val: number, acc: number]> |
// createCache.ts | |
export default function createCache(fetchFunction: () => Promise<any>, refreshInterval: number, retryAfter: number) { | |
let fetchPromise: null | ReturnType<typeof fetchFunction> = null; | |
const doThinInInterval = () => { | |
fetchFunction().then((data) => { | |
fetchPromise = Promise.resolve(data); | |
}) | |
.catch(() => setTimeout(doThinInInterval, retryAfter)); | |