Skip to content

Instantly share code, notes, and snippets.

View shinzui's full-sized avatar
👨‍💻

Nadeem Bitar shinzui

👨‍💻
  • Los Angeles / San Francisco
  • X @shinzui
View GitHub Profile
@shinzui
shinzui / README.md
Created March 21, 2024 04:43 — forked from benkuhn/README.md
Migration tool README

$NAME is a language-agnostic tool for managing your Postgres schema, designed to make downtime-free schema changes as easy as possible to develop and run.

High-level overview

$NAME improves database migration ergonomics in five major ways:

  1. It stores previous versions of your schema in source control and auto-generates scaffolding for new migrations by "diffing" them with the current schema. This ensures that your production schema never drifts out of sync from the schema defined by your application.

  2. It automates many recipes for doing tricky migrations like column renames "online," without requiring downtime or a synchronized application deploy. Naive methods of renaming a column require multiple application deploys and costly table rebuilds. $NAME's recipe doesn't require either.

@shinzui
shinzui / programming-as-theory-building.md
Created February 4, 2023 15:21 — forked from onlurking/programming-as-theory-building.md
Programming as Theory Building - Peter Naur

Programming as Theory Building

Peter Naur

Peter Naur's classic 1985 essay "Programming as Theory Building" argues that a program is not its source code. A program is a shared mental construct (he uses the word theory) that lives in the minds of the people who work on it. If you lose the people, you lose the program. The code is merely a written representation of the program, and it's lossy, so you can't reconstruct

@shinzui
shinzui / README
Created July 7, 2022 04:56 — forked from jmatsushita/README
Setup nix, nix-darwin and home-manager from scratch on an M1 Macbook Pro
# I found some good resources but they seem to do a bit too much (maybe from a time when there were more bugs).
# So here's a minimal Gist which worked for me as an install on a new M1 Pro.
# Inspired by https://github.com/malob/nixpkgs I highly recommend looking at malob's repo for a more thorough configuration
#
# Let's get started
#
# Let's install nix (at the time of writing this is version 2.5.1
curl -L https://nixos.org/nix/install | sh
# I might not have needed to, but I rebooted
@shinzui
shinzui / default.nix
Created February 16, 2022 13:14 — forked from Gabriella439/default.nix
neovim + haskell-language-server setup
# nix-env --install --file ./default.nix
let
nixpkgs = builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/c473cc8714710179df205b153f4e9fa007107ff9.tar.gz";
sha256 = "0q7rnlp1djxc9ikj89c0ifzihl4wfvri3q1bvi75d2wrz844b4lq";
};
config = {
allowUnfree = true;
};
@shinzui
shinzui / haskell-records.md
Created April 8, 2021 05:17 — forked from mtesseract/haskell-records.md
Working around Haskell's namespace problem for records

The Problem

Defining records in Haskell causes accessor functions for the record's fields to be defined. There is no seperate namespace for these accessor functions.

The Goal

Be able to

  • use records in Haskell, which share field names.
  • use lenses for accessing these fields
@shinzui
shinzui / Optics Cheatsheet.md
Created December 28, 2020 23:02 — forked from ChrisPenner/Optics Cheatsheet.md
Optics Cheatsheet
@shinzui
shinzui / Pubsub.hs
Created December 4, 2020 19:03 — forked from jamesthompson/Pubsub.hs
Example pub/sub grpc interface with fused-effects
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE KindSignatures #-}
@shinzui
shinzui / Environment.hs
Created May 25, 2020 16:25 — forked from clementd-fretlink/Environment.hs
Env var parsing with free applicatives
#!/usr/bin/env stack
-- stack --resolver lts-14.20 --install-ghc runghc --package either --package free
{-# LANGUAGE DeriveFunctor #-}
module Main
where
import Control.Applicative.Free
import Data.Bifunctor (first)
import Data.Either.Combinators (maybeToRight)
import Data.Either.Validation

Modern applications

Most JavaScript developers love making modern applications, with our new language features and latest libraries making our life easier, but has any one ever actually wondered if this ever impacts our users.

We are dealing with abstractions, abstractions are trying to cover a general use case which could not be conforming to yours. Some are over-engineered in ways one can't possibly comprehend, use cases that will never be reached by middle sized applications. Some of these over

@shinzui
shinzui / exchange-formats.md
Created August 12, 2019 03:43 — forked from gelisam/exchange-formats.md
A list of every data exchange formats I could find

At work, I just spent the last few weeks exploring and evaluating every format I could find, and my number one criteria was whether they supported sum types. I was especially interested in schema languages in which I could describe my types and then some standard specifies how to encode them using an on-the-wire format, usually JSON.

  1. Swagger represents sum types like Scala does, using subtyping. So you have a parent type EitherIntString with two subtypes Left and Right represented as {"discriminator": "Left", value: 42} and {"discriminator": "Right", value": "foo"}. Unfortunately, unlike in Scala in which the parent type is abstract and cannot be instantiated, in Swagger it looks like the parent type is concrete, so when you specify that your input is an EitherIntString, you might receive {"discriminator": "EitherIntString"} instead of one of its two subtypes.
  2. JSON-schema supports unions, which isn't quite the same thing as sum types because