Skip to content

Instantly share code, notes, and snippets.

@guyromm
guyromm / jsonlkeys.py
Created August 15, 2023 14:27
analyze keys and data types in a JSONL coming into stdin
#!/usr/bin/env python
import sys
import json
import collections
from typing import Any, Dict, List, Union
def get_type(value: Any) -> str:
return type(value).__name__
def update_summary(item: Union[Dict[str, Any], List[Any]], path: str = ""):
@guyromm
guyromm / README.org
Created March 20, 2020 05:05
incrementally periodically dump a postgresql database to google drive using borg, zstandard & rclone
@guyromm
guyromm / jsonl_to_psql_import.sh
Created April 4, 2023 10:21
how to import a bunch of JSONL into your all time favorite database (postgresql, duh)
#!/bin/bash
F="$1"
T="$2"
for ((I=0;I<"$(cat "$F" |wc -l)";I=$I+1)) ; do
tail -n+$I $F | head -1 > /tmp/1.json
(echo '\set l1 `cat /tmp/1.json`' ; echo "insert into "$T" (v) values (:'l1')" ) | ./psql.sh -t -v ON_ERROR_STOP=1;
done
@guyromm
guyromm / summarize.py
Created March 24, 2023 22:36
gpt4 powered long document summarizer
#!/usr/bin/env python
"""
invocation example:
@guyromm
guyromm / rps.py
Created March 7, 2011 17:08
socket.io flask route
@app.route('/socket.io/websocket')
def socketio():
s = request.environ['socketio']
if s.on_connect():
#print 'CONNECTED', locals()
#s.send({'buffer': buffer})
#s.broadcast({'announcement': s.session.session_id + ' connected'})
pass
game_id=None;game=None;cook=None;i_am='spectator';rdsub = redis.Redis('localhost')
while True:
@guyromm
guyromm / exportLayers.jsx
Created March 17, 2011 14:30
export Adobe Illustrator layers as separate rasters - now recursive
/////////////////////////////////////////////////////////////////
// Batch Export Unlocked Layers v1 -- CS5
//>=--------------------------------------
// This script will generate a separate raster image for every UNLOCKED layer in your .ai file. (Only tested on PC)
//
// Locked images will be left as is.
// To <b>hide</b> any layer;
// Lock it, and hide it on the Layers palate before running this script.
//
// To <b>include</b> a layer in every image:
@guyromm
guyromm / paste-in-console.js
Created February 27, 2020 08:59
a way to print your list of domains registered with namecheap from their horrendous interface
doms=[];prevlen=0;scrollpos=0;scrollinc=300;
function work() {
prevlen = doms.length;
for (let e of document.querySelectorAll('domain-icon')) {
let dom = e.nextSibling.nextSibling.textContent;
if (!doms.includes(dom))
{
console.log(dom);
doms.push(dom);
}
@guyromm
guyromm / esnextbin.md
Last active September 24, 2019 10:09
esnextbin sketch
@guyromm
guyromm / collect.sh
Created January 17, 2019 11:44
AWS instance state collection & merge script. requires python3 & awscli
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
REG=$(aws configure get region)
OPDIR=$DIR/$REG/
function retrieve() {
mkdir -p $OPDIR && \
cd $OPDIR && \
(aws ec2 describe-volumes | tee $OPDIR/ec2-describe-volumes.json | wc) && \
(aws ec2 describe-instances | tee $OPDIR/ec2-describe-instances.json | wc) && \
@guyromm
guyromm / generate.sh
Created October 23, 2018 12:23
generate some mac addresses for masquerading with ebtables
python -c "for a in xrange(0x00,0xff+1): print(format(a,'X').zfill(2).lower())" | \
awk '{print "ebtables -t nat -A POSTROUTING -s 00:16:3e:"$1":95:60 -j snat --to-src 38:d5:47:0:c:ed --snat-target ACCEPT --log --log-level=warning --log-prefix=MACREWRITE"}' | \
tee /tmp/ebatron.sh && \
bash /tmp/ebatron.sh