Skip to content

Instantly share code, notes, and snippets.

👨‍💻
Loves programming languages

Steven Shaw steshaw

👨‍💻
Loves programming languages
View GitHub Profile
View tailscale-gcp.sh
#! /bin/bash
# custom startup script for GCP (in metadata)
tailscale up --advertise-routes=10.0.0.0/8,172.16.0.0/24
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
echo 0 | sudo tee /proc/sys/net/ipv4/conf/tailscale0/rp_filter
iptables -t nat -A POSTROUTING -j MASQUERADE
EOF
@steshaw
steshaw / .00readme.org
Created May 22, 2020 — forked from mbbx6spp/.00readme.org
A caching and persistent Nix shell with direnv
View .00readme.org

Cached and Persistent Nix shell with direnv integration

Problem being solved

  • the default direnv Nix integration from projects loads a Nix shell every new terminal or every time shell.nix and/or default.nix changes. On larger projects with a lot of Nix shell dependencies, that can cause the terminal to take more than 6 seconds to load, which significantly degrades the developer experience (DX).
  • when a developer garbage collects in their Nix store, often the Nix shell dependencies are deleted also which causes a slow start the next time the project’s Nix shell is requested, also degrading developer experience (DX).

Solution outline

  • on first Nix shell load, the Nix shell is evaluated fully such that direnv dumps the environment from the spawn Nix shell process
View Partition.hs
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE LambdaCase #-}
{-# OPTIONS_GHC -Wall #-}
import Data.Either
data Decl a
= TypeSig String a
| Law String a a
| FunModel String a
View Partition.hs
data Decl a
= TypeSig String a
| Law String a a
| FunModel String a
| TypeModel String a
| Import a
| Other a
deriving (Show)
decls =
View Partition.hs
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE DerivingStrategies #-}
import Data.Either
data Decl a
= TypeSig String a
| Law String a a
| FunModel String a
| TypeModel String a
View HtmlToPlain.hs
module HtmlToPlain where
import Prelude
import Text.Pandoc
import Text.Pandoc.Walk
import Data.Text
import qualified Data.Text.IO as T
htmlToPlain :: FilePath -> IO ()
View Doc.hs
module Docs where
import Prelude
import Text.Pandoc
import Text.Pandoc.Walk
import qualified Data.Text.IO as T
go = do
t <- T.readFile "../.local/j.html";
View Strong.hs
module Strong where
import Prelude
import Text.Pandoc
import Text.Pandoc.Walk
stripStrong :: Inline -> Inline
stripStrong (Strong blocks) = Span def $ walk stripStrong blocks
stripStrong x = x
View exa-wrapper
#!/usr/bin/env bash
set -euo pipefail
exa_opts=""
while getopts 'ahlrtAF' o; do
case $o in
a) exa_opts="${exa_opts} -a -a" ;;
A) exa_opts="${exa_opts} -a" ;;
h) ;;
View casks-installed.txt
amethyst
android-platform-tools
brave-browser
caffeine
docker
dropbox
firefox
flux
font-firacode-nerd-font
font-sourcecodepro-nerd-font
You can’t perform that action at this time.