Skip to content

Instantly share code, notes, and snippets.

@ddimick
ddimick / Dockerfile
Created Jan 3, 2021
Dockerfile to build image for govizlora/optical-breacher
View Dockerfile
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 Aug 12, 2020
One-liner to run ffsubsync against all media files in directory.
View gist:d165c090e458b035e0f0eb89f775c073
# 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 Feb 8, 2020
The usual home files.
View .gitconfig
# 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 Dec 16, 2019
Convert one or more BGP Autonomous System Number (ASN) to a list of corresponding IPv4 networks, updated to work with python3.
View asn-to-ip.py
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 Apr 23, 2020
Query NUT UPS status and output in InfluxDB Line Protocol. Use with telegraf inputs.exec.
View nut-telegraf.sh
#!/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
Runs '/sbin/zpool list -Hp' and outputs an InfluxDB-compatible JSON array. Use with telegraf inputs.exec.
View zpool_list.py
#!/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"