Skip to content

Instantly share code, notes, and snippets.

View estimate.md

Software estimation Q&A

Q: What do the points mean?

A: Lets say we have two engineers, E1 and E2, estimating a story S. E1 believes the story can be done in time T1. E2 believes it can be done in time T2.

We assign the velocity numbers V1 and V2 to these two engineers, such that

View sync-async-adapter.js
let Read = {};
let End = {};
function* lexer() {
let accumulatedChars = [];
while (true) {
let inp = yield Read;
if (inp === End) {
if (accumulatedChars.length > 0) yield accumulatedChars.join('');
return;
View simplified.ts
function inRange(a: number, min: number, max: number) {
return min <= a && a <= max;
}
class UTF8Encoder {
bytes = new Uint8Array(4).fill(0)
len = 0;
toBytes(codePoint: number):void {
View techempower.diff
diff --git a/frameworks/JavaScript/express/express-postgres.dockerfile b/frameworks/JavaScript/express/express-postgres.dockerfile
index f2907bd02..9b2196082 100644
--- a/frameworks/JavaScript/express/express-postgres.dockerfile
+++ b/frameworks/JavaScript/express/express-postgres.dockerfile
@@ -1,9 +1,9 @@
FROM node:12.3.1-slim
-COPY ./ ./
-
+COPY package.json ./
View mobx.js
@observer class Chart(props) {
@computed get data() { return getDataWithinRange(this.props.dateRange) }
@computed get dimensions() { return getDimensions() }
@computed get xScale() { return getXScale() }
@computed get yScale() { return getYScale() }
render() {
// use this.xScale, this.yScale etc. component will re-render automatically if any of those update.
return <svg className="Chart" />
}
View gist:96b6232b151d1007a2aa396c2e2c478a

Be careful when feature flags affect any shared mutable state. This for example will cause data loss if the flag value changes during the work:

this.fancyModel = FancyModel.createInitial()
this.rustyModel = RustyModel.createInitial()

async loadData() { 
  let flag = await this.ff.isEnabled('flag');
  let data = await this.fetchData();
View typescript-generics-clarity.ts
type ExtractValuesRecusrively<T> = T extends FormState<infer U>
? { [K in keyof U]: ExtractValuesRecusrively<U[K]> }
: T extends FieldState<infer V>
? V
: never;
// vs
type ExtractValuesRecusrively<State> = State extends FormState<infer InnerForm>
? { [FieldKey in keyof InnerForm]: ExtractValuesRecusrively<InnerForm[FieldKey]> }
View 01-readable.dhall
let types = ../types.dhall sha256:e48e21b807dad217a6c3e631fcaf3e950062310bfb4a8bbcecc330eb7b2f60ed
let defaults = ../defaults.dhall sha256:4450e23dc81975d111650e06c0238862944bf699537af6cbacac9c7e471dfabe
let deployment : types.Deployment = defaults.Deployment // {
metadata = defaults.ObjectMeta // { name = "nginx" },
spec = Some ( defaults.DeploymentSpec // {
replicas = Some 2,
template = defaults.PodTemplateSpec // {
metadata = defaults.ObjectMeta // {
View async-case.ts
type PromiseState<T> = {
state: 'fulfilled', value: T
} | {state: 'pending'} | {state: 'rejected', error: Error};
let wm = new WeakMap<Promise<any>, PromiseState<any>>()
export function asyncCase<T, U>(promise: Promise<T>, handlers: {
pending?: () => U;
fulfilled?: (t: T) => U;
@spion
spion / js-this-via-bind.md
Last active Jun 17, 2019
Understanding JS `this` via bind operator
View js-this-via-bind.md

In JavaScript, functions have arguments. We can name those arguments so that we can access the values we pass to those functions

function add(a, b) {
  return a + b;
}

We can call these functions normally:

You can’t perform that action at this time.