Skip to content

Instantly share code, notes, and snippets.

@roryrjb
roryrjb / install-python.sh
Last active June 23, 2024 07:09
Install Python (on Ubuntu 24.04)
sudo apt update
sudo apt install -y build-essential pkgconf libssh-dev libz-dev uuid-dev liblzma-dev libreadline-dev libffi-dev libbz2-dev
cd "$(mktemp -d)"
curl -LO https://www.python.org/ftp/python/3.11.9/Python-3.11.9.tgz
tar xvf Python-3.11.9.tgz
cd Python-3.11.9/
./configure --prefix ~/opt/python --enable-optimizations
make -j$(nproc)
make install
~/opt/python/bin/python3 -m pip install --upgrade --user pip
@roryrjb
roryrjb / ff
Created July 22, 2023 15:39
A simple file finder/grepper that supports ignore patterns (add one per line in ~/.ffignore)
#!/usr/bin/env python3
import argparse
import fnmatch
import os
import sys
def walktree(root, ignored_patterns):
try:
@roryrjb
roryrjb / npm.c
Last active January 22, 2023 11:05
npm.exe: a bad hack for when your Node.js project that spawns npm isn't quite portable
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#pragma comment(lib, "Shlwapi.lib")
/* Find the end of argv[0]. */
static WCHAR *
findargs(WCHAR *s)
{
if (s[0] == 34)
@roryrjb
roryrjb / .gitattributes
Created January 22, 2023 10:52
WSL1 git attributes
* text=auto eol=lf
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf
@roryrjb
roryrjb / subl
Last active January 22, 2023 16:20
Sublime Text wrapper for use within WSL1
#!/usr/bin/env python3
import sys
import subprocess
import os
filename = os.path.abspath(sys.argv[1])
if filename.startswith('/mnt'):
# /mnt/c/a/b/c.txt -> c:\a\b\c.txt