Skip to content

Instantly share code, notes, and snippets.

View cmj's full-sized avatar
💭
📠

cmj cmj

💭
📠
View GitHub Profile
@cmj
cmj / twitter_auth.sh
Created November 13, 2024 19:19
Cookie auth for Nitter
#!/bin/bash
# Grab auth_token, x-csrf-token (ct0) for use with Nitter
# and other tools (requires Twitter account).
# - 1-2 successfull logins can be seen every 60 seconds (not fully tested)
username=""
password=""
# number of login attempts
debug=1 # [0|1] set to 0 if redirecting output to config
@cmj
cmj / edates.sh
Created November 11, 2024 09:07
gnuplot dates
#!/bin/bash
dates() {
dateutils.dseq 2022-11-01 now -f '%Y-%m-%d' | cat -n
}
export -f dates
monthly_seq=$(dates | grep 01$ | awk ' { t = $1; $1 = "\""$2"\""; $2 = t","; print; } ' | tr '\n' ' ' | sed 's/, $//')
last_day=$(dates | sed -n 'x;$p')
@cmj
cmj / pluto-guide
Created November 7, 2024 14:04
pretty print pluto.tv guide
#!/bin/bash
# pretty print pluto.tv guide
# use '1' option for up next?
if [ -z $1 ]; then
n=0
else
n=$1
fi
@cmj
cmj / twitter-cookie.sh
Last active November 7, 2024 02:42
Twitter cookie for Nitter, create cookies.json
@cmj
cmj / inversion.sh
Last active November 8, 2024 13:41
Check for atmospheric inversion via KSEA soundings
#!/bin/bash
# Check for atmospheric inversion via KSEA soundings
# ex:
# +.08 - 41.78° @ 867.55 feet
# +.88 - 42.58° @ 1064.47 feet
# +.84 - 42.54° @ 1295.16 feet
# Portland, OR (KPDX) - https://a.atmos.washington.edu/mm5rt/rt/showsounding_d3.cgi?initmodel=GFS&yyyymmddhh=timeindep&reqhr=12&loc=kpdx&locname=Portland,OR&latlon=45.59N,122.6W
sounding=$(curl -s 'https://a.atmos.washington.edu/mm5rt/rt/showsounding_d3.cgi?initmodel=GFS&yyyymmddhh=timeindep&reqhr=12&loc=ksea&locname=Sea-Tac,WA&latlon=47.44N,122.31W')
out=$(grep -A 30 TMPF <<< "${sounding}" | tail -30 | awk '{print $4,$10}')
@cmj
cmj / pluto.m3u8
Created November 5, 2024 11:13
Pluto TV playlist
#EXTM3U
#EXTINF:0,00s Replay
http://service-stitcher.clusters.pluto.tv/stitch/hls/channel/62ba60f059624e000781c436/master.m3u8?advertisingId=&appName=web&appVersion=unknown&appStoreUrl=&architecture=&buildVersion=&clientTime=0&deviceDNT=0&deviceId=5d9cd8e2-dd04-11eb-990c-d7728814a60c&deviceMake=Chrome&deviceModel=web&deviceType=web&deviceVersion=unknown&includeExtendedEvents=false&sid=0c6cb070-0cfd-4d6c-ad81-c614133fd44b
#EXTINF:0,48 Hours
http://service-stitcher.clusters.pluto.tv/stitch/hls/channel/6176f39e709f160007ec61c3/master.m3u8?advertisingId=&appName=web&appVersion=unknown&appStoreUrl=&architecture=&buildVersion=&clientTime=0&deviceDNT=0&deviceId=5d9cd8e2-dd04-11eb-990c-d7728814a60c&deviceMake=Chrome&deviceModel=web&deviceType=web&deviceVersion=unknown&includeExtendedEvents=false&sid=0c6cb070-0cfd-4d6c-ad81-c614133fd44b
#EXTINF:0,70s Cinema
http://service-stitcher.clusters.pluto.tv/stitch/hls/channel/5f4d878d3d19b30007d2e782/master.m3u8?advertisingId=&appName=web&appVersion=unknown&appStoreUrl=&archit
@cmj
cmj / gulf-current.sh
Last active October 9, 2024 05:21
Grab latest Hurricane Milton longwave IR sat image with overlays
#!/bin/bash
# Grab latest Hurricane Milton longwave IR image with overlays
# example: https://i.imgur.com/hMiwLZy.jpeg
# can't figure out the start & end params here
#gulf_sat=$(curl -so /tmp/gulf-sat.gif 'https://weather.cod.edu/satrad/assets/php/scripts/mkgif.php?parms=regional-gulf-13-1&rate=&pause=&start=891&end=891&checked=counties-usint-map&colorbar=undefined')
# so, doin' it by hand
# slurp overlays
if [[ ! -e /tmp/gulf_map.png || ! -e /tmp/gulf_counties.png || ! -e /tmp/gulf_usint.png ]]; then
@cmj
cmj / ff-redir
Last active October 8, 2024 13:52
kitty terminal - launcher wrapper
#!/bin/bash
# kitty terminal - launcher wrapper
# ~/.config/kitty/kitty.conf: open_url_with ff-redir
url=$1
# redirect twitter/x.com to local nitter instance
redir=$(sed 's|https://twitter.com|http://fuck.elon|;s|https://x.com|http://fuck.elon|' <<< "${url}")
# launch videos with mpv
videos="(youtube.com|youtu.be|twitch.tv|\.m3u8)"
@cmj
cmj / create-new.sh
Created October 7, 2024 19:50
Create Longwave IR for tropical storm Milton
#!/bin/bash
# Tropical storm Milton animation
find . -maxdepth 1 -type l -delete
d=$(date -u -Is )
dateutils.dseq ${d:0: -10}0 -10m 00:00:00 -f gulf.13.%Y%m%d.%H%M |
sed 's/0$/617.jpg/' |
tac |
while read file; do
@cmj
cmj / noaa.py
Created October 4, 2024 23:03
noaa forecast by zip
#!/usr/bin/python3
import sys
import json
from noaa_sdk import NOAA
import linecache as lc
zip = sys.argv[1]
n = NOAA()
res = n.get_forecasts(zip, 'US')
for i in res:
results = str(i)