Skip to content

Instantly share code, notes, and snippets.

View ahrjarrett's full-sized avatar
🌳
these days i'm writing a lot of docs

andrew jarrett ahrjarrett

🌳
these days i'm writing a lot of docs
View GitHub Profile
@JacobWeisenburger
JacobWeisenburger / makeSearchParamsObjectSchema.ts
Last active April 19, 2025 19:41
a way to parse URLSearchParams with Zod
import { z } from 'zod'
function safeParseJSON ( string: string ): any {
try { return JSON.parse( string ) }
catch { return string }
}
function searchParamsToValues ( searchParams: URLSearchParams ): Record<string, any> {
return Array.from( searchParams.keys() ).reduce( ( record, key ) => {
const values = searchParams.getAll( key ).map( safeParseJSON )
@baetheus
baetheus / #note.md
Last active December 23, 2022 17:59
Kliesli Arrow Optics

This implementation can now be found in production here

@Widdershin
Widdershin / ssr.md
Last active May 1, 2024 17:36
The absurd complexity of server-side rendering

In the olden days, HTML was prepared by the server, and JavaScript was little more than a garnish, considered by some to have a soapy taste.

After a fashion, it was decided that sometimes our HTML is best rendered by JavaScript, running in a user's browser. While some would decry this new-found intimacy, the age of interactivity had begun.

But all was not right in the world. Somewhere along the way, we had slipped. Our pages went uncrawled by Bing, time to first meaningful paint grew faster than npm, and it became clear: something must be done.

And so it was decided that the applications first forged for the browser would also run on the server. We would render our HTML using the same logic on the server and the browser, and reap the advantages of both worlds. In a confusing series of events a name for this approach was agreed upon: Server-side rendering. What could go wrong?

In dark rooms, in hushed tones, we speak of colours.

@Willmo36
Willmo36 / traversal.ts
Created October 15, 2020 16:02
monocle-ts traversal example
import * as T from "monocle-ts/lib/Traversal";
import * as R from "fp-ts/lib/Record";
import { pipe } from "fp-ts/lib/function";
import { Lens } from "monocle-ts";
type Person = {
age: number;
hairColor: string;
};
" Specify a directory for plugins
call plug#begin('~/.vim/plugged')
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'scrooloose/nerdtree'
"Plug 'tsony-tsonev/nerdtree-git-plugin'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
Plug 'ryanoasis/vim-devicons'
Plug 'airblade/vim-gitgutter'
@effe-megna
effe-megna / TaskRemoteData.ts
Created November 4, 2019 11:57
monad TaskRemoteData
import { Monad2 } from 'fp-ts/lib/Monad'
import * as RD from "@devexperts/remote-data-ts"
import * as T from "fp-ts/lib/Task"
import * as TE from "fp-ts/lib/TaskEither"
import * as E from "fp-ts/lib/Either"
import { pipe, pipeable } from "fp-ts/lib/pipeable"
import { sequenceT } from 'fp-ts/lib/Apply'
declare module 'fp-ts/lib/HKT' {
interface URItoKind2<E, A> {
@gcanti
gcanti / io-ts2form.ts
Created August 25, 2018 13:37
Automatically building a form from a `io-ts` type
import * as t from 'io-ts'
import * as React from 'react'
import { render } from 'react-dom'
type Field = t.StringType | t.NumberType | t.BooleanType
interface Form extends t.InterfaceType<{ [key: string]: Field }> {}
const toReactElement = (f: Form | Field): React.ReactElement<any> => {
// f is a tagged union
switch (f._tag) {
@AndyShiue
AndyShiue / CuTT.md
Last active November 29, 2025 08:26
Cubical type theory for dummies

I think I’ve figured out most parts of the cubical type theory papers; I’m going to take a shot to explain it informally in the format of Q&As. I prefer using syntax or terminologies that fit better rather than the more standard ones.

Q: What is cubical type theory?

A: It’s a type theory giving homotopy type theory its computational meaning.

Q: What is homotopy type theory then?

A: It’s traditional type theory (which refers to Martin-Löf type theory in this Q&A) augmented with higher inductive types and the univalence axiom.

@ibraheem4
ibraheem4 / postgres-brew.md
Last active September 27, 2025 02:49 — forked from sgnl/postgres-brew.md
Installing Postgres via Brew (OSX)

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
@ChrisPenner
ChrisPenner / Battleship.lhs
Last active September 10, 2023 03:12
Hit! You sunk my Adjunction!
Today we'll be looking into Kmett's
[adjunctions](http://hackage.haskell.org/package/adjunctions) library,
particularly the meat of the library in Data.Functor.Adjunction.
This post is a literate haskell file, which means you can load it right up in
ghci and play around with it! Like any good haskell file we need half a dozen
language pragmas and imports before we get started.
> {-# language DeriveFunctor #-}
> {-# language TypeFamilies #-}