Skip to content

Instantly share code, notes, and snippets.

Avatar

Cody Kochmann CodyKochmann

  • Severn, MD
View GitHub Profile
@CodyKochmann
CodyKochmann / Makefile
Last active September 16, 2023 16:35
Makefile for managing a directory of .magnet files for isolated parallel torrenting sessions using aria2c
View Makefile
# Author: Cody Kochmann
# Date Created: 2023-09-16
# Last Modified: 2023-09-16
# License: MIT
#
# This makefile spins up an aria2c process for every .magnet file in the current directory.
#
# It assumes it will be only one magnet link per each .magnet file.
#
# The benefit of this over just having a single aria2c call pull multiple magnet links from
@CodyKochmann
CodyKochmann / demo-sqlite-over-ssh-user.sh
Created March 6, 2023 13:41
dedicated db user that has a login shell of sqlite for a sqlite over ssh interface
View demo-sqlite-over-ssh-user.sh
➜ ~ ssh kali@10.0.0.8 cat /usr/local/bin/sqlite3-user-db
kali@10.0.0.8's password:
#!/bin/bash
/usr/bin/sqlite3 "$HOME/$USER.db"
➜ ~ ssh db@10.0.0.8
db@10.0.0.8's password:
Linux kali 6.0.0-kali3-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.0.7-1kali1 (2022-11-07) x86_64
@CodyKochmann
CodyKochmann / ocr_remote_image.py
Created February 17, 2023 13:27
python ocr conversion of an image from a url
View ocr_remote_image.py
# by: Cody Kochmann
# this script pulls the contents of $TARGET_IMAGE
# and uses pytesseract against it to output the
# text contents of the image to stdout
import os, sys, functools
import requests
try:
from PIL import Image
except ImportError:
@CodyKochmann
CodyKochmann / cicd-life-advice.md
Created February 5, 2023 17:18
CICD life advice inspired by reddit.
View cicd-life-advice.md

I need scripts to run on github webhooks just as bad as you do. But this one-size-fits-all "lets make scripts but in yaml" shit has got to go.

Yaml acts as the "purely ci details". Script logic goes in... SCRIPTS!

Every CI/CD engine has a million different 'input' layers - environment variables, repo variables, workflows from various branches, maybe the git commit object. Oftentimes your scripts will have the ability to jam more variables into the 'input' layer for later scripts - such as in the case of the github environment variables. UNFORTUNATELY, it's never clear WHICH input layers are available to WHICH parts of the script. "Oh, no, you can't use outputs from this script to as arguments for something in our yaml, because the yaml is calculated first." Well thanks, Mr Nadella, I'll just torch my entire pipeline and start over.

My form of dynamic ci materializes all variables into logged and exam-able ci code. Hidden ci assembly magic was one of the first things I got rid of because life triggered

@CodyKochmann
CodyKochmann / pg_kv_store_functions.sql
Last active April 6, 2022 23:17
postgres function based kv storage for sql algorithms.
View pg_kv_store_functions.sql
-- -------------------------------------------
-- This is an implementation of a key, value
-- store for function based kv storage for
-- different sql based algorithms to utilize
-- in postgres.
-- -------------------------------------------
-- Author: Cody Kochmann
-- license: MIT
-- -------------------------------------------
View gitlab_request_rate_limit.py
from functools import wraps
from threading import Timer, Semaphore
import requests
def service_request_rate_limit(per_minute: int):
assert isinstance(per_minute, int), per_minute
assert per_minute > 0, per_minute
lock = Semaphore(per_minute)
@CodyKochmann
CodyKochmann / .tmux.conf
Created October 12, 2021 15:59
My personal tmux.conf I like to start with when setting up new systems.
View .tmux.conf
# by: Cody Kochmann
# license: MIT
#
# This is my personal tmux.conf I like to start with when setting up new systems before I tune
# things for the specific monitors I need to work with.
#
# This has been a comfortable "starting point" for ultrawides, pocket laptops (like gpd pocket),
# and even iphones. (yes, I daily drive tmux on my iphone. I win the oddball fight.)
#
@CodyKochmann
CodyKochmann / stateful-embedded-postgres-python-functions.sh
Created October 2, 2021 11:21
stateful embedded postgres python functions
View stateful-embedded-postgres-python-functions.sh
#
# description: demo of shared data in plpython functions
# by: Cody Kochmann
# date: 2021-10-02
#
testdb=> -- pg has two magic vars for plpython3u functions
testdb=> -- SD | dict | per function memory
testsb=> -- GD | dict | global shared function memory
testdb=> CREATE FUNCTION state_test (t TEXT)
RETURNS TEXT[]
@CodyKochmann
CodyKochmann / disable_hyperthreading.sh
Created July 23, 2021 16:22
how to turn off hyperthreading from a vm with no bios privs
View disable_hyperthreading.sh
#!/bin/bash
# by: Cody Kochmann
#
# this program tells the kernel to turn off the
# odd cores on a host. This is useful when you
# want to disable hypertheading in an ec2
# instance and dont have bios access to do it
# at the chip level.
seq 0 127 | awk '{print "echo 0 > /sys/devices/system/cpu" $1 * 2 + 1 "/online"}' | bash -x
@CodyKochmann
CodyKochmann / iterate_stdin.go
Created July 15, 2021 14:24
iterate stdin lines in golang
View iterate_stdin.go
// by: Cody Kochmann
// this iterates stdin lines to a golang channel
package main
import (
"os"
"bufio"
)