Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@asktree
asktree / index.js
Last active March 1, 2021 22:03
Confusion-aware explanation of monadic mapping that I am proud of
" Summary: "
`
I recently had an aha! moment. I finally understood what mapping functions are in Functional Programming,
*and* I finally understood why JS had made learning the FP meaning confusing.
`
` this makes it obvious "map" means in Functional Programming`
A.map(add1)(myArray)
` this makes it confusing: `
@asktree
asktree / InformationDestruction.ts
Last active February 5, 2021 17:55
TypeScript's type assignment feature destroys information (inconsistently)
// Typescript lets you put constraints on assignment -- cool
// - I don't know what this feature is officially called and can't find it.
// for example, telling the IDE that a constant should be "even"
type even = 2 | 4 | 6;
const a = 2;
const b: even = 2;
const c: even = 4;
const d: even = 3; // error: constraint violation
// you can assert types, this is different!
@asktree
asktree / example.ts
Last active December 9, 2020 21:49
async await
export const caller = async (
event: CallerEvent,
context: ServerlessContext,
callback
) => {
// START ur code
logger.info({ event, context });
const { collection, time } = event;
const args = {
collection,
import React from "react"
import LinearProgress from "@material-ui/core/LinearProgress"
import throttle from "lodash.throttle"
import ScrollManager from "./ScrollManager"
import { Id, Result } from "../../modules/Stores/Search/searchInterfaces"
import Masonry from "./Masonry"
import { Typography } from "@material-ui/core"
interface Props {
@asktree
asktree / README.md
Created June 29, 2018 19:55 — forked from sbrudz/README.md
Time Series Stacked Histogram

This chart shows a histogram of reported rat sightings in NYC between January 2010 and September 2014 grouped by borough. It's intended as a simple example to show how to create a time-based histogram using the stack layout in D3.js.

Data source: NYC Open Data