Skip to content

Instantly share code, notes, and snippets.

# vim:ft=zsh ts=2 sw=2 sts=2
#
# agnoster's Theme - https://gist.github.com/3712874
# A Powerline-inspired theme for ZSH
#
# # README
#
# In order for this theme to render correctly, you will need a
# [Powerline-patched font](https://github.com/Lokaltog/powerline-fonts).
# Make sure you have a recent version: the code points that Powerline
@ddimick
ddimick / Dockerfile
Created January 3, 2021 05:00
Dockerfile to build image for govizlora/optical-breacher
FROM node:current-alpine
EXPOSE 1234
WORKDIR /home/node/app
RUN apk --no-cache add git \
&& chown node:node /home/node/app
USER node
@ddimick
ddimick / gist:d165c090e458b035e0f0eb89f775c073
Last active August 12, 2020 20:54
One-liner to run ffsubsync against all media files in directory.
# assumes .mkv media format and existing subtitles end in .en.srt
for f in ./*.mkv; do media=$(basename -s .mkv ${f}); $(ffs ${media}.mkv -i ${media}.en.srt --overwrite-input); done
# improved version that handles directory recursion
find . -type f -name '*.mkv' -print0 | while IFS= read -r -d '' file; do episode=$(echo -en ${file} | sed 's/\.[^.]*$//'); echo -en ${episode}; done
@ddimick
ddimick / .gitconfig
Created February 8, 2020 04:20
The usual home files.
# This is Git's per-user configuration file.
[user]
# Please adapt and uncomment the following lines:
name = Doug Dimick
email = doug@dimick.net
@ddimick
ddimick / asn-to-ip.py
Last active December 16, 2019 20:24
Convert one or more BGP Autonomous System Number (ASN) to a list of corresponding IPv4 networks, updated to work with python3.
import socket
import re
## https://tools.ietf.org/html/rfc3912
def whois_request(domain, server, port=43):
_sock=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
_sock.connect((server, port))
_sock.send(domain.encode('utf-8'))
_result=""
while True:
@ddimick
ddimick / nut-telegraf.sh
Last active July 19, 2023 12:17
Query NUT UPS status and output in InfluxDB Line Protocol. Use with telegraf inputs.exec.
#!/bin/bash
#
# Query NUT UPS status and output in InfluxDB Line Protocol
#
# Usage: ups.sh upsname[@hostname[:port]]
# (same as `upsc`, see https://networkupstools.org/docs/man/upsc.html)
# Sample telegraf.conf config snippet.
#[[inputs.exec]]
# commands = [
@ddimick
ddimick / zpool_list.py
Created May 29, 2019 15:03
Runs '/sbin/zpool list -Hp' and outputs an InfluxDB-compatible JSON array. Use with telegraf inputs.exec.
#!/usr/bin/env python
# Runs '/sbin/zpool list -Hp' and outputs an InfluxDB-compatible JSON array. Use with telegraf inputs.exec.
# Sample telegraf.conf config snippet.
# [[inputs.exec]]
# commands = [
# "/usr/local/bin/zpool_list.py"
# ]
# data_format = "influx"