Skip to content

Instantly share code, notes, and snippets.

# Adjust sensitivity for logitech mouse
# xinput list
# xinput list-props 17
xinput set-prop 17 144 0.400000, 0.000000, 0.000000, 0.000000, 0.400000, 0.000000, 0.000000, 0.000000, 1.000000
# Scroll speed
xinput set-prop 17 'Evdev Scrolling Distance' 1.9 1 1
cryptsetup luksOpen /dev/nvme0n1p2 cryptkey
cryptsetup luksOpen --key-file=/dev/mapper/cryptkey /dev/nvme0n1p3 cryptswap
cryptsetup luksOpen --key-file=/dev/mapper/cryptkey /dev/nvme0n1p4 cryptroot
#+END_SRC
Then for a not fun bit, matching entries in =/dev/disk/by-uuid/= to
the partitions we want to mount where. Running ~ls -l
/dev/disk/by-uuid/~ shows which devices have which UUIDs. To determine
what =dm-1= and =dm2=, I ran ~ls -la /dev/mapper~:
function print_fequency() {
(echo "Package Frequency" ; \
cat | tr ' ' '\n' | sort | uniq -c | awk '{print $2"\t"$1}') | column -t
}
# https://github.com/dominikh/go-unused
function find_unused() {
unused -exported "${1}/..."
}
@jason-riddle
jason-riddle / req.sh
Last active October 21, 2019 00:38
Snippet to ensure command is available #complete
#!/usr/bin/env bash
function req() {
what=$1
which "${what}" >/dev/null || { echo "${what} required"; exit 1; }
}
req curl
req gcc
@jason-riddle
jason-riddle / maxProfit.py
Last active October 21, 2019 00:40
Interview Practice #interviewing #complete
#!/usr/bin/env python3
"""
I have an ordered historical list of daily prices of quizlet coin - the hot new cryptocurrency.
[100, 50, 120, 100, 300, 250, 1]
What is the best profit I could have made from 1 purchase and 1 sale of Quizlet Coin?
@jason-riddle
jason-riddle / gist:d2bf6de8b25a70c05a6570232da9d0c9
Last active October 21, 2019 00:44
Snippet using tcpdump to listen on an http port #snippet #complete
# Ref: https://github.com/SergK/cheatsheat-tcpdump/blob/master/tcpdump_advanced_filters.txt
# Ref: http://edoceo.com/cli/tcpdump
HTTP_PORT="8444"
HTTP_FILTER="(((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)"
tcpdump -i any -s 0 -A "tcp port $HTTP_PORT and $HTTP_FILTER"
@jason-riddle
jason-riddle / find_examples
Last active October 21, 2019 01:24
Examples using find #snippet #complete
# More on Performance
# Ref: https://unix.stackexchange.com/questions/41740/find-exec-vs-find-xargs-which-one-to-choose
# Ref: https://www.everythingcli.org/find-exec-vs-find-xargs
# Find all files, including hidden, that match the name "config"
find . -type f -name config
# Find all files that contain the word "git" in the filename
find . -type f -iname '*git*'
@jason-riddle
jason-riddle / burn_sdcard.sh
Last active October 21, 2019 01:37
Burn to sdcard using dd and pv #guide #complete
SD_CARD="/dev/disk1000"
LOCAL="~/Desktop/2013-09-25-wheezy-raspbian-minimal.img"
# First, unmount the disk
diskutil unmountDisk ${SD_CARD}
# If you are writing from SD card to Mac, calculate the number of bytes to skip as well as the size to pipe to pv.
# 5785600 bytes (count) * 512 (default bs) = 2962227200 bytes == 2825 Megabytes
dd if=${SD_CARD} count=5785600 | pv -s 2825M | dd of=${LOCAL} count=5785600
@jason-riddle
jason-riddle / curl_examples.sh
Created October 21, 2019 01:39
Examples for Curl #snippet #complete
# Robust curl command to retry, timeout, and save the output to a file
curl --silent --show-error \
--location --max-redirs 3 \
--retry 3 --retry-connrefused --retry-delay 2 \
--max-time 30 \
"$url"
@jason-riddle
jason-riddle / dmesg_to_utc.sh
Last active October 21, 2019 01:58
Convert dmesg timestamps to UTC format
#!/bin/bash
# Translate dmesg timestamps to human readable format
# desired date format
date_format="%Y-%m-%dT%H:%M:%SZ"
# [ 3.469072] EXT4-fs (xvda1): mounted filesystem with ordered data mode. Opts: (null)
# [ 3.483769] dracut: Remounting /dev/disk/by-label/\x2f with -o noatime,ro
# [ 3.495019] EXT4-fs (xvda1): mounted filesystem with ordered data mode. Opts: (null)
# [ 3.506417] dracut: Mounted root filesystem /dev/xvda1