Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View bcherny's full-sized avatar

Boris Cherny bcherny

View GitHub Profile
@bcherny
bcherny / designing-data-intensive-application-notes.md
Last active April 18, 2024 06:00
Notes: Designing Data-Intensive Applications

Notes on Martin Kleppmann's excellent Designing Data-Intensive Applications.

Chapter 1: Reliable, Scalable, and Maintainable Applications

  • Data Systems
    • Dimensions to consider when thinking about data systems: access patterns, performance characteristics, implementations.
    • Modern data systems often blur the lines between databases, caches, streams, etc.
  • Reliability
    • Systems should perform the expected function at a given level of performance, and be tolerant to faults and user mistakes
  • Fault: One component of a system deviating from its spec. Prefer tolerating faults over preventing them (except for things like security issues). Faults stem from hardware failures, software failures, and human error (in a study, config errors caused most outages).
@bcherny
bcherny / react-rollup-typescript.md
Last active January 30, 2024 12:13
react + rollup + typescript boilerplate

terminal:

npm i --save-dev rollup rollup-watch rollup-plugin-typescript typescript typings
npm i -S react react-dom
./node_modules/.bin/typings install react react-dom --save
mkdir src dist
touch src/index.tsx
@bcherny
bcherny / options-in-typescript.ts
Last active February 25, 2023 23:57
Options in TypeScript
type None = {
flatMap<U>(f: (value: null) => Option<U>): None
getOrElse<U>(def: U): U
isEmpty(): true
map<U>(f: (value: null) => U): None
nonEmpty(): false
orElse<U>(alternative: Option<U>): Option<U>
}
type Some<T> = {
@bcherny
bcherny / Option.ts
Last active February 18, 2023 10:20
Options in TypeScript!
// @see http://www.scala-lang.org/api/2.7.4/scala/Option.html
class Opt<A> {
value: A | null
// TODO: use constructor fn instead
static from<A>(value: A | null): Opt<A> {
return value == null ? None : Some(value)
}
@bcherny
bcherny / using-typescript-and-angular-1.x-in-the-real-world.md
Last active October 9, 2022 12:55
Using Typescript + Angular 1.x in the Real World

Work in progress!

A little while ago I started using Typescript with the Angular 1.5 app I'm working on, to help ease the migration path to Angular 2. Here's how I did it. We'll go example by example through migrating real world code living in a large, mostly non-Typescript codebase.

Let's start with a few of the basic angular building blocks, then we'll go through some of the higher level patterns we derived.

Filters

Javascript

@bcherny
bcherny / typescript-effect-system.ts
Last active July 19, 2021 17:07
designing an effect system in typescript
type Effect<A> = {type: A}
interface IO<A> {}
interface NetworkIO<A> extends IO<A> {}
interface DOMMutation<A> {}
interface DOMAppend<A> extends DOMMutation<A> {}
interface DOMRemove<A> extends DOMMutation<A> {}
function request<A>(url: string): Promise<A> & Effect<NetworkIO<A>> {
@bcherny
bcherny / gist:de24955c15430efd99f1
Last active April 30, 2021 12:09
How to squash commits with git

Let's say you have a Pull Request from myBranch to master with 3 commits, and you want them to appear as a single commit in master.

If you're merging on the command line, this is trivial:

git checkout master
git merge --squash myBranch
git commit

graph mutation language (graphml)

             connection
          /              \
         
  Node 1 -----------------> Node 2
         \    edge 1
          \_________________> Node 3
 \ edge 2