Skip to content

Instantly share code, notes, and snippets.

# .zshrc
# created by tkaemming on 2009-04-08
alias lstree="ls -R | grep \":$\" | sed -e 's/:$//' -e 's/[^-][^\/]*\//–/g' -e 's/^/ /' -e 's/-/|/'"
export PATH="/usr/local/php5/bin:/usr/local/mysql/bin:$PATH"
autoload colors zsh/terminfo
if [[ "$terminfo[colors]" -ge 8 ]]; then
colors
@tkaemming
tkaemming / jquery.inlineformset.js
Created June 17, 2009 19:53
Simple inlineformset plugin for jQuery and Django. This is a work in progress and not ready for a production environment, but a good starting point for forks to add additional functionality.
;(function($){
$.inlineformset = {
defaults: {
extra: 3,
formSelector: '.form',
formsetSelector: '.formset',
hideOnDeletion: true,
},

Creating Video Thumbnails with FFmpeg

Assuming you have FFmpeg (http://ffmpeg.org/) installed, you should be able to run the following command. (It helps to have ffmpeg on your path, or call it absolutely from your script.)

ffmpeg -y -i ./path/to/video.mpg -f mjpeg -ss 00:00:05 -vframes 1 ./path/to/thumbnail.jpg

Hints:

  • The -f flag forces the output to "mjpeg". You can view a list of available formats by with "ffmpeg -formats".
  • The -ss flag denotes the position in the video (HH:MM:SS[.xxx] format). I'm sure there's a way to get the total length of the video (if you're doing video conversions before this, you should be able to get it by parsing STDERR).
from calendar import timegm
from datetime import datetime
from rfc822 import parsedate
from urllib import urlencode
from urllib2 import urlopen
from django import template
from django.utils import simplejson
register = template.Library()
(function ($) {
$.fn.defaultValue = function (defaultValue) {
return this.each(function (i) {
var currentField = $(this);
// Only apply the default value to text, password or textareas.
if (currentField.is(':not(input:text)') &&
currentField.is(':not(input:password)') &&
currentField.is(':not(textarea)')) {
return;
<?php
function get_month_range($start_date, $end_date)
{
if (!is_int($start_timestamp)) :
$start_timestamp = strtotime($start_date);
if ($start_timestamp === false) :
throw new Exception("Invalid value provided for the start date!");
endif;
endif;
class PhoneNumberMultiWidget(forms.MultiWidget):
def __init__(self, attrs=None):
self.widgets = (
forms.TextInput(attrs={'size': 3, 'maxlength': 3, 'class': 'areacode'}),
forms.TextInput(attrs={'size': 3, 'maxlength': 3, 'class': 'exchange'}),
forms.TextInput(attrs={'size': 4, 'maxlength': 4, 'class': 'lastfour'})
)
super(PhoneNumberMultiWidget, self).__init__(self.widgets, attrs)
def format_output(self, rendered_widgets):
import os
import tempfile
from compress.filter_base import FilterBase
class LessCSSFilter(FilterBase):
"""
A filter for django-compress that adds LessCSS support.
Based off of "compress.filters.csstidy.CSSTidyFilter".
Supported settings:
<?php
// You'll want to change this to reflect the proper include path.
// I just put it in dump/ or a directory like that.
require_once '../wp-config.php';
$filename = sprintf('dump-%s.sql', time());
$file = fopen($filename, 'a');
$command = sprintf('mysqldump %s -h %s -u %s --password=%s', DB_NAME, DB_HOST, DB_USER, DB_PASSWORD);
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Open Page in Browserlab</title>
</head>