Skip to content

Instantly share code, notes, and snippets.

@mikeslattery
mikeslattery / briefmarks.lua
Last active January 19, 2024 17:44
which_key.nvim extension to limit how many marks are shown.
View briefmarks.lua
local M = {}
--[[
~/.config/nvim/lua/which-key/plugins/briefmarks.lua
This extends which-key/plugins/marks.lua with these changes:
* Only show subset of marks
* Letters
* ^ . '
@mikeslattery
mikeslattery / webcam2html.sh
Last active November 16, 2023 21:11
AI Webcam to html
View webcam2html.sh
#!/bin/bash
# Takes a photo and converts to a project text artifact.
# Just experimental for now.
set -euo pipefail
THISDIR="$(dirname "$0")"
#shellcheck disable=SC1091
source "$THISDIR/.env"
@mikeslattery
mikeslattery / git-syncr
Last active February 25, 2024 20:23
Git Directory Synchronizer
View git-syncr
#!/bin/bash
help() { cat<<HELP
git-syncr - git worktree synchronizer
Usage: git syncr <command>
COMMANDS:
create <path> [<branch>]
Create new worktree at <path> forked from current directory.
@mikeslattery
mikeslattery / .vimrc
Last active February 23, 2023 20:19
Beginner's Minimal Vim Config
View .vimrc
" This is a beginners .vimrc or init.vim file
" with sane defaults so you can be productive at the start.
" Not designed to work with Neovim.
" Sane defaults.
source $VIMRUNTIME/defaults.vim
set mouse=a " Enable mouse
set clipboard+=unnamed,unnamedplus " Use desktop's clipboard
set hidden " Allow switch buffers if current not saved
set noswapfile autoread " Swap file annoyance. Use git.
@mikeslattery
mikeslattery / airplay-client.sh
Last active October 17, 2021 13:26
An attempt at an airplay client
View airplay-client.sh
#!/bin/bash
# Screen cast your desktop to Apple TV (airplay).
# Usage: airplay-client <server-address> <local-address>
# Untested. Likely doesn't work. Airplay V1 only.
if [[ "$SERVER_PORT" == "7000" ]]; then
# We are the cgi script.
echo 'Content-Type: video/h264'
@mikeslattery
mikeslattery / gvim-ide-intg.md
Last active January 26, 2024 14:02
How to loosely integrate IdeaVim and gVim
View gvim-ide-intg.md

This will allow you to switch between a Jetbrains IDE and gVim at the same file/line/column by hitting <leader>i. Hit <leader><leader>i to start gVim (once).

I've also done this with terminal Vim, but it's much more complex and varies depending on your environment (OS, DE, multiplexers, terminal).

Steps:

Install gVim and the IdeaVim plugin

In IDE: Settings > Build,Execution,Deployment > check "Allow unsigned requests"

@mikeslattery
mikeslattery / ssh2config.sh
Last active April 27, 2023 12:11
Convert shell history or CLI args into ~/.ssh/config format.
View ssh2config.sh
#!/bin/bash
ssh2append() {
ssh -G "$@" | sed -n 's/^hostname /Host /p'
comm -23 <(ssh -G "$@" 2>/dev/null | sort) <(ssh -G . 2>/dev/null | sort) | sed 's/^/ /'
# This loop+if is for remote command, -N, -W as -G lacks support
while getopts '1246AaCfGgKkMNnqsTtVvXxYyB:b:c:D:E:e:F:I:i:J:L:l:m:O:o:p:Q:R:S:W:w:' opt; do
#shellcheck disable=SC2254
case "$opt" in
@mikeslattery
mikeslattery / rt-clip.sh
Last active August 1, 2020 02:12
Markdown to Clipboard
View rt-clip.sh
#!/bin/bash
# Converts markdown format to clipboard in html format.
# Requres Wayland, pandoc, and wl-clipboard.
# Usage:
# rt-clip - Copy from stdin
# rt-clip <file> Copy from a file
# rt-clip Copy from clipbaord
if [[ "$1" == "-" ]]; then shift; cat
@mikeslattery
mikeslattery / alpine-chroot.sh
Created April 30, 2020 15:37
Create a temporary Alpine chroo
View alpine-chroot.sh
#!/bin/sh
# Create and launch an alpine chroot
# If /tmp is not tmpfs, change this to /dev/shm
rootfs=/tmp/alpine
set -eu
if ! [ -f $rootfs/etc/resolv.conf ]; then
if ! [ -f ~/Downloads/alpine.tar.gz ]; then
curl -Lf -o ~/Downloads/alpine.tar.gz http://dl-cdn.alpinelinux.org/alpine/v3.11/releases/x86_64/alpine-minirootfs-3.11.6-x86_64.tar.gz
@mikeslattery
mikeslattery / init.gradle
Last active May 1, 2020 19:17
Build gradle projects to RAM
View init.gradle
// This goes in ~/.gradle/init.d/tmpfs.gradle
def ramdir='/tmp/gradle'
gradle.projectsLoaded {
rootProject.allprojects {
buildDir = "${ramdir}${project.path}/build"
//println "${project.name}.buildDir = ${buildDir}"
}