Skip to content

Instantly share code, notes, and snippets.

@swdunlop
swdunlop / Dockerfile
Created September 28, 2021 19:22
Rootless Nix Dev Container for Visual Code hackers
# See here for base image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.194.0/containers/alpine/.devcontainer/base.Dockerfile
ARG ALPINE_VERSION="3.14"
FROM mcr.microsoft.com/vscode/devcontainers/base:0-alpine-${ALPINE_VERSION}
USER root
# https://nvd.nist.gov/vuln/detail/CVE-2019-5021
RUN sed -i -e 's/^root::/root:!:/' /etc/shadow
@swdunlop
swdunlop / mustang.toml
Created March 17, 2022 00:05
Port of Mustang theme to the Helix text editor
# Author: Scott W. Dunlop <swdunlop@gmail.com>
# Derived from RayGervais <raygervais@hotmail.ca>
# Original Mustang color theme: https://www.deviantart.com/hcalves/art/Mustang-Vim-Colorscheme-98974484
"ui.background" = { bg = "base00" }
"ui.menu" = "base01"
"ui.menu.selected" = { fg = "base01", bg = "base04" }
"ui.linenr" = { fg = "base03", bg = "base01" }
"ui.popup" = { bg = "base01" }
"ui.window" = { bg = "base01" }
@swdunlop
swdunlop / fuzzex.py
Created December 21, 2010 11:08
Random string generator using regex-like expressions
#!/usr/bin/env python
# Copyright (C) 2010, Scott W. Dunlop <swdunlop at gmail.com>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
@swdunlop
swdunlop / plyml.go
Last active October 21, 2021 00:23
PLYML is a simple utility to convert OSX plists to/from YAML to make them easier to hack on
/* plyml converts Apple plists into YAML, and vice-versa. This is used to make it easier to hack on TextMate and Sublime Text themes. It depends on Apple's "plutil" utility, meaning it is only useful on OSX. */
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"launchpad.net/goyaml"
"os"
"os/exec"
@swdunlop
swdunlop / README.md
Last active May 7, 2021 18:50
A script to fix Visual Code Remoting via SSH to NixOS after the April 2021 update

NixOS does not normally install libraries in a FHS layout, which means that binaries compiled for other Linux platforms typically will not work. Visual Studio Code's Remote SSH extension transfers a NodeJS binary and a binary library built by Microsoft that must be patched to be used on NixOS.

Prior to April 2021, this could simply be done by replacing .vscode-server/bin/*/node with nodejs-12_x; after April 2021, there is also a library module that is not compatible with nodejs-12_x. Therefore, it is necessary to patch these two ELF files.

What happens if you just replace nodejs (the pre-April solution from nixos.wiki)

@swdunlop
swdunlop / identifypanic.go
Created March 18, 2014 20:45
Identify a GOLANG Panic Function and Line in Recovery
// You can edit this code!
// Click here and start typing.
package main
import "fmt"
import "runtime"
import "strings"
func identifyPanic() string {
var name, file string
@swdunlop
swdunlop / Makefile
Created January 8, 2011 05:48
A fuzzer for Go structures that uses reflection to identify and alter fields.
GOROOT ?= /opt/go
include $(GOROOT)/src/Make.inc
TARG=blur
GOFILES=blur.go
include $(GOROOT)/src/Make.pkg
@swdunlop
swdunlop / mp3collect.go
Created January 31, 2011 23:29
a simple utility to hardlink mp3 files to a hash of their non-ID3 contents
package main
import "io"
import "os"
import "fmt"
import "encoding/hex"
import "crypto/sha256"
import "path"
import "strings"
@swdunlop
swdunlop / ply_clike.py
Created November 15, 2010 01:40
Example use of Python and Ply to lexically analyze C files for identifiers.
#!/usr/bin/env python
LICENSE = '''
Copyright (C) 2010, Scott W. Dunlop <swdunlop at gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
@swdunlop
swdunlop / main.go
Created November 28, 2019 05:45
Simple Time Server Using GQLGen
package main
import (
"context"
"net/http"
"strings"
"time"
"github.com/99designs/gqlgen/handler"
)