Skip to content

Instantly share code, notes, and snippets.

View pdxjohnny's full-sized avatar
🐢
Rolling Alice...

John Andersen pdxjohnny

🐢
Rolling Alice...
View GitHub Profile
@cee-dub
cee-dub / sse.go
Created May 30, 2014 21:08
Simple Golang SSE example using CloseNotifier
package main
import (
"fmt"
"log"
"net/http"
"time"
)
// SSE writes Server-Sent Events to an HTTP client.
@dnoliver
dnoliver / disk-encryption.sh
Created January 13, 2020 22:01
Disk encryption with Clevis example
GNU nano 4.3 disk-encryption.sh
#!/bin/bash
set -euxo pipefail
rpm -qa clevis* cryptsetup* luks* tpm2* e*fspr* | sort
# Creation
# dd if=/dev/zero of=/dev/sda1 bs=1M status=progress
@lawliet89
lawliet89 / gist:5899943
Created July 1, 2013 10:55
Git grep for trailing whitespace
git grep -I -E '^.+[ ]+$'
@dbrgn
dbrgn / scan.sh
Last active October 9, 2021 15:20
Determine whether subdirectories containing git repos are dirty or diverged
#!/bin/bash
function git_is_dirty {
[[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]] && echo "yes"
}
function git_is_diverged {
LOCAL=$(git rev-parse --abbrev-ref HEAD 2> /dev/null || echo "none")
REMOTE=$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2> /dev/null || echo "none")
if [[ "$LOCAL" == "none" ]]; then # No commits yet
@cwacek
cwacek / cobbler-uefi-pxe-rhel.md
Last active January 17, 2022 21:26
A description of how to make Cobbler, PXE, and UEFI behave for Red Hat Enterprise Linux 6 installations

UEFI PXE Installation of RHEL6.4

For some reason, starting a PXE boot installation of RHEL6.4 on UEFI systems is poorly documented. Simultaneously, the process is not terribly verbose when it fails. Here's what I had to do to get this to work.

We going to use Cobbler to take care of a lot of the gruntwork (TFTP, DHCP, etc). It's entirely possible to do it without Cobbler, but even accounting for its warts it will make you more

@ryancdotorg
ryancdotorg / dnaas.c
Created October 30, 2013 23:20
Wrapper library to use /dev/null as a service on Linux via LD_PRELOAD
/* This is a wrapper library that will give your server the power of
* /dev/null as a service, as seen at http://devnull-as-a-service.com/
*
* Compile:
* gcc -ggdb -shared -fPIC dnaas.c -ldl -lcurl -o libdnaas.so
*
* Try:
* LD_PRELOAD=./libdnaas.so dd if=/dev/sda of=/dev/null bs=8192 count=16
*
* Install:
@0xdade
0xdade / selfdestruct.py
Created January 23, 2020 04:26
Simple code snippet for a python file to delete itself, whether it's a standalone .py file or compiled into an executable using pyinstaller
#!/usr/bin/env python3
'''
Determine if this python is part of an executable or a standalone script and then delete the file accordingly.
If the script has been bundled into an executable using pyinstaller (such as pyinstaller --onefile <fname>.py) then the realpath of __file__ will be incorrect, thus the use of sys.executable.
Example of just relying on __file__:
$ pyinstaller --onefile test.py
[...]
$ ls dist/
@usrbinkat
usrbinkat / 00-wolfi-static.md
Last active October 14, 2022 00:43
Chainguard Wolfi go-containerregistry

Hacking on UOR Framework based ai-model-registry

Build Container

cat <<EOF > Dockerfile && docker build -t registry .
FROM --platform=x86_64 cgr.dev/chainguard/go:latest-glibc as build
RUN CGO_ENABLED=0 GOBIN=/home/nonroot go install github.com/google/go-containerregistry/cmd/registry@latest

FROM --platform=x86_64 cgr.dev/chainguard/static:latest
@hwayne
hwayne / Filters.tla
Created October 28, 2022 17:13
Email Filters
---- MODULE Filters ----
EXTENDS TLC, Integers
VARIABLE push_msgs, emails, i, filtered, pushed
vars == <<push_msgs, emails, i, filtered, pushed>>
set ++ x == set \union {x}
set -- x == set \ {x}
TypeInv ==
/\ emails \subseteq (1..3)
{
"method": "ProtocolsConfigure",
"protocol": "https://decentralized-music.org/protocol",
"protocolVersion": "1.0.0",
"protocolDefinition": {
"labels": {
"playlist": {
"schema": "https://decentralized-music.org/protocol/playlist",
"dataFormat": [
"application/json"