Skip to content

Instantly share code, notes, and snippets.

View chtzvt's full-sized avatar
⛱️
‍To create a little flower is the labor of ages.

Charlton Trezevant chtzvt

⛱️
‍To create a little flower is the labor of ages.
View GitHub Profile
GitHubAuditLogPolling_CL
| where action_s =~ "integration_installation.repositories_added" or action_s =~ "integration_installation.create"
| extend appName = tostring(name_s)
| extend organization = tostring(org_s)
| project-reorder TimeGenerated, actor_s, org_s, organization
| extend date_time = unixtime_milliseconds_todatetime(_timestamp_d)
| project TimeGenerated = date_time, AccountCustomEntity = actor_s, organization = org_s, appName , action = action_s
@chtzvt
chtzvt / pdf_optimize.sh
Last active September 25, 2023 18:35
PDF conversion commands
# .pdf to .pdf - 90+% compression ratio (lossy)
find . -type f -iname "*.pdf" -exec gs -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -dCompatibilityLevel=1.4 -dNOPAUSE -dBATCH -sOutputFile={}.optimized.pdf {} \;
# .ai to .pdf - 90+% compression ratio
find . -type f -iname "*.ai" -exec gs -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -dCompatibilityLevel=1.4 -dNOPAUSE -dBATCH -sOutputFile={}.optimized.pdf {} \;
@chtzvt
chtzvt / org_repo_cleanup.rb
Created August 30, 2023 18:22
Deletes all repositories associated with a given GitHub organization.
require 'octokit'
access_token = ENV["GH_PAT"]
org_name = ENV["GH_ORG"]
begin
client = Octokit::Client.new(access_token: access_token)
rescue Octokit::Unauthorized
puts "Invalid access token. Please set the GH_PAT environment variable to a valid GitHub Personal Access Token."
exit
@chtzvt
chtzvt / ghazdo-starter.yml
Last active March 7, 2024 17:57
Starter Pipeline for GitHub Advanced Security for Azure DevOps
# Welcome to the Starter Pipeline for GitHub Advanced Security for Azure DevOps (GHAzDo)
#
# This pipeline enables two core features of GHAzDo for your repository:
#
# - Dependency Scanning, which will examine your application's package manifests
# to find and alert on any vulnerable dependencies you may be using, and
#
# - Code Scanning, which performs static analysis (SAST) of your application's source
# code to identify certain types of security vulnerabilities, along with additional,
# optional quality checks.
@chtzvt
chtzvt / lmdb.tcl
Created May 18, 2023 19:33 — forked from antirez/lmdb.tcl
LMDB -- First version of Redis written in Tcl
# LVDB - LLOOGG Memory DB
# Copyriht (C) 2009 Salvatore Sanfilippo <antirez@gmail.com>
# All Rights Reserved
# TODO
# - cron with cleanup of timedout clients, automatic dump
# - the dump should use array startsearch to write it line by line
# and may just use gets to read element by element and load the whole state.
# - 'help','stopserver','saveandstopserver','save','load','reset','keys' commands.
# - ttl with milliseconds resolution 'ttl a 1000'. Check ttl in dump!

GitHub Secret Scanning - PEM Format

Secret format: ((\w|[=/+])+\r?\n)+

Before secret: -----BEGIN ([A-Z]+ )?PRIVATE KEY-----\r?\n

After secret: -----END ([A-Z]+ )?PRIVATE KEY-----

# Scholten/Dijkstra pebble game
# https://youtu.be/31KI7fk15QA?t=90
# my implementation (an abomination)
class Pebble
attr_accessor :color
def initialize
@color = 1 + rand(2) > 1 ? :black : :white
end
# Okasaki style Functional Red Black Tree
# https://www.cs.tufts.edu/comp/150FP/archive/chris-okasaki/redblack99.pdf
#
# leaves and root are black
# BST
# No red node has a red child
# Every path from the root to a leaf has the same number of black nodes
module RBTree
class Leaf
@chtzvt
chtzvt / iptables_rules.sh
Last active September 26, 2022 16:00
AnyConnect transparent VPN bridge/router
SYSTEM_LAN_IFACE="eth0"
VPN_CLIENT_IFACE="tun0"
DEST_IP="10.173.204.63"
FWDED_PORT="22"
SOURCE_NET_WHITELIST="10.0.2.0/24,10.0.3.0/24"
get_iface_ip() {
IP=`ip addr show $1 | grep -o "inet [0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" | grep -o "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*"`
if [[ $? -ne 0 ]];
then
@chtzvt
chtzvt / exif_fix_first_pass.rb
Last active September 16, 2022 18:00
Fixing missing/clobbered EXIF data on a portion of my photos library
# frozen_string_literal: true
require 'exif'
require 'fileutils'
require 'shellwords'
formats = ['.jpg', '.png', '.jpeg', '.mov', '.mp4', '.m4v']
def update_exif(year, month, day, f)
f = f.strip