Skip to content

Instantly share code, notes, and snippets.

@edwtjo
edwtjo / nixos-proxy-switch
Created November 3, 2016 16:17
Dynamic NixOS Proxy Switcher
#!/bin/sh
orig=`echo $NIX_PATH | sed -e "s,.*nixos-config=\(.*\)\.nix,\1.nix,"`
export NIX_REMOTE=""
buildAndSwitch() {
sudo -E nix-build \
-A system '<nixpkgs/nixos>' \
--option use-binary-caches false
sudo -E nixos-rebuild switch --option use-binary-caches false
@edwtjo
edwtjo / pandoc-filter-comments
Created October 2, 2016 07:37
A Pandoc Filter for Comments (install nix and chmod to use)
#! /usr/bin/env nix-shell
#! nix-shell -i runghc -p "haskellPackages.ghcWithPackages (p: with p; [pandoc])"
#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/7465bcd67a2177c63adeec66398b1b581260b31e.tar.gz
import Text.Pandoc.JSON
removeComments :: Block -> IO Block
removeComments cb@(CodeBlock (id, classes, namevals) contents) =
if "comment" `elem` classes then
return $ Para []
@edwtjo
edwtjo / pandoc-filter-graphviz
Created October 2, 2016 07:35
A Pandoc Filter for Graphviz in Haskell (install nix and chmod to use)
#! /usr/bin/env nix-shell
#! nix-shell -i runghc -p "haskellPackages.ghcWithPackages (p: with p; [bytestring pandoc text base16-bytestring])"
#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/7465bcd67a2177c63adeec66398b1b581260b31e.tar.gz
{-# LANGUAGE OverloadedStrings #-}
import Crypto.Hash
import Control.Monad (unless)
import Data.ByteString (ByteString)
import Data.Byteable (toBytes)
@edwtjo
edwtjo / vcf-namescrub
Last active August 29, 2015 14:13
Cleanup display names (VCF entries)
#!/bin/awk -f
# Purges and regenerates contact book display names
# Delete current contact display name
!/^N:/
# Generate a new contact display name on the form:
# N:LASTNAME_1;FIRSTNAME_1;..;FIRSTANME_n;LASTNAME_2;..;LASTNAME_m;;;
/^FN:.*/{

Keybase proof

I hereby claim:

  • I am edwtjo on github.
  • I am edwtjo (https://keybase.io/edwtjo) on keybase.
  • I have a public key whose fingerprint is 7FD9 0C40 78AD 3CC6 B6E5 C172 50C5 4E31 D592 E068

To claim this, I am signing this object: