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
@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.
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 / debugf.h
Last active August 15, 2023 21:06
A tiny little macro to help debug your C code.
// debugf.h
// Charlton Trezevant - 2018
// MIT license
/* USAGE:
* To use this macro, simply paste it into your source file (you may also
* include debugf.h if you have many source files). Doing this will define
* the function debugf(), which acts as a thin wrapper around fprintf() with
* a little added pizazz.
*
@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-----

Charltons-MacBook-Air:clevbot charlton$ node main.js
BOT 1: What's up?
BOT 1: Oh Damn b1
BOT 1: Okay Nothing.
BOT 2: Okay, sure. Eggs have nothing to do with the core concepts of Buddhism.
BOT 1: Maybe I would if you knew how to keep a relationship intact!
BOT 2: Okay Nothing.
BOT 1: Okay Nothing.
BOT 2: I can't.
BOT 2: It is movie with Jennifer Lawrence.
# 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