Skip to content

Instantly share code, notes, and snippets.

View bcherny's full-sized avatar

Boris Cherny bcherny

View GitHub Profile
<div onmouseover="hoverslick()" onmouseout="nonhoverslick()">
<p class="Noanimation">I can</p>
<p class="Noanimation">also do</p>
<p class="Noanimation">slick animations</p>
<script>
function hoverslick() {
document
.querySelectorAll(".Noanimation")
.forEach(function(animationtxt) {
animationtxt.classList.add("Animation");
let storeA = createStore({ a: 1 })
let storeB = createStore({ b: 2 })
let withStoreA = connect(storeA)
let withStoreB = connect(storeB)
type StateA = {
a: number
}
type StateB = {
b: number
// hyperscript and React-inspired DSL
// "react in 50 lines"
void function() {
/////////// tags
type Tagish = string | Tag
type Attrs = {
void function() {
class ChessError extends Error { }
class InvalidMoveError extends ChessError { }
class NoLineOfSightError extends ChessError { }
class NotYourTurnError extends ChessError { }
// Represents a chess game
class Game {
private board = new Board
@bcherny
bcherny / generative-snapshot-testing.md
Created February 2, 2018 07:26
Idea: generative snapshot testing

Problem

Code changes that cause program behavior to change can be dangerous if the behavior change was unintentional. Unit tests help mitigate this, but in practice a lot of code is not covered by unit tests.

Solution

Property based snapshot testing.

For example, say our program is a single function:

@bcherny
bcherny / hackle.md
Last active January 31, 2018 05:41

hackle

1. Parsing Hack ASTs

Top level functions

function a()
@bcherny
bcherny / seq.php
Last active January 10, 2018 23:05
<?hh
async function seq(vec<(function(): Awaitable<T>)> $as): Awaitable<vec<T>> {
$result = vec[];
foreach ($as as $a) {
$r = await $a();
$result[] = $r;
}
return $result;
}
@bcherny
bcherny / hack-lang-spec-notes.md
Last active January 16, 2018 06:34
Hack Lang Spec Notes

Some notes while reading through the Hack Lang spec.

4. Basic Concepts

VSlot -> VStore -> value: scalar | null
                \_ type tag: Null, Bool, Int, Float, Str, Arr, Arr-D, Obj, or Res

  eg. `$a = true;`
// Type definitions for babel-types 7.0
// Project: https://github.com/babel/babel/tree/master/packages/babel-types
// Definitions by: Troy Gerwien <https://github.com/yortus>
// Sam Baxter <https://github.com/baxtersa>
// Marvin Hagemeister <https://github.com/marvinhagemeister>
// Boris Cherny <https://github.com/bcherny>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
export interface Comment {
// Shadows built-in $Keys
type $Keys<A> = number
type A<B> = $Keys<B>