Skip to content

Instantly share code, notes, and snippets.

View bscott's full-sized avatar
🏠
Working from home

Brian Scott bscott

🏠
Working from home
View GitHub Profile
@bscott
bscott / ts-unauth-node-cleanup.py
Created December 19, 2023 17:24
Tailscale unauthorized device cleanup
import requests
# Get API token from environment variable
api_token = os.getenv('TAILSCALE_API_TOKEN')
tailnet_name = os.getenv('TAILSCALE_TAILNET_NAME')
# see if we have an API token
if api_token is None:
print("Please set TAILSCALE_API_TOKEN environment variable")
exit(1)
@bscott
bscott / contact.md
Created December 10, 2021 05:28
Secure Contact

How to contact me in a relatively secure manner

Here are some moderately secure methods for contacting me.

Easiest methods

Keybase

I'm brianscott on Keybase

A bit more esoteric

@bscott
bscott / functions.go
Last active November 16, 2021 02:10
Go Functions
func getEnvBool(key string) bool {
val := os.Getenv(key)
if val == "" {
return false
}
v, err := strconv.ParseBool(val)
if err != nil {
return false
}
@bscott
bscott / Dockerfile
Created January 28, 2021 05:28
Go Dockerfile
FROM golang:1.15-alpine AS build
RUN apk add --no-cache git
WORKDIR /go/src/project
COPY . /go/src/project
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /bin/index <PROJECT PATH>
FROM scratch
COPY --from=build /bin/index /bin/index
@bscott
bscott / devshell.nix
Last active December 4, 2021 08:12
Nix Dev Shell Setup
{ pkgs ? import <nixpkgs> {} # here we import the nixpkgs package set
}:
pkgs.mkShell { # mkShell is a helper function
name="dev-environment"; # that requires a name
buildInputs = [ # and a list of packages
pkgs.nodejs
pkgs.python3
pkgs.go
pkgs.rustc
pkgs.wget
sudo du -a /dir/ | sort -n -r | head -n 20
@bscott
bscott / go-install.sh
Created February 24, 2018 21:34
go install
#!/bin/bash
set -e
GVERSION="1.7"
GFILE="go$GVERSION.linux-amd64.tar.gz"
GOPATH="$HOME/go"
GOROOT="/usr/local/go"
if [ -d $GOROOT ]; then
echo "Installation directory already exists $GOROOT"
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "exec",
"remotePath": "",
@bscott
bscott / launch-pre.json
Last active July 18, 2017 02:10
prevscode-config
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"remotePath": "",
@bscott
bscott / funcs.go
Created July 11, 2017 03:26
errorf
func errorf(format string, args ...interface{}) {
fmt.Fprintf(os.Stderr, format, args...)
}