Skip to content

Instantly share code, notes, and snippets.

@ctemplin
ctemplin / Watch i3 output focus array
Created December 2, 2021 14:52
Watch i3 output focus array
watch 'jq .focus < <(i3-msg -t get_tree)'
@ctemplin
ctemplin / gist:f79261b23c15071ad6e233e976897099
Created October 19, 2021 19:45
launch Urxvt(c) and run a bash command
urxvt -e bash -i -c "<command>"
@ctemplin
ctemplin / i3 tree workspaces
Created October 17, 2021 21:29
i3 tree workspaces
i3-msg -t get_tree | jq '.nodes[1].nodes[1].nodes[] | select(.type==workspace)'
@ctemplin
ctemplin / Find identical (hardlinked) files
Created September 27, 2021 00:14
Find identical (hardlinked) files
sudo find / -ignore_readdir_race -samefile [file]
@ctemplin
ctemplin / Max RAM capacity
Last active September 11, 2021 16:02
Max RAM capacity
sudo dmidecode -t memory
@ctemplin
ctemplin / Locate directories that contain string. Example query: 'bash-completion'
Last active October 5, 2021 21:05
Locate directories that contain string. Example query: 'bash-completion'
# lists matching non-dirs too after dirs
ls -dp --group-directories-first `locate -b '\bash*completion'`
@ctemplin
ctemplin / Sort pacman packages by size.
Last active August 22, 2021 15:20
Sort pacman packages by size.
expac '%m\t%n' -H M | sort -hr | less
@ctemplin
ctemplin / recoilResetThenSetValue.js
Created August 22, 2021 12:13
Recoil selector to capture the default values of atoms and merge them with arbitrary props.
import { atom, selector, selectorFamily, snapshot_UNSTABLE } from 'recoil'
const atomDefaults = {}
export const resetThenSetValue = selector ({
key: 'resetThenSetValue',
set: ({set}, {atom, ...rest}) => {
set(atom,
(prevValue) => {
// Defaults not already stored
@ctemplin
ctemplin / xfce4-terminal-pwd.sh
Created June 30, 2015 18:37
Launch new xfce4-terminal starting in the working directory of the current xfce4-terminal or pwdx
#!/bin/bash
# Little script hack that launches a new xfce4-terminal with the
# current working directory as its default. Mimics pwdx with
# xfce4-terminal (all of whose windows share a single process for
# perfomance) by extracting the cwd from the window title. If the
# ACTIVE_WINDOW isn't a xfce4-terminal, use pwdx of the current
# window's PID.
id=$(xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}')
class_string=$(xprop -id $id | awk '/WM_CLASS\(STRING\)/' | cut -d'=' -f2 | cut -d',' -f1)