Skip to content

Instantly share code, notes, and snippets.

@guyromm
guyromm / README.org
Last active November 12, 2024 10:09
local proxy to remote server hack for macos

requirements

  • brew install tinyproxy
  • move the tinyproxy .plist from ~/Users/Library.. to /Library/LaunchDaemons/com.user.tinyproxy.plist

places to save the files

  • /Library/LaunchDaemons/com.user.tinyproxy.plist
  • /Library/LaunchDaemons/com.user.ssh_tunnel.plist
  • /usr/local/bin/ssh_tunnel.sh
  • /usr/local/etc/tinyproxy/tinyproxy.conf
@guyromm
guyromm / chunk_audio.py
Last active August 12, 2024 20:34
an example on how to save an hour of one's time using openai's speech 2 text & then gpt4-o to summarize and ask questions about the resulting text
#!/usr/bin/env python
from pydub import AudioSegment
from pydub.silence import split_on_silence
import sys
import os
def chunk_audio(input_file, output_prefix, min_silence_len=len(sys.argv)>2 and int(sys.argv[2]) or 1000, silence_thresh=-40, keep_silence=None):
if not keep_silence:
keep_silence = min_silence_len/4
@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 / 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 / README.org
Created March 20, 2020 05:05
incrementally periodically dump a postgresql database to google drive using borg, zstandard & rclone
@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