Skip to content

Instantly share code, notes, and snippets.

View djds23's full-sized avatar

Dean Silfen djds23

View GitHub Profile
@djds23
djds23 / rename.py
Last active December 28, 2015 23:49
Rename footage '.dpx' files from c500 footage if cables are switched leaving the camera.
'''
This is a script to fix c500 footage that got mixed up.
If the SDI cables are switched leaving the camera entering the recorder
then file names will be incorrect. Files that should be numbed even are odd,
and files that are odd should be even.
Luckily those files are also separated into two different folders.
**Run this script in each folder separately before merging the footage **
@djds23
djds23 / cracklepop.py
Created December 1, 2013 16:09
CracklePop
for i in range(1,100):
response = ''
if i%3==0:
response += 'Crackle'
if i%5==0:
response += 'Pop'
if i%5 != 0 and i%3 != 0:
response += str(i)
print response
@djds23
djds23 / extemail.py
Last active August 29, 2015 13:56
Parses text to find emails, accepts text files or raw input
import re
import sys
# Email regex taken from django/django
# https://github.com/django/django/blob/master/django/core/validators.py#L137
email_re = re.compile(
r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*" # dot-atom
r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-011\013\014\016-\177])*"' # quoted-string
r')@(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?$', re.IGNORECASE)
@djds23
djds23 / extractid.py
Created February 26, 2014 00:04
pull all 9 digit id numbers out of a text file
import re
with open('ids.txt', 'r') as f:
data = f.read()
sort = [ anid for and in re.findall(r'[0-9]{9}', data)]
with open('newids.txt', 'w') as nl:
for anid in sort:
nl.write(anid)
nl.write('\n')
@djds23
djds23 / routes.py
Created March 4, 2014 19:00
tutorial for flask-socketio
from flask import Flask, render_template
from flask.ext.socketio import SocketIO, emit
app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret!'
socketio = SocketIO(app)
@app.route('/')
def index():
return render_template('index.html')
@djds23
djds23 / match_videos.py
Created April 24, 2014 21:16
Instead of gathering videos by hand, this script will take a csv with video descriptions, and a json file of the database, then download the videos that match.
import csv
import sets
import json
import string
import urllib
import operator
from datetime import datetime
with open('master.csv', 'rb') as f: #csv from client with celeb name and description
@djds23
djds23 / Crouton Copypasta
Last active August 29, 2015 14:01
Crouton scripts for Chrome OS
##**FOR PIXEL**##
#With precise because LTS means LTS, XFCE works well with the high dpi and is simple to config
sh -e ~/Downloads/crouton -t xfce,xorg,audio,touch,keyboard,gtk-extra,extension,core,cli-extra,chrome -r precise -n REPLACE_WITH_NAME
#Once Trusty is supported, unity to try out
sh -e ~/Downloads/crouton -t unity,xorg,audio,touch,keyboard,gtk-extra,extension,core,cli-extra,chrome -r trusty -n REPLACE_WITH_NAME
##**FOR SAMSUNG ARM CHROMEBOOK**##
@djds23
djds23 / sift_mrs.py
Last active August 29, 2015 14:02
Sift through MPEG transport footage from prosumer cameras and convert to 1/10th the size for playback
import os
from subprocess import call
root = "."
def crawl_folder(root):
'''crawl filesystem and apply encoding function'''
root = os.walk(root) #walk filesystem, return tuples
for root, dirs, files in root: #for each tuple, check for streamers dict, create dict and encode
for filename in files:
@djds23
djds23 / dp172.py
Created July 23, 2014 00:34
The answer for Daily Programmer #172
from string import uppercase
#Build fonts from txt file
with open('font.txt', 'rb') as fonts:
letters = fonts.readlines()
font = {}
for line in letters:
if line[0] in uppercase:
line = line.translate(None, '\n')
font[line] = []
@djds23
djds23 / anti_patterns.py
Last active August 29, 2015 14:14
anti-patterns in object oriented programming
"""
This is a demonstration of an anti-pattern I have come across in other people's
code that frustrates me. This is only meant as a silly learning exercise and
nothing more.
"""
def bad_config(some_object):
try:
data = some_object.data_field.get_data()
except NoDataError:
some_object.has_data = False