Skip to content

Instantly share code, notes, and snippets.

View bored-engineer's full-sized avatar

Luke Young bored-engineer

View GitHub Profile
@bored-engineer
bored-engineer / Dockerfile
Last active May 4, 2024 17:41
Dockerfile for buliding a simple Golang application with correct caching logic for optimal build performance
# It is faster to cross-compile if the application can be built without CGO
FROM --platform=${BUILDPLATFORM} cgr.dev/chainguard/go:latest as builder
# Building from / or a directory in GOPATH can cause problems
WORKDIR /build
# Fetch the Golang dependencies
RUN --mount=type=cache,target=/go/pkg \
--mount=type=bind,source=go.sum,target=go.sum \
--mount=type=bind,source=go.mod,target=go.mod \
#!/usr/bin/ruby
#
# This tool is only used to "decrypt" the github enterprise source code.
#
# Run in the /data directory of the instance.
require "zlib"
KEY = "This obfuscation is intended to discourage GitHub Enterprise customers "+
"from making modifications to the VM. We know this 'encryption' is easily broken. "
@bored-engineer
bored-engineer / exrex.go
Created May 19, 2020 00:30
A go program to expand a regular expression into every possible matching string
package main
import (
"os"
"fmt"
"strings"
"regexp/syntax"
"unicode/utf8"
)
@bored-engineer
bored-engineer / controlmaster_pid.go
Created March 30, 2020 08:37
Get the PID of a SSH controlmaster process
package main
import (
"bytes"
"encoding/binary"
"io"
"log"
"net"
"os"
"time"
@bored-engineer
bored-engineer / mq.go
Created January 29, 2020 20:01
jq but for MessagePack: go build mq.go -o mq
package main
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"os/exec"
@bored-engineer
bored-engineer / watch.go
Created January 17, 2020 23:42
Watch new process spawns from userspace (without becoming root) via polling /proc (`GOOS=linux GOARCH=amd64 go build watch.go`)
package main
import (
"bufio"
"bytes"
"io/ioutil"
"log"
"os"
"path/filepath"
"strconv"
@bored-engineer
bored-engineer / _main.go
Last active March 31, 2023 15:07
[Golang] PrefixReader (io.WriteCloser) wraps an io.Reader allowing data to be written ("prefixed") to the Reader which will be returned by subsequent Read calls until Close is called at which points all reads will pass-through to the underlying reader.
// THIS IS THE CORRECT SOLUTION, NOT WHAT WAS IN THIS GIST
package main
import (
"strings"
"io"
"io/ioutil"
"fmt"
)
@bored-engineer
bored-engineer / 0_usage.md
Last active February 13, 2019 14:34
A jq script to generate strongly typed golang structures based on results from a GraphQL introspection query

Usage (using get-graphql-schema to fetch the schema):

get-graphql-schema https://hackerone.com/graphql --json | jq -rf graphql.jq

Supports Union types, Enum types, Interfaces, Input Objects and regular Objects.

See bored-engineer/hackeroni-ql for an example library generated with this script.

@bored-engineer
bored-engineer / command.sh
Last active July 23, 2017 12:46
Command to run minio on a WD MyCloud
docker run -d -p 9000:9000 --name $share -v /mnt/HD/HD_a2/$share/:/export -v /mnt/HD/HD_a2/$share/config:/root/.minio minio/minio server /export/data
token=asdf
token="sad"