Skip to content

Instantly share code, notes, and snippets.

View saulshanabrook's full-sized avatar
🏊

Saul Shanabrook saulshanabrook

🏊
View GitHub Profile
@saulshanabrook
saulshanabrook / Convert Movies.py
Created January 22, 2012 20:04
Converts, imports, and then removes downloaded video files in a folder, and its subfolders, into Python.
import os
from os.path import join
from subprocess import call
source_directory = '/Users/ygbhygb/Documents/Torrents/To Be Converted'
output_directory = '/Users/ygbhygb/Music/iTunes/iTunes Media/Automatically Add to iTunes'
video_endings = ['.avi', '.mkv']
hb_options = '--preset="universal"'
hbcli_path = '/Applications/HandBrakeCLI'
@saulshanabrook
saulshanabrook / .gitignore
Created July 6, 2012 19:39
Analyze Unison log, and send email of changed files
unison.log.old
unison.log
@saulshanabrook
saulshanabrook / example.py
Created July 16, 2012 18:14
django-arbitrage
# Note: this isn't python. It just has some syntax highlighting to make it more readable
# First pair is stocks x, y with a difference of z (ex. 60, 80 with a difference of 20)
x + z == y # 80 - 20 = 60
z == y - x # 20 = 80 - 60
# Buy smaller (x), sell larger (y)
balance == -(x + (100 - y)) # -(60 + (100 - 80))
== -(x + 100 - y) # -(60 + 100 - 80)
== -(-(y - x) + 100 ) # -(-(20 - 60) + 100))
@saulshanabrook
saulshanabrook / .gitignore
Created September 4, 2012 01:55
Test Project for issue #134 on rq
*.pyc
{
"close_windows_when_empty": true,
"color_scheme": "Packages/Tomorrow Color Schemes/Tomorrow.tmTheme",
"create_window_at_startup": false,
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"find_selected_text": true,
"fold_buttons": false,
"folder_exclude_patterns":
[
@saulshanabrook
saulshanabrook / save_images.py
Created October 5, 2013 13:59
Create a range of JPEG image sizes and save them to the disk. I wrote this to test my image uploading and processing capabilities for https://github.com/saulshanabrook/django-canadanewyork
import os
from PIL import Image
IMAGE_SIZES = range(500, 20000, 2000)
JPEG_SAVE_QUALITY = 100
DIRECTORY = '~/Desktop/temp/'
COLOR = 'red'
# Included in LaTeX document, but also I put it here for better code highlighting
import math
import operator
import itertools
import numpy
def polar_to_cartesian(point):
r, theta = point
@saulshanabrook
saulshanabrook / README.md
Last active August 29, 2015 13:57
Artwork Names and Descriptions from PP

For my art history class, my teacher gave me a large PP with a slide for each artwork we needed to learn, so that I could use upload the images plus the artwork identifications and classifications to Memrise for virtual study cards.

I grew tired of copying the two lines from each slide, so I decided to try to parse the PP in python to export a list of artwork IDs and classifications. For example, here El Greco I wanted the output to be El Greco: Mannerism.

I found out that a .ppx file is really just a .zip, so once I extracted the PP it was easy to find the slide files, which were all .xml.

https://asciinema.org/a/8098

@saulshanabrook
saulshanabrook / README.md
Last active August 29, 2015 13:57
Prolific Genetic Programers
from collections import namedtuple
Parents = namedtuple('Parents', ['mother', 'father'])
from itertools import zip_longest
from collections import Counter, abc
class FrozenCounter(Counter):
'''