Skip to content

Instantly share code, notes, and snippets.

View cmj's full-sized avatar
💭
📠

cmj cmj

💭
📠
View GitHub Profile
@cmj
cmj / reddit-scrape.py
Created December 4, 2026 19:46
simple test
#!/usr/bin/env python3
import json
import sys
from curl_cffi import requests
url = sys.argv[1]
# grab reddit_session cookie using devtools
cookie = 'reddit_session=......'
usage: twitter_search.py [-h] [--filter {live,top}] [--output PATH] [--csv PATH] [--stdout] [--pretty] [--display] [--irc]
                         [--pages N] [--tweets COUNT] [--delay | --no-delay] [--delay-range MIN MAX] [--sessions PATH]
                         [--impersonate TARGET] [--debug] [--no-tid] [--quiet] [--no-color] [--color] [--limit N] [--no-verified]
                         [--columns COLS] [--localtime] [--colorize] [--theme THEME] [--highlight WORDS] [--url-domain DOMAIN]
                         [--watch] [--irc-watch] [--interval SEC] [--watch-mode MODE] [--no-clear] [--log-json PATH] [--log [PATH]]
                         [--no-batch-sep]
                         QUERY

Search X/Twitter with auth_token cookies via the SearchTimeline GraphQL endpoint
@cmj
cmj / imgur
Created November 23, 2026 03:16
anon imgur upload
#!/bin/bash
# Imgur script by Bart Nagel <bart@tremby.net>
# Improvements by Tino Sino <robottinosino@gmail.com>
# Version 6 or more
# I release this into the public domain. Do with it what you will.
# The latest version can be found at https://github.com/tremby/imgur.sh
# API Key provided by Bart;
# replace with your own or specify yours as IMGUR_CLIENT_ID envionment variable
@cmj
cmj / reddit_comments.py
Created November 18, 2026 15:00
reddit comments rss / json generator
#!/usr/bin/env python3
"""
Grab a subreddit's recent comments, and convert them to Atom/RSS and/or JSON.
Reddit removed basic RSS/JSON features (2026-11-17) so we go back to circa 2005 webscraping.
Usage:
python reddit_comments.py redditdev # writes redditdev.rss + .json
python reddit_comments.py redditdev --pages 4 --format json
python reddit_comments.py redditdev --file redditdev.html # parse a saved page, no network
python reddit_comments.py redditdev -o - -f json | jq '.[].author' # JSON to stdout
@cmj
cmj / portland.rss
Created November 18, 2026 13:22
reddit rss generator output
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<category term="portland" label="r/portland" />
<updated>2026-11-18T13:20:21+00:00</updated>
<icon>https://www.redditstatic.com/icon.png/</icon>
<id>/r/portland/comments/.rss</id>
<link rel="self" href="https://www.reddit.com/r/portland/comments/.rss" type="application/atom+xml" />
<link rel="alternate" href="https://www.reddit.com/r/portland/comments/" type="text/html" />
<title>newest comments : portland</title>
<entry>
@cmj
cmj / reddit-rss2json.py
Created November 9, 2026 08:26
reddit comments - rss2json with pretty print (.rss upstream ends 2026-11-13)
#!/usr/bin/env python3
import argparse
import json
import re
import sys
import xml.etree.ElementTree as ET
from datetime import datetime
from urllib.parse import urlsplit, parse_qsl
from bs4 import BeautifulSoup
from curl_cffi import requests
@cmj
cmj / dump1090-watchdog.sh
Created November 3, 2026 10:09
dump1090-fa watchdog cron script
#!/bin/bash
# dump1090-fa watchdog: run from cron every minute.
# Restarts dump1090-fa if it isn't running (or its data has gone stale),
# power-cycles the RTL-SDR USB device first, and sends an ntfy notification.
NTFY_TOPIC="CHANGE_ME" # e.g. "my-secret-pi-adsb-topic" (uses https://ntfy.sh, free, no account)
USB_VID="0bda" # Realtek RTL2832U
USB_PID="2838"
JSON_DIR="/run/dump1090-fa"
STALE_SECS=180 # restart if aircraft.json hasn't updated in this long
@cmj
cmj / bashrc_twitter_at_handler.md
Created October 26, 2026 16:25
bash at command scriipt

Enable @username in bash render tweets via kitty-tweet

copy this into ~/.bashrc

command_not_found_handle() {
    if [[ $1 =~ ^@[^[:space:]]+$ ]]; then
        kitty-tweet "$@"
        return $?
 fi
@cmj
cmj / shade
Created October 25, 2026 20:36
window shading/stretching script, bind to a shortcut
#!/bin/bash
# KDE6 unshade hack.
# Stretch stuck unshaded window to 3/4 of the current screen height, preserve width
win=$(xdotool getactivewindow 2>/dev/null) || exit 0
[ -z "$win" ] && exit 0
# Bail if the "active window" is the root window
root=$(xwininfo -root | awk '/Window id:/{print $4}')
[ "$(printf '0x%x' "$win")" = "$root" ] && exit 0
@cmj
cmj / 0-screenshot.md
Created October 25, 2026 09:32
Print tweet with images to kitty term