Skip to content

Instantly share code, notes, and snippets.

View sampollard's full-sized avatar

Sam Pollard sampollard

View GitHub Profile
@sampollard
sampollard / capslock.ahk
Last active February 24, 2024 08:30
Add some convenience keybindings
; How to view scancodes in AHK v1 (I can't figure this out for v2)
; Right-click, "run this script" on this file (not the .exe)
; Right click and select "Open"
; View -> Key History and Script Info
; Now you can type things, press F5 to refresh; they appear bottom-up
SendMode("Input") ; Tutorials say this is good
Capslock::LCtrl ; Map Capslock to Control
RCtrl & Capslock::Capslock ; Map Right control + Capslock to Capslock
; Hibernate on ctrl+alt+win+h
@sampollard
sampollard / merge.sh
Last active February 17, 2023 05:23
Merge pdfs
# usage: merge out.pdf file1.pdf file2.pdf ...
function merge() {
out="$1"
shift
gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE="$out" -dBATCH $@
}
@sampollard
sampollard / conversation.sh
Created July 2, 2022 02:12
Slowly spit out text, paragraph by paragraph
#!/bin/bash
FILE=conversation
LTIME=`stat -c %Z $FILE`
# Below is a Text width of 40
echo "========================================"
while true
do
ATIME=`stat -c %Z $FILE`
if [[ "$ATIME" != "$LTIME" ]]
then
@sampollard
sampollard / passport.sh
Created December 1, 2021 08:55
Get 6 2" x 2" passport photos on a 4x6
#!/bin/bash
# Create a 4x6 photo from one square image
if [ $# -ne 1 ]; then
echo "usage: ./passport.sh <filename>"
exit 1
fi
FN="$1"
montage "$FN" -clone 0,0,0,0,0 -geometry +0+0 -tile 3x2 "${FN%.*}-4x6.jpeg"
@sampollard
sampollard / negativebox.tex
Last active October 7, 2020 05:57
Highlight a part of a bounding box in Tikz. Use with \negativebox{x1,y1}{x2,y2} inside tikzpicture
\newcommand\negativebox[2]{%
\def\opc{0.75}
\def\opcol{white}
% Left
\fill[opacity=\opc, color=\opcol]
let
\p{sw} = (current bounding box.south west),
\p{nw} = (current bounding box.north west),
\p1 = (#1)
in (\p{sw}) rectangle (\x1, \y{nw});%
@sampollard
sampollard / roman-name-generator.sh
Last active August 30, 2020 06:36
Generate Random Names
#!/bin/bash
# Generates random roman names plus its gender
# Names copied from https://www.behindthename.com/names/usage/ancient-roman
# First preprocessed by
# awk 'FNR%2 {print $1 " " $2}' roman-names.txt > roman-names.csv
# Surnames copied from https://en.wikipedia.org/wiki/List_of_Roman_nomina
CNT=$1
if [ "$#" -ne 1 ]; then
CNT=5
fi
@sampollard
sampollard / settings.json
Last active October 29, 2020 23:22
Windows Terminal Settings
// This file was initially generated by Windows Terminal 1.3.2651.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
@sampollard
sampollard / vim.ahk
Last active February 17, 2021 07:20
Vim in Windows
; How to view scancodes
; Right-click, "run this script" on this file (not the compiled file!)
; Right click and select "Open"
; View -> Key History and Script Info
; Now you can type things, press F5 to refresh; they appear bottom-up
#NoEnv ; Compatibility with future AutoHotkey releases
SendMode Input ; Tutorials say this is good
Capslock::Esc ; Map Capslock to Escape
+Capslock::Capslock ; Map Shift-Capslock to Capslock
@sampollard
sampollard / ital.sh
Created April 8, 2020 04:06
Italicise every other character in LaTeX
#!/bin/bash
# usage: ital.sh <filename>
echo '/\\begin{document}/+,/\\end{document}/-s/\(.\)\(.\)/\\emph{\1}\2/g | w' | vim -e "$1"
# A xterm-256color based TERMINFO that adds the escape sequences for italic.
# Follow instructions at
# https://apple.stackexchange.com/questions/266333/how-to-show-italic-in-vim-in-iterm2
# Basically, check italic text in settings, then type
# tic -o ~/.terminfo xterm-256color.terminfo.txt
# and make sure to export TERM=xterm-256color in your ~/.profile
xterm-256color|xterm with 256 colors and italic,
sitm=\E[3m, ritm=\E[23m,
use=xterm-256color,