Skip to content

Instantly share code, notes, and snippets.

View grantjenks's full-sized avatar

Grant Jenks grantjenks

View GitHub Profile
@grantjenks
grantjenks / step.py
Created November 21, 2023 01:39
Print all the files tracked by Git
#!/usr/bin/env python
import subprocess
from pathlib import Path
output = subprocess.run(['git', 'ls-files'], stdout=subprocess.PIPE, text=True, check=True)
paths = [Path(path) for path in output.stdout.strip().split('\n')]
for path in paths:
print(path)
@grantjenks
grantjenks / Bookmark
Created March 8, 2023 16:44
Scratchpad in Chrome
data:text/html,<body contenteditable style=font-family:monospace;line-height:1.5;font-size:24px><script> window.onbeforeunload = function(e) { e.preventDefault();return ''; }; </script>
@grantjenks
grantjenks / mac-key-speed.txt
Created March 1, 2023 06:23
Settings for Mac Keyboard Speed
$ defaults write -g InitialKeyRepeat -int 13
$ defaults write -g KeyRepeat -int 1
@grantjenks
grantjenks / Terminal.out
Created January 21, 2023 19:33
Proof of Concept for "On-call Assistant"
$ ipython
Python 3.8.4 (v3.8.4:dfa645a65e, Jul 13 2020, 10:45:06)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.16.1 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from langchain.agents import Tool, initialize_agent
...: from langchain.agents import load_tools
...: from langchain.llms import OpenAI
...:
@grantjenks
grantjenks / dotfiles-management.md
Created January 17, 2023 01:35
Dotfiles Management
@grantjenks
grantjenks / fizzbuzz.py
Created January 16, 2023 21:40
FizzBuzz
from itertools import cycle, slice
fizz = cycle('', '', 'fizz')
buzz = cycle('', '', '', '', 'buzz')
pairs = zip(fizz, buzz)
for pair in slice(pairs, 30):
print(' '.join(pair))
@grantjenks
grantjenks / ffmpeg-notes.txt
Created October 28, 2022 05:21
ffmpeg commands to convert video files
# Convert .m4v to .mp4
$ ffmpeg -i input.m4v -c:v libx264 -c:a aac output.mp4
# Convert .mp4 to .webm
$ ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 30 -b:v 0 -b:a 128k -c:a libopus output.webm
@grantjenks
grantjenks / base.css
Created October 26, 2022 06:12
Basic CSS styling for HTML webpages.
html {
max-width: 70ch;
padding: calc(1vmin + .5rem);
margin-inline: auto;
font-size: clamp(1em, 0.909em + 0.45vmin, 1.25em);
font-family: system-ui;
}
body {
line-height: 1.6;
}
@grantjenks
grantjenks / tcp_proxy.py
Created March 14, 2021 18:34
Simple TCP Proxy
"""Simple TCP Proxy
Receive connections on one port and forward them to another port.
Example:
$ python3 -m http.server 8080 # Start an http server on port 8080
$ python3 tcp_proxy.py 5000 8080 # Proxy port 5000 to 8080
Open http://localhost:5000/ in Chrome
@grantjenks
grantjenks / reboot.service
Created May 3, 2020 20:28
Weekly reboots using systemd.
# /etc/systemd/system/reboot.service
[Unit]
Description=Reboot Service
[Service]
Type=oneshot
ExecStart=/bin/systemctl --force reboot