Skip to content

Instantly share code, notes, and snippets.

func typeCache[T any](compute func(t reflect.Type) T) func(t reflect.Type) T {
cache := map[reflect.Type]T{}
return func(t reflect.Type) T {
if v, ok := cache[t]; ok {
return v
}
v := compute(t) // but compute cant recurse
cache[t] = v
return v
}
@TrooperT
TrooperT / TripleO-quickie.sh
Created December 10, 2020 15:40
TripleO-Quickie
#!/usr/bin/env bash
export WORKDIR=""
export NODESCONFIG="$WORKDIR/oooq_nodes.yaml"
export EXTRACONFIG="$WORKDIR/oooq_extras.yaml"
export VIRTHOST=""
cat > $CONFIG << EOCONF
control_memory: 16384
compute_memory: 16384
undercloud_memory: 18432
@TrooperT
TrooperT / DRAFT-ec-ca-softhsm2_p11-kit.md
Last active February 5, 2021 08:51
EC CA REDUX: NOW WITH P11-KIT AND SOFTHSM2

Create directory structure

mkdir ca
cd ca
mkdir -p {root,intermediate}/{certs,crl,csr,newcerts}
mkdir -p {client,server}/{certs,csr,pfx,private}
touch {root,intermediate}/database
echo 1000 | tee {root,intermediate}/{serial,crlnumber}
chmod 700 {client,server}/private
@TrooperT
TrooperT / waitForKeyElements.js
Created January 30, 2020 15:21 — forked from BrockA/waitForKeyElements.js
A utility function, for Greasemonkey scripts, that detects and handles AJAXed content.
/*--- waitForKeyElements(): A utility function, for Greasemonkey scripts,
that detects and handles AJAXed content.
Usage example:
waitForKeyElements (
"div.comments"
, commentCallbackFunction
);
@TrooperT
TrooperT / New-SerialPort.ps1
Created January 11, 2020 16:16
Pipeable Addition of Serial port to VMware VM
Function New-SerialPort {
Param (
[Parameter(Mandatory=$True,ValueFromPipelinebyPropertyName=$True)]
$Name,
[Parameter(Mandatory=$True,ValueFromPipelinebyPropertyName=$True)]
$Port
)
Process {
$VMDevSpec = New-Object VMware.Vim.VirtualDeviceConfigSpec
$VMDevSpec.Operation = "add"
@TrooperT
TrooperT / _general.conf
Last active October 12, 2018 16:57
NGINX config snippets for reverse proxy-ing multiple HTTPS hosts on single public IP
# /etc/nginx/_general.conf
# security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Content-Security-Policy "default-src * data: 'unsafe-eval' 'unsafe-inline'" always;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
@TrooperT
TrooperT / _ssl.conf
Created September 12, 2018 23:05
NGINX config snippets to forward proxy UNIFI controller
ssl_certificate /etc/letsencrypt/live/unifi.imnotgonnatellyoumydomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/unifi.imnotgonnatellyoumydomain.com/privkey.pem;
@TrooperT
TrooperT / coord.sorted.log
Created May 10, 2014 08:51
cat bfgminer.coord.log | grep Coord | sort -k3 > ~/coord.sorted.log
[2014-05-10 04:27:31] BFY 0aa: nonce: 0ef06585, Coord: (16,19)
[2014-05-10 04:27:46] BFY 0aa: nonce: 153de0be, Coord: (0,28)
[2014-05-10 04:27:45] BFY 0aa: nonce: 26c92483, Coord: (1,9)
[2014-05-10 04:27:36] BFY 0aa: nonce: 34a0d5dc, Coord: (9,27)
[2014-05-10 04:27:34] BFY 0aa: nonce: 45f51673, Coord: (18,7)
[2014-05-10 04:27:35] BFY 0aa: nonce: 45f51673, Coord: (18,7)
[2014-05-10 04:27:50] BFY 0aa: nonce: 67b0ef0a, Coord: (3,10)
[2014-05-10 04:27:45] BFY 0aa: nonce: 6867d532, Coord: (3,11)
[2014-05-10 04:27:40] BFY 0aa: nonce: 6ac16fdc, Coord: (11,14)
[2014-05-10 04:27:46] BFY 0aa: nonce: 6f75f3e1, Coord: (11,20)
@TrooperT
TrooperT / moar gdb
Last active December 26, 2015 17:59
gdb on mavericks with symbols!!!! i think
[2013-10-27 23:54:41] [thread 0: 3170893824 hashes, 2275075.3 khash/sec]
[New Thread 0x1a0b of process 89057]
[New Thread 0x1b03 of process 89057]
[New Thread 0x1c03 of process 89057]
[New Thread 0x1d03 of process 89057]
[New Thread 0x1e03 of process 89057]
[New Thread 0x1f03 of process 89057]
[New Thread 0x2003 of process 89057]
[New Thread 0x2103 of process 89057]
[New Thread 0x2203 of process 89057]
@TrooperT
TrooperT / LLDB
Created October 28, 2013 03:30
output from: lldb used nwools xgminer-osx and added -g -O0 and compiled with that and flags were NOT stripped (middle finger to homebrew)
Last login: Sun Oct 27 23:05:41 on ttys003
Ragnarok:bin owner$ lldb bfgminer
Current executable set to 'bfgminer' (x86_64).
(lldb) run
Process 44482 launched: '/Users/owner/xgminer-osx/output/bin/bfgminer' (x86_64)
[2013-10-27 23:16:42] Timers: Using gettimeofday
[2013-10-27 23:16:42] Global quota greatest common denominator set to 1
[2013-10-27 23:16:42] setrlimit: Soft fd limit not being changed from 1024 (FD_SETSIZE=1024; hard limit=unlimited)
[2013-10-27 23:16:42] Started bfgminer 3.4.0
[2013-10-27 23:16:42] Loaded configuration file /Users/owner/.bfgminer/bfgminer.conf