Skip to content

Instantly share code, notes, and snippets.

# /usr/bin/env python
#
# Author: Red5d
#
# Description: Extract and run OCR on subtitles from a PGS-format .sup file.
#
# Example Usage: python sup2srt.py bd_subtitles.sup bd_subtitles.srt
#
# Dependencies:
# - pytesseract
@Red5d
Red5d / home-assistant_nodered_mqtt.yml
Created November 23, 2017 17:18
docker-compose file for setting up homeassistant, node-red, and mqtt services
version: "3"
services:
homeassistant:
image: homeassistant/home-assistant
ports:
- "8123:8123"
- "3218:3218"
volumes:
- /opt/docker/home-assistant:/config
- /etc/localtime:/etc/localtime:ro
@Red5d
Red5d / ghfeed-updates.py
Last active February 2, 2016 18:02
Python script to show the latest updates to an awesome-<whatever> list repo.
#! /usr/bin/env python
# Example: python ghfeed-updates.py vinta/awesome-python
import sys, re, requests
repo = sys.argv[1]
token="<personal GitHub token here>"
if token == "<personal GitHub token here>":
print "Add your personal GitHub token to the 'token=' line in the script."
@Red5d
Red5d / dockerps
Last active March 14, 2018 03:12
Python version of the "docker ps" command that rearranges the output to fit on a smaller terminal window a little better.
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from docker import Client
import sys
reload(sys)
sys.setdefaultencoding('utf8')
c = Client(base_url='unix://var/run/docker.sock')
@Red5d
Red5d / memegen
Created July 14, 2015 21:41
CLI python tool for using the http://memegen.link/ meme generator service.
#! /usr/bin/env python
# Author: Red5d
# Client tool for the http://memegen.link/ service.
# Run with no parameters for help.
import json, sys, urllib
if len(sys.argv) < 2:
@Red5d
Red5d / pbis
Created March 26, 2015 15:22
Ansible module to manage the PBIS config
#! /usr/bin/env python
# Author: Red5d
# Date: 8/11/2014
#
# Description: Ansible module to manage the PBIS config.
#
# Examples:
#
# Get all current PBIS config settings and put them into the pbis_output variable:

Keybase proof

I hereby claim:

  • I am red5d on github.
  • I am red5d (https://keybase.io/red5d) on keybase.
  • I have a public key whose fingerprint is 2CB6 B1AA AD59 0C00 7226 33E7 C9A4 29E2 A9F7 EF57

To claim this, I am signing this object:

#! /bin/bash
# Author: Red5d
# Commands adapted from: https://www.digitalocean.com/community/tutorials/how-to-install-an-ssl-certificate-from-a-commercial-certificate-authority
if [ $(which openssl) -eq "" ];then
echo "Can't find openssl command. Exiting..."
exit 1
fi
function mempercent {
total=$(free -m | sed -n '2p' | awk '{print $2}')
used=$(free -m | sed -n '3p' | awk '{print $4}')
echo $(echo $(echo 'scale=2;'$used'/'$total'' | bc)*100 | bc | cut -d'.' -f1)"% memory usage (${used}M Used / ${total}M Total)"
}
function systemload {
loadAverage=$(uptime | cut -d',' -f4 | grep -o "[0-9]*\.[0-9]*$")
processors=$(cat /proc/cpuinfo | grep processor | tail -n1 | awk '{ print $3 }')
let processors=$processors+1