Skip to content

Instantly share code, notes, and snippets.

View lukestanley's full-sized avatar

Luke Stanley lukestanley

View GitHub Profile
@lukestanley
lukestanley / alpaca.py
Created March 23, 2023 20:33
WIP Alpaca LangChain Python LLM Class with streaming
# Credit to https://github.com/nsarrazin/serge - this is heavily copied from the API there and not very well yet but it might work.w
from typing import List, Optional
from uuid import UUID, uuid4
from pydantic import BaseModel, Field
from datetime import datetime
import subprocess, os
import asyncio
@lukestanley
lukestanley / xuuid.py
Last active March 26, 2023 14:56
xuuid 0.1.1 -- Extended Universally Unique Identifiers Extremely large UUIDs that are more certainly unique, descriptive, supported by tooling for short local reference. There is a distinction made between "hard" and "soft" data for an identifier.
# xuuid.py
"""
xuuid 0.1.1 -- Extended Universally Unique Identifiers
Extremely large UUIDs that are:
more certainly unique,
descriptive,
supported by tooling for short local reference.
There is a distinction made between "hard" and "soft" data for an identifier.
@lukestanley
lukestanley / vm_launcher.py
Last active April 22, 2022 11:41
PySide2 VirtualBox VM launcher script for Linux
"""
A PySide2 script to open selected VirtualBox VMs.
It shows a list of VirtualBox VM's and that is filtered on every key press (without pressing enter).
When enter is pressed, we launch or switch to the first matching VirtualBox machine.
Later the filter query is cleared ready for the next interaction.
VirtualBox's own GUI doesn't clear it's search box after using it.
This annoyed me so I wrote this for my Linux box.
It depends on PySide2, wmctrl, and VBoxManage.
"""
from PySide2.QtWidgets import (
@lukestanley
lukestanley / save_open_x_window_icons.py
Last active September 14, 2021 16:13
Saves icons for open X windows to a folder
"""Saves icons for open X windows to a folder.
Pypanel inspired me, by showing that Python can get icons with Xlib.
This does that in a more simple and uses PIL to save them too :)
"""
from PIL import Image
from Xlib import X, display, error, Xatom
DIRECTORY = "/home/user/icons/"
#define _GNU_SOURCE
#include <errno.h>
#include <sched.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
@tomhicks
tomhicks / plink-plonk.js
Last active July 26, 2024 01:10
Listen to your web pages
@lukestanley
lukestanley / termux-sshd-wormhole.sh
Last active March 27, 2023 20:29
Access Android's files remotely with SSH server on Termux, and magic-wormhole for key exchange
# With Termux installed, something like this should work
# to type less, you might be able to copy and paste this,
# or use Curl / wget
# First enable file access permission:
termux-setup-storage # accept file access as prompted
pkg install clang cmake python openssh libsodium
SODIUM_INSTALL=system pip install pynacl # skip building bundled version
pip install magic-wormhole
sshd
wormhole ssh invite # follow directions
@glasslion
glasslion / vtt2text.py
Last active July 26, 2024 12:39
This script convert youtube subtitle file(vtt) to plain text.
"""
Convert YouTube subtitles(vtt) to human readable text.
Download only subtitles from YouTube with youtube-dl:
youtube-dl --skip-download --convert-subs vtt <video_url>
Note that default subtitle format provided by YouTube is ass, which is hard
to process with simple regex. Luckily youtube-dl can convert ass to vtt, which
is easier to process.
@oscherler
oscherler / README.md
Last active July 3, 2024 00:18
Diff JSON in Git using gron

jsondiff: diff JSON in Git using gron

gron is an incredible tool that makes JSON greppable. But it also makes it diffable, which is great if you have JSON files in Git.

To use gron to diff JSON in Git, save the json-diff script below and make it executable. Then add a difftool as shown in gitconfig, and optionally create an alias to invoke it more easily. Then try it:

git init
echo '{"foo":42,"bar":"hello"}' > foo.json
git add foo.json &amp;&amp; git commit -m 'Initial commit.'
@kwmiebach
kwmiebach / pytest.md
Last active June 4, 2024 06:29 — forked from amatellanes/pytest.sh
pytest cheat sheet

Usage

(Create a symlink pytest for py.test)

pytest [options] [file_or_dir] [file_or_dir] ...

Help: