Skip to content

Instantly share code, notes, and snippets.

@lettertwo
lettertwo / absurl.py
Created April 27, 2011 22:35
A template tag to create an absolute URI.
from django.template import Library
from django.templatetags.future import URLNode, url
register = Library()
class AbsoluteURLNode(URLNode):
def __init__(self, view_name, args, kwargs, asvar, legacy_view_name=True):
super(AbsoluteURLNode, self).__init__(view_name,
args,
kwargs,
@danriti
danriti / gist:2869387
Created June 4, 2012 16:27
Generate user activation key for a Django user
"""
The activation key for the ``UserProfile`` will be a
SHA1 hash, generated from a combination of the ``User``'s
email and a random salt.
"""
salt = hashlib.sha1(str(random.random())).hexdigest()[:5]
email = user.email
if isinstance(email, unicode):
@unycone
unycone / sortlayers.jsx
Created March 25, 2013 12:28
This AfterEffects script sorts layers in a composition according to their in-points.
/*
* This AfterEffects script sorts layers in a composition according to their in-points.
*
* 1. Save this file as "sortlayers.jsx".
* 2. Select a target composition in project panel of your AfterEffects.
* 3. Run "sortlayers.jsx" from Menu->"File"->"Scripts"->"Run Script File".
*/
app.beginUndoGroup("Sort layers");
var item = app.project.activeItem;
if (item != null && item instanceof CompItem) {
@ruby0x1
ruby0x1 / tilt.shift.glsl
Last active February 19, 2024 02:46
Tilt shift shader, modified from something @grapefrukt gave me
// Modified version of a tilt shift shader from Martin Jonasson (http://grapefrukt.com/)
// Read http://notes.underscorediscovery.com/ for context on shaders and this file
// License : MIT
uniform sampler2D tex0;
varying vec2 tcoord;
varying vec4 color;
/*
Take note that blurring in a single pass (the two for loops below) is more expensive than separating
@need12648430
need12648430 / PokéPie
Created August 30, 2014 04:50
PokéPieChart, now with 200% more comments
import java.util.Map;
import java.util.Comparator;
import java.util.Collections;
int index = 0;
// sprite sheet
PImage pokemon;
// current pokemon sprite
PImage current;
// current pie chart
@Vestride
Vestride / encoding-video.md
Last active June 5, 2024 14:38
Encoding video for the web

Encoding Video

Installing

Install FFmpeg with homebrew. You'll need to install it with a couple flags for webm and the AAC audio codec.

brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-opus