Skip to content

Instantly share code, notes, and snippets.

@jceloria
jceloria / repairMKV.sh
Created March 9, 2014 15:10 — forked from jnbt/repairMKV.sh
repairMKV.sh
#!/bin/bash
#
# Fixes MKV files to be more complient to XMBC, PLEX and other media server / players.
# Work for OSX. Needs mkvtoolnix (http://www.downloadbestsoft.com/MKVToolNix.html)
#
#####################################################################################
##
## PREFERENCES
##
@jceloria
jceloria / ini.sh
Created June 23, 2014 17:58
INI parser in pure bash4+
#!/bin/bash
CONFIG=$1
#### Assign associative arrays from ini config file: key[section]=value
while IFS='\n' read line; do
# Ignore comments and empty lines
[[ ${line} =~ (^[[:space:]]*$|^[\;x\#]) ]] && continue
# Are we a section heading?
@jceloria
jceloria / Archive.py
Created August 31, 2016 21:04
Download and create/extract different archive formats.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
################################################################################
"""
Download and create/extract different archive formats.
Copyright © 2016 by John Celoria <[REDACTED]>.
@jceloria
jceloria / adblock-dnsmasq.sh
Created August 31, 2016 21:04
Block ads using dnsmasq
#!/usr/bin/env bash
SELF=${0##*/}; SDIR=${0%/*}; PATH+=:${SDIR}
################################################################################
# Block ads using dnsmasq
#
# *REQUIREMENTS*
# The Ubiquiti router I wrote this for did not ship with a GNU coreutils
# timeout binary. I instead used a Python timeout script provided by:
# https://github.com/timwarnock/timeout.py/blob/master/timeout.py
@jceloria
jceloria / flushTransmission.py
Created August 31, 2016 21:04
Remove completed torrents in Transmission.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
################################################################################
"""
Remove completed torrents in Transmission.
Copyright © 2016 by John Celoria <[REDACTED]>.
@jceloria
jceloria / h0stz.py
Created August 31, 2016 21:04
Display host information based on application name
#!/usr/bin/env python
# -*- coding: utf-8 -*-
################################################################################
"""
Display host information based on application name
Copyright © 2016 by John Celoria <[REDACTED]>.
@jceloria
jceloria / logz_io.py
Last active August 30, 2017 22:20
logz_io.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
################################################################################
"""
Query a ES index to find patterns
Copyright © 2016
@jceloria
jceloria / container-home-assistant.service
Created March 3, 2017 15:34
home-assistant in Docker container
[Unit]
Description=home-assistant in Docker container
After=docker.service
Requires=docker.service
[Service]
TimeoutStartSec=0
Restart=always
ExecStartPre=-/usr/bin/docker stop home-assistant
ExecStartPre=-/usr/bin/docker rm home-assistant
@jceloria
jceloria / retry-ssh.sh
Last active March 27, 2017 15:11
ssh wrapper to continuously retry if unavailable
########################################################################################################################
# ssh wrapper to continuously retry if unavailable
function ssh() {
local next prev host port
for ((i=1;i<=$#;++i)); do
next=$((i+1)); [[ $((i-1)) -eq 0 ]] || prev=$((i-1))
case "${!i}" in
-p*) [[ "${!i}" =~ -p$ ]] && port=${!next} || port=${!i//-p} ;;
*@*) host=${!i##*@} ;;
-*) true ;;
@jceloria
jceloria / es.sh
Last active January 5, 2018 19:35
bash functions for ES
########################################################################################################################
# Common Elasticsearch functions
function es() {
local id=$1; shift; local cmd=$1; shift; local connect region json curl="$(type -P curl) -sL --netrc-file ~/.netrc-es"
local actions=(aliases allocation health indices nodes recovery shards settings stats clear-cache)
local regex="+(*$(IFS='|';echo "${actions[*]}"|sed 's/|/|*/g'))"
function _help() {
echo "Usage: es <id> ${regex##*+}" >&2