Skip to content

Instantly share code, notes, and snippets.

View bmgxyz's full-sized avatar

Bradley Gannon bmgxyz

View GitHub Profile
@bmgxyz
bmgxyz / random-redact.py
Created September 8, 2024 15:31
Randomly replace words in the input with full block characters, giving the appearance that they have been redacted
#!/usr/bin/env python3
import random
import sys
def print_usage():
print("random-redact.py <RAND_THRESH> [INPUT]")
print()
print("Randomly replace words in the input with full block characters, giving the appearance")
print("that they have been redacted")
@bmgxyz
bmgxyz / hsv_rgb.rs
Created May 11, 2022 02:08
Convert between HSV and RGB color spaces in Rust
use image::Rgb;
struct Hsv([f32; 3]);
fn convert_rgb_to_hsv(pixel: &Rgb<u8>) -> Hsv {
let [r, g, b] = pixel.0;
let big_m = *[r, g, b].iter().max().unwrap() as f32 / 255.;
let little_m = *[r, g, b].iter().min().unwrap() as f32 / 255.;
let c = big_m - little_m;
let s = (c / big_m) * 100.;
@bmgxyz
bmgxyz / overheard.py
Created July 21, 2019 15:21
Sends an email whenever a new DCist Overheard is released (cronjob not included)
#!/usr/bin/env python
#
# Bradley Gannon --- 2019-07-21
#
# Someone recently showed me the delightful collection of out-of-context
# quotes from the streets of Washington known as DCist Overheard. DCist has a
# publication-wide RSS feed, which is great, but I only really care to read
# Overheard, not the actual news that they publish. This script downloads the
# Overheard page, checks if there's a new post, and sends me an email if there
# is. (It actually just checks whether or not the most recent post was released