Skip to content

Instantly share code, notes, and snippets.

View CodyKochmann's full-sized avatar

Cody Kochmann CodyKochmann

  • Severn, MD
View GitHub Profile
@CodyKochmann
CodyKochmann / deb-install-podman.sh
Created February 18, 2020 14:29
install podman on debian 10 and kali linux
echo 'deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/Debian_10/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
wget -nv https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/Debian_10/Release.key -O- | apt-key add -
apt update
apt install podman
@CodyKochmann
CodyKochmann / firewall_log_generator.py
Created November 6, 2020 13:48
firewall log generator for testing log systems
#!/usr/bin/env python
# by: Cody Kochmann
from datetime import datetime
from functools import partial
from ipaddress import ip_address
from itertools import cycle, product, islice
from random import randint, shuffle
@CodyKochmann
CodyKochmann / shrink-postgres-table-disk-usage-with-full-disks.sh
Created February 25, 2024 12:53
This script contains the steps needed to shrink a massive table on postgres when disks did not have enough room to run a VACUUM FULL after major deletions.
#!/bin/bash
# This script contains the steps needed to shrink a massive table on postgres
# when disks did not have enough room to run a VACUUM FULL after major deletions.
# by: Cody Kochmann
# NOTE - These commands were run manually and will need situation specific
# options added if they were ever to be reused. This gist was only to
# capture the gist of the steps needed.
# set a date to clear logs to
@CodyKochmann
CodyKochmann / json-to-directory.py
Created October 4, 2023 13:29
This script takes a json object from stdin and turns it into a directory tree of files.
#!/usr/bin/env python3
# by: Cody Kochmann
# created: 2023-10-01
# license: MIT
'''
This script takes a json object from stdin and turns it into a directory tree of files.
'''
import sys, json, os, contextlib
@CodyKochmann
CodyKochmann / linux-gui-user-sandbox-demo.sh
Created September 24, 2023 11:40
how to run an interactive gui program from another user on debian 12
#!/bin/bash
# by: Cody Kochmann
# how to run an interactive gui program from another user on debian 12
# inspired by https://gist.github.com/kasunbg/5502cb630429819d07b5dc0cfa26813c
export NEW_USER_NAME=cody-facebook
#---------------------------------
# step 1 - create a new user
#---------------------------------
@CodyKochmann
CodyKochmann / fstab
Created September 24, 2023 11:38
how I keep cache to per boot lifetimes
# file /etc/fstab
# by: Cody Kochmann
# license: MIT
# description: how I keep cache to per boot lifetimes
# Note - pull the uid and gid from /etc/fstab to ensure correct permissions
# Note - the "size" can be defined as units like "1G" or percentages like "10%"
# configuration for per user cache
tmpfs /home/cody/.cache tmpfs defaults,uid=1000,gid=1000,mode=0700,size=10% 0 0
@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
# 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 / myIP.js
Created May 13, 2015 12:10
returns the users ip address in javascript
function myIP() {
// returns the users ip address
// ref link: http://stackoverflow.com/questions/391979/get-client-ip-using-just-javascript
if (window.XMLHttpRequest) xmlhttp = new XMLHttpRequest();
else xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("GET","http://api.hostip.info/get_html.php",false);
xmlhttp.send();
hostipInfo = xmlhttp.responseText.split("\n");
@CodyKochmann
CodyKochmann / IP.class.php
Created May 9, 2017 20:40
use this to extract ip addresses from strings and arrays in php.
<?
class IP
{
# by: Cody Kochmann
# returns true if the input is a valid ip address
public static function validate($s)
{
# returns true if the $s is valid ip address
return (int)(!filter_var($s, FILTER_VALIDATE_IP) === false);
@CodyKochmann
CodyKochmann / install_StaSh.py
Created September 25, 2016 20:22
install StaSh on pythonista for iOS to get pip working
# from https://forum.omz-software.com/topic/1919/stash-shell-like-an-expert-in-pythonista
# this script will get pip working on iOS!
import requests as r
exec(r.get('http://bit.ly/get-stash').text)