Skip to content

Instantly share code, notes, and snippets.

@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
@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 / compare_excelleris_oscar_labs.py
Last active January 4, 2016 13:39
A utility to find what labs from Excelleris are missing from OSCAR
#!/usr/bin/env python3
"""
A utility to find what labs from Excelleris are missing from OSCAR
"""
import argparse
import csv
import datetime
from operator import itemgetter
import unittest
@dgrant
dgrant / ordered_dicts_python.py
Created August 25, 2013 06:20
An ordered dict implementation in Python using a second hash map to store the order information.
#!/usr/bin/env python
import random
import operator
import time
from collections import OrderedDict
import unittest
class ordered_dict(dict):
def __init__(self):
self.order = {}