Skip to content

Instantly share code, notes, and snippets.

@dgrant
dgrant / update_video_tools.py
Last active December 12, 2015 06:58
This script builds the latest stable versions of x264 and ffmpeg and/or libav and builds deb packages for them (which do not replace the existing deb packages. Mine place binaries in /usr/local/bin, not /usr/bin). Limitations: -Meant for ubuntu systems. Probably works on debian just fine but I have not tested. -Builds static libraries and puts t…
#!/usr/bin/env python3
import os
import subprocess
import shutil
from os.path import join
from subprocess import call
X264 = 'x264'
@dgrant
dgrant / disk_space_checker.py
Last active December 14, 2015 22:09
I run this file in a cron job every 5 minutes. It checks whether your drives' usage has exceeded a configurable threashold, and if so, it sends an email to a configurable e-mail address.
#!/usr/bin/env python3
"""
A simple program that sends warnings when disk space on one or more hard
drives has reached a critical level
"""
from subprocess import Popen, PIPE
##############################################################
#CHANGE SETTINGS BELOW
##############################################################
@dgrant
dgrant / cpu_temp_checker.py
Last active December 14, 2015 22:09
I run this file in a cron job every 5 minutes. It checks the CPU temperature using various sensors (using the 3rd party package lm-sensors) and sends en e-mail to a configurable e-mail address if any one of the temperature exceeds are configurable threshold.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
A simple program that sends warnings when disk space on one or more hard
drives has reached a critical level
"""
import re
from subprocess import Popen, PIPE
##############################################################
@dgrant
dgrant / piano_technique_generator.py
Last active December 14, 2015 22:18
I use this to generate some scales, arpeggios, triads, chords to practice.
#!/usr/bin/env python3
"""Generate technique practice schedule"""
import argparse
import datetime
import random
ALL_TYPES = \
{'Major Scales': ["G","D","B","Bb","Eb"],
'Harmonic Minor Scales': ["E","B","G#","G","C"],
'Melodic Minor Scales': ["E","B","G#","G","C"],
@dgrant
dgrant / remove_svn_dirs.py
Last active December 14, 2015 22:18
Remove all .svn dirs recursively under the given path
#!/usr/bin/env python
"""Remove all .svn directories"""
import os
import shutil
def remove_dot_svn_dirs(root):
"""Remove all .svn directories root"""
for root, dirs, _ in os.walk(root):
for adir in dirs:
if adir == '.svn':
@dgrant
dgrant / password_map.py
Last active December 14, 2015 22:18
Generates a mapping of all letters of the alphabet to a 2-character combination of uppercase, lowercase, or digits. A great way to come up with a random password for a website.
#!/usr/bin/env python3
"""
Generate a password map
"""
import itertools
import random
from string import ascii_lowercase, ascii_uppercase
def main():
"""Main script"""
@dgrant
dgrant / gen_passwords.sh
Last active December 14, 2015 22:18
Generate random passwords
#!/bin/bash
for ((n=0;n<10;n++));
do
dd if=/dev/urandom count=1 2> /dev/null | uuencode -m -| head -n 2 | tail -n 1 | cut -c-8
done
@dgrant
dgrant / find_vcs_dirs.py
Last active December 14, 2015 22:29
Find any VCS directories in the specified path (ie. git, mercurial, svn, CVS)
#!/usr/bin/env python3
"""
Find all the VCS controlled directories in a file path
"""
import argparse
import os
EXTS = ['.git', '.hg', '.svn', 'CVS']
def find(path):
@dgrant
dgrant / create_gist_symlinks.py
Last active December 14, 2015 22:38
This script will create symlinks in specific "binpath" for all executables in sub-directories of a specified "gistpath"
@dgrant
dgrant / debian_find_orphan_files.py
Last active December 14, 2015 22:39
For debian systems, this finds all files that do not belong to a package.
#!/usr/bin/env python3
"""
Search for orphan files (files that do not belong to any package)
"""
import fnmatch
import os
import subprocess
import itertools
INCLUDES = ('/usr', '/etc', '/opt', '/lib32', '/lib64', '/sbin')