Skip to content

Instantly share code, notes, and snippets.

@dgrant
dgrant / ogg2mp3.py
Created September 2, 2014 07:30
Convert .ogg files to .mp3
#!/usr/bin/env python
"""Convert ogg files to mp3"""
from optparse import OptionParser
import tempfile
import os
import subprocess
class CommandException(Exception):
"""Exception that is raised if calling an external command fails"""
def __init__(self, command):
@dgrant
dgrant / exist_check.py
Created September 2, 2014 07:28
Script to verify that destination is not mising any files from source Usage: exist_check.py <src> <dest>
#!/usr/bin/python
"""
Script to verify that destination is not mising any files from source
Usage: exist_check.py <src> <dest>
"""
import os
import sys
FILE_TYPES = ['.NEF', '.JPG', '.MTS']
@dgrant
dgrant / m4a2mp3.sh
Created September 2, 2014 07:26
Convert .m4a to .mp3
#!/bin/bash
#
# Dump m4a to wav (first step in conversion)
mkdir -p output
for i in *.mp3
do
mplayer -ao pcm:file="output/${i%.mp3}.wav" "$i"
done
@dgrant
dgrant / id3_remove_all_tags.py
Created September 2, 2014 07:23
Script to remove all id3 tags from a file
#!/usr/bin/env python
"""Remove all id3 tags"""
import sys
import eyeD3
def main():
"""main method"""
tag = eyeD3.Tag()
for afile in sys.argv[1:]:
tag.link(afile, eyeD3.ID3_V1)
@dgrant
dgrant / convertall_ps2eps.sh
Created September 2, 2014 07:22
Script to convert *.ps files to *.pdf and *.eps files for inclusion in Latex documents
#!/bin/sh
#Script to convert *.ps files to *.pdf and *.eps files for inclusion in Latex documents
ONE=1
FOUND=0
numberEPS=0
numberPDF=0
for file #Traverse all files in directory.
do
@dgrant
dgrant / id3_remove_all_tags.py
Last active August 29, 2015 14:20
Remove all id3 tags from an mp3
#!/usr/bin/env python
"""Remove all id3 tags"""
import sys
import eyeD3
def main():
"""main method"""
tag = eyeD3.Tag()
for afile in sys.argv[1:]:
tag.link(afile, eyeD3.ID3_V1)
@dgrant
dgrant / gb
Created April 27, 2015 01:13
Git batch (run git commands in all sub-directories)
#!/usr/bin/env python3
import os
import sys
import subprocess
commandMap = {
# Key(command) => Value(Tuple(list of commands to run, whether to ask for confirmation))
'rebase': (['git', 'svn', 'rebase'], False),
'diff': (['git', 'diff'], False),
'dcommit': (['git', 'svn', 'dcommit'], False),
@dgrant
dgrant / encrpytPass.pl
Created April 27, 2015 01:12
Generate a difficult password
#!/usr/bin/perl
srand (time());
my $randletter = "(int (rand (26)) + (int (rand (1) + .5) % 2 ? 65 : 97))";
my $salt = sprintf ("%c%c", eval $randletter, eval $randletter);
my $plaintext = shift;
my $crypttext = crypt ($plaintext, $salt);
print "${crypttext}\n";
@dgrant
dgrant / convertAllps2eps.sh
Created April 27, 2015 01:11
Script to convert *.ps files to *.pdf and *.eps files for inclusion in Latex documents
#!/bin/sh
#Script to convert *.ps files to *.pdf and *.eps files for inclusion in Latex documents
ONE=1
FOUND=0
numberEPS=0
numberPDF=0
for file #Traverse all files in directory.
do
@dgrant
dgrant / photo_verify.py
Created April 27, 2015 01:10
Script to verify that destination is not mising any photos from source
#!/usr/bin/python
""" Script to verify that destination is not mising any files from source """
import os
import sys
FILE_TYPES = ['.NEF', '.JPG', '.MTS']
def get_all_files(path, filters=()):
"""
Iterates over all files in path