Skip to content

Instantly share code, notes, and snippets.

View sstelfox's full-sized avatar

Sam Stelfox sstelfox

View GitHub Profile
@sstelfox
sstelfox / varietal_nodes_traits_playground.rs
Created July 28, 2019 21:31
Playing around and attempting to figure out somethings around lifetimes, and recursive objects using traits.
trait Node: std::fmt::Debug {
fn value(&self) -> usize;
fn visit(&self) -> Result<usize, &str>;
}
#[derive(Debug)]
struct FixedNode;
impl Node for FixedNode {
fn value(&self) -> usize { 100 }
@sstelfox
sstelfox / monthly-renewal.sh
Last active October 18, 2021 21:46
Bare bones example of nginx & acme-tiny with auto-renewal
#!/bin/bash
# Should be set to run monthly as a cron job
# If the renewal fails abort immediately
set -o errexit
LOG_FILE="/var/log/acme.log"
# Perform the actual renewal, logging the output and saving the certificate
# The following is broken, it doesn't consider module documentation in other
# files (mostly a problem for namespace modules), it doesn't properly respect
# :nodoc: as claimed in the documentation and it doesn't consider a module a
# namespace module if if contains a constant definition.
Style/Documentation:
Enabled: false
require:
- rubocop-rspec
upnp2 {
acl {
rule 10 {
action deny
local-port 0-1024
subnet 0.0.0.0/0
}
rule 20 {
action deny
external-port 0-1024,1080,5432,8000,8080,8081,8088,8443,8888,9100,9200
@sstelfox
sstelfox / panic_trace_01.txt
Created January 8, 2018 19:28
Kubelet Stack Traces
unexpected fault address 0xc420dac140
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x2 addr=0xc420dac140 pc=0xc420dac140]
goroutine 211 [running]:
runtime.throw(0x38a42e3, 0x5)
/usr/lib64/go/src/runtime/panic.go:605 +0x95 fp=0xc420aa6c98 sp=0xc420aa6c78 pc=0x42ea55
runtime.sigpanic()
/usr/lib64/go/src/runtime/signal_unix.go:374 +0x227 fp=0xc420aa6ce8 sp=0xc420aa6c98 pc=0x445947
created by k8s.io/kubernetes/pkg/kubelet/volumemanager.(*volumeManager).Run
@sstelfox
sstelfox / ethereum_err1.log
Last active November 27, 2017 15:12
Dump of the entire log from a segaulted geth instance.
INFO [11-26|19:03:38] Starting peer-to-peer node instance=Geth/v1.7.3-stable-4bb3c89d/linux-amd64/go1.7.3
INFO [11-26|19:03:38] Allocated cache and file handles database=/root/.ethereum/geth/chaindata cache=2048 handles=1024
INFO [11-26|19:03:41] Initialised chain configuration config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Engine: ethash}"
INFO [11-26|19:03:41] Disk storage enabled for ethash caches dir=/root/.ethereum/geth/ethash count=3
INFO [11-26|19:03:41] Disk storage enabled for ethash DAGs dir=/root/.ethash count=2
INFO [11-26|19:03:41] Initialising Ethereum protocol versions="[63 62]" network=1
INFO [11-26|19:03:41] Loaded most recent local header number=4615166 hash=9b0e97…d2ebdf td=1553373258111240174199
INFO [11-26|19:03:41] Loaded most recent local full block number=4615166 hash=9b0e97…d2ebdf td=1553373258111240174199
INFO [11-26|19:03
✓ ~/ $ echo -ne '\x7f\x45\x4c\x46\x02\x01\x01\x03\x00' > test
✓ ~/ $ chmod +x test
✓ ~/ $ ./test
-bash: ./test: cannot execute binary file: Exec format error
@sstelfox
sstelfox / tls_proxy_enabled_server.rb
Last active July 7, 2017 21:31
Ruby TLS Sample Echo Server w/ Proxy Protocol v1 Support
#!/usr/bin/env ruby
require 'openssl'
require 'socket'
require 'timeout'
Thread.abort_on_exception = true
SERVER_KEY = OpenSSL::PKey::RSA.new(2048)
@sstelfox
sstelfox / example.tld.zone
Created May 16, 2017 18:13
Sample CAA Records
$TTL 14400
@ IN SOA nsd01.prd.btv.example.tld. hostmaster.example.tld. (
2017051601 ; Serial number YYYYMMDDNN
2d ; Refresh
2h ; Retry
30d ; Expire
5m ; Min TTL
)
$ORIGIN example.tld. ; Default zone domain
@sstelfox
sstelfox / quick_stats.rb
Last active May 24, 2017 17:41
Quick unoptimized model to perform certain stat operations
module Statistics
def self.sum(data)
data.inject(0.0) { |s, val| s + val }
end
def self.mean(data)
sum(data) / data.size
end
def self.median(data)