Skip to content

Instantly share code, notes, and snippets.

jclosure /
Last active Mar 23, 2022
Using watchdog to inspect all changes for a dir + pattern. Useful for seeing all activity during debugging inotify handlers.
import logging
import os
import time
import traceback
from watchdog.observers import Observer
from import PatternMatchingEventHandler
MAP_DATA_DIR = "/tmp/foo"
jclosure / my-clipboard-plugin.zsh
Created Feb 16, 2022
Perfect blend of system clipboard with zsh killring
View my-clipboard-plugin.zsh
cutbuffer () {
emulate -L zsh
zle kill-region
zle set-mark-command -n -1
killring=("$CUTBUFFER" "${(@)killring[1,-2]}")
if which clipcopy &>/dev/null; then
printf "%s" "$CUTBUFFER" | clipcopy
echo "clipcopy function not found. Please make sure you have Oh My Zsh installed correctly."
jclosure / history_tracking.sql
Created Jan 31, 2022
Automatic history tracking in postgres.
View history_tracking.sql
-- create a separate schema to hold our history table
CREATE TABLE IF NOT EXISTS logging.t_history (
id serial,
tstamp timestamp DEFAULT now(),
schemaname text,
tabname text,
operation text,
who text DEFAULT current_user,
new_val json,
jclosure / logstash.conf
Created Jan 25, 2022
Logstash parsing json string fields, merging, and replacing event
View logstash.conf
# test as follows:
# 1. start logstash:
# logstash -f ~/logstash.conf --config.reload.automatic
# 2. send it data:
# echo '{"container": "/spiff", "bleh": "blah"}' | nc localhost 6060
input {
tcp {
jclosure / Makefile
Created Jan 8, 2022
modify yaml on the fly as part of a make task
View Makefile
UNAME := $(shell uname)
# assuming a yaml like this:
# main:
# device: 21
jclosure /
Created Sep 27, 2021 — forked from ReSTARTR/
ZeroMQ sample in Go and Python. (with MonitoredQueue)


  • zeromq: stable 3.2.2
  • go: 1.0.3
    • gozmq: zmq_3_x
  • python: 2.7.3
    • pyzmq: 13.0.2


jclosure / init.el
Created Jul 14, 2021
Emacs set font-size based on monitor size.
View init.el
;; set some defaults
(setq my-font-name "monospace")
(setq my-font-size 10)
;; this method seems to work on gui systems only
(when window-system
(if (eq system-type 'darwin)
(setq my-font-name "Meslo"))
(if (eq system-type 'gnu/linux)
(setq my-font-name "FiraCode"))
jclosure /
Created Apr 6, 2021
Generator for flattening nested dicts into a lists of path parts and value at the end
def dict_generator(indict, pre=None):
pre = pre[:] if pre else []
if isinstance(indict, dict):
for key, value in indict.items():
if isinstance(value, dict):
for d in dict_generator(value, pre + [key]):
yield d
elif isinstance(value, list) or isinstance(value, tuple):
for v in value:
for d in dict_generator(v, pre + [key]):

There are certain files created by particular editors, IDEs, operating systems, etc., that do not belong in a repository. But adding system-specific files to the repo's .gitignore is considered a poor practice. This file should only exclude files and directories that are a part of the package that should not be versioned (such as the node_modules directory) as well as files that are generated (and regenerated) as artifacts of a build process.

All other files should be in your own global gitignore file. Create a file called .gitignore in your home directory and add anything you want to ignore. You then need to tell git where your global gitignore file is.


git config --global core.excludesfile ~/.gitignore


git config --global core.excludesfile %USERPROFILE%\.gitignore