Skip to content

Instantly share code, notes, and snippets.

View mwolson's full-sized avatar

Mike Olson mwolson

View GitHub Profile
# Set policy for lid-close
sudo mkdir -p /etc/systemd/logind.conf.d
cat <<'EOF' | sudo tee /etc/systemd/logind.conf.d/10-lid-switch.conf > /dev/null
[Login]
HandleLidSwitch=suspend
HandleLidSwitchDocked=ignore
HandleLidSwitchExternalPower=suspend
EOF
sudo systemctl reload systemd-logind
@mwolson
mwolson / README.md
Last active November 30, 2025 05:46
gptel-manual-complete.el

gptel-manual-complete.el

This is an example of how the existing gptel-rewrite.el file can be used to perform completion on an entire function, replacing what's already written so far in that function.

Setup

To use:

@mwolson
mwolson / gradio-ui.py
Created January 10, 2025 01:02
local llm UI example
# taken from https://mer.vin/2024/07/codestral-mamba-code/
import gradio as gr
import openai
import os
import sys
openai.api_key = "-"
openai.base_url = sys.argv[1]
def chat_with_mistral(user_input):
@mwolson
mwolson / README.md
Last active January 7, 2025 16:11
Ghostty + tmux uniform copy and paste

Ghostty + tmux uniform copy and paste

Explanation

This set of configuration changes achieves the following:

  • Disable automatic copying to clipboard while using the mouse to select text. Instead, the selection is copied when the user types either Ctrl+Shift+c or Super+c (on macOS only) after using the mouse to select text.
  • The Super+c keybinding works by remapping it to Ctrl+Shift+c in ghostty.
  • Ghostty will ignore those keybindings so that tmux can handle them. This allows tmux to copy text cleanly even
@mwolson
mwolson / updating-man-database.md
Created October 21, 2016 01:30
Updating man database (for man -k) on OS X

After installing new packages, the M-x man command might not list the new manpages for those packages, because the whatis DB used by man gets updated weekly via a cron job. Further, any manpages for programs that are part of the XCode Commandline Tools will never get installed because the cron job inexplicably excludes them. To make force them to be generated, run the following:

sudo /etc/periodic/weekly/320.whatis
sudo /usr/libexec/makewhatis /Applications/Xcode.app/Contents/Developer/usr/share/man
@mwolson
mwolson / index.css
Created March 20, 2019 23:31
zoom image into a box preserving aspect ratio
.tc-ConversationItem[class] .tc-ConversationItem__avatar .tc-AvatarImage {
// modify these with something like calc(200%), or manual width/height "box" around the image
// which then gets zoomed to fit
width: 52px;
height: 52px;
}
.tc-AvatarImage[class].tc-AvatarImage--size--fit {
display: block;
width: 100%;
@mwolson
mwolson / pyramid.md
Created March 22, 2017 22:13
Test pyramid

Test pyramid

We want more of the (faster and/or easier to write) things at the bottom of the pyramid, and less of the (slower and/or harder to write) things at the top of the pyramid.

                        /\
                       /  \
                      /    \
 / security analysis
@mwolson
mwolson / swank-js-init.el
Last active December 15, 2015 01:19
Attaching to a swank-js node.js server using SLIME and Emacs
;; Improved Javascript support
(add-to-list 'load-path (concat my-emacs-path "/elisp/js2-mode"))
(autoload 'js2-mode "js2-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
;; Node REPL using SLIME
(add-to-list 'load-path (concat my-emacs-path "/elisp/slime"))
(add-to-list 'load-path (concat my-emacs-path "/elisp/slime/contrib"))
(require 'slime)
(autoload 'slime-js-minor-mode "slime-js" nil t)
@mwolson
mwolson / erc-solarized.el
Created December 4, 2012 22:08
Make ERC look nice with some themes
;;; Assumptions:
;;
;; - Solarized (dark) theme has already been loaded
;; https://github.com/sellout/emacs-color-theme-solarized
;;
;; - Nicks in ERC buffer before running this code may look weird.
;; New activity in ERC buffer after running this code should look OK.
(defun mwolson/make-erc-themeable ()
(interactive)