Skip to content

Instantly share code, notes, and snippets.

@algal
algal / lisp_for_zach.el
Created January 17, 2025 02:26
some emacs lisp snippets
;; This is miraculously all you need to add decent support for python.
;; It requires that you have uv installed. Then run `eglot` in a python buffer.
(use-package eglot
:defer t
:config
(add-to-list 'eglot-server-programs
`(python-mode . ,(split-string "uvx --quiet --from pyright pyright-langserver --stdio"))))
;; this is handy for dumping web pages into buffers, to then add them to context for AI with gptel
(defun alg/insert-markdown-from-url (url)
@algal
algal / claude-2024-12-28.org
Last active December 28, 2024 21:32
Claude on automated btrfs maintenance, subjectivity, and subconscious compulsions

How do I find out about the e2scrub_all.timer on my system?

To learn more about the e2scrub_all.timer on your system, you can use these systemctl commands:

  1. View timer details:
systemctl status e2scrub_all.timer
@algal
algal / Shuffling in torch vs numpy-public.ipynb
Created December 20, 2024 06:46
Shuffling in torch vs numpy-public.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@algal
algal / advent2024d3.ipynb
Created December 4, 2024 01:52
My Dialog
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@algal
algal / aoc2023d3.ipynb
Created December 3, 2024 17:29
My Dialog
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@algal
algal / advent2022.ipynb
Created December 3, 2024 01:03
My Dialog
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
def find_free_port(candidates=[]):
for p in (candidates + [0]):
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
try:
s.bind(('localhost',p))
return s.getsockname()[1]
except Exception:
logging.info(f"Could not bind to port {p}. Trying another")
port = find_free_port([5001,5010,5100])
@algal
algal / openjup.py
Last active October 2, 2024 19:00
Python script to open a notebook in your local browser, no matter where the server or notebook is
#!/usr/bin/env python3
import os, os.path, sys, urllib.parse, base64, subprocess
def on_iterm2(): return 'ITERM_SESSION_ID' in os.environ or os.environ.get('LC_TERMINAL','') == 'iTerm2'
def on_macOS(): return sys.platform == 'darwin'
def on_remote_host(): return 'SSH_CLIENT' in os.environ or 'SSH_TTY' in os.environ
def openurl(url):
@algal
algal / term-iterm2.el
Created May 5, 2024 22:33
Make emacs see all keystrokes in TTY mode with iTerm2
;; This package makes changes to how emacs interprets CSI escape codes, so that
;; it better understands "CSI u"-style codes, so that more key chords pass
;; through to emacs in terminal mode.
;;
;; It is intended to work with the following terminal confugration:
;;
;; - iTerm2 / Keys / Report modifiers using CSI u: enabled
;; - iTerm2 / Keys / xterm control sequences can enable modifyOtherKeys mode: enabled
;; - iTerm2 / Terminal / Report Terminal Type: xterm-direct
;;