Skip to content

Instantly share code, notes, and snippets.

@mrrusof
mrrusof / swap-capslock-control.reg
Created July 13, 2019 22:22
Swap left control and caps lock in Windows.
Windows Registry Editor Version 5.00
; The hex data is in five groups of four bytes:
; 00,00,00,00,\ header version (always 00000000)
; 00,00,00,00,\ header flags (always 00000000)
; 02,00,00,00,\ # of entries (2 in this case) plus a NULL terminator line.
; Entries are in 2-byte pairs: Key code to send & keyboard key to send it.
; Each entry is in LSB, MSB order.
; 1d,00,3a,00,\ Send LEFT CTRL (0x001d) code when user presses the CAPS LOCK key (0x003a)
; 3a,00,1d,00,\ Send CAPS LOCK (0x3A) code when user presses the LEFT CTRL key (0x001d)
@mrrusof
mrrusof / start-db.sh
Created August 14, 2017 18:16
Run PostgreSQL in Docker container
docker run -d -e POSTGRES_DB=mydb -e POSTGRES_USER=myuser -e POSTGRES_PASSWORD=mypassword -p 5432:5432 --name mydb postgres:9.6.3
@mrrusof
mrrusof / .tmux.conf
Created July 16, 2017 19:34
Make C-q the prefix sequence in `tmux`.
unbind C-b
set -g prefix C-q
bind C-q send-prefix
@mrrusof
mrrusof / matrix-element.sh
Created July 4, 2017 22:41
In Bash, given a matrix, return element in given row & col
#!/bin/bash
function element { r=$1; c=$2; head -n $r | tail -n 1 | awk "{ print \$$c }"; }
# Example usage:
#
# $ echo -e "1 2 3\n4 5 6\n7 8 9" | element 2 2
# 5
# $ echo -e "1 2 3\n4 5 6\n7 8 9" | element 2 3
# 6
@mrrusof
mrrusof / pomodoro.sh
Created December 30, 2016 02:54
Poor man's pomodoro timer for OS X (or oxymoronic pomodoro timer)
alias timesup='osascript -e "tell application (path to frontmost application as text) to display dialog \"Time is up!\" buttons {\"OK\"} with icon stop"'
alias pomodoro-regular="i=0; while [ \$i -lt 25 ]; do sleep 60; (( i = i + 1 )); echo \$i minutes elapsed; done; timesup"
alias pomodoro-break="i=0; while [ \$i -lt 5 ]; do sleep 60; (( i = i + 1 )); echo \$i minutes elapsed; done; timesup"