Skip to content

Instantly share code, notes, and snippets.


Cal Leeming foxx

View GitHub Profile
def get_video_info(path):
"""Uses ffmpeg to determine information about a video. This has not been broadly
tested and your milage may vary"""
from decimal import Decimal
import subprocess
import re
process = subprocess.Popen(['/usr/bin/ffmpeg', '-i', path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
stdout, stderr = process.communicate()
class dict_as_class(dict):
"""Proper replacement for UserDict
Allows a dictionary to be used like a class. Really messy, thrown
together in a few minutes as a quick replacement, will probably
tidy this up later"""
def __setattr__(self, k, v):
if k in self.keys():
View gist:6048955
# default sub orders before first sub end
with patch_today(2013, 1, 1, 1, 1, 1) as pt:
i = UserSubscription.objects.create_orders()
self.assertEquals(len(i['orders_created']), 0)
# default sub orders after first sub end
with patch_today(2013, 1, 6, 1, 1, 1) as pt:
# create
i = UserSubscription.objects.create_orders()
self.assertEquals(len(i['orders_created']), 2)
View gist:d4ce9e71c6860650d7af
import os
import sys
# temp assign
_files = {}
import binascii
View gist:b36138811f61305ffc66
import random
from pprint import pprint as p
CHOICES = ['G', 'G', 'G', 'G', 'B', 'B']
foxx /
Last active Aug 29, 2015
Stopwatch Calculator
A stopwatch records lap times as strings of the form "MM:SS:HS"
MM = minutes; SS = seconds; and HS = hundredths of a second.
Write a function that accepts two lap times and calculates their average,
returning the result in the same string format.
Input: "00:02:20" and "00:04:40"
Output: "00:03:30"
#!/usr/bin/env python
import re
import datetime
import smtplib
import itertools
from email.mime.text import MIMEText
class ScanAuthLog(object):
foxx /
Last active Aug 29, 2015
Browserify RCE Vulnerability (<= 4.2.0)
Browserify POC exploit
To run, just do:
$ python > exploit.js
foxx / gist:1968fe19f759e608452a
Created Nov 27, 2014
Django partial forms mixin (alpha as fuck)
View gist:1968fe19f759e608452a
class FormFieldQuerySetMixin(object):
Adds support for changing RelatedField queryset
easily without having to patch __init__.
def get_FIELDNAME_queryset(self):
foxx / jquery.togglr.js
Created Dec 1, 2014
Element toggle for jQuery
View jquery.togglr.js
(function (factory) {
// loader from
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else {
// Browser globals
}(function ($) {