Skip to content

Instantly share code, notes, and snippets.

@dnoyes
dnoyes / gist:1653345
Created January 21, 2012 17:23
serving uploaded MEDIA
# settings.py
import os
VENV_ROOT = os.environ.get('VIRTUAL_ENV', '')
MEDIA_ROOT = VENV_ROOT + '/media/'
MEDIA_URL = '/media/'
# urls.py
urlpatterns = patterns('',
# ...
@dnoyes
dnoyes / gist:1674741
Created January 25, 2012 04:31
creating a team (django)
# teams/urls.py
urlpatterns = patterns('teams.views',
...
url(r'^create/?$', 'create'),
...
)
# teams/models.py
class Team(models.Model):
@dnoyes
dnoyes / gist:1881280
Created February 22, 2012 04:12
How do I make multi-[blah] fields ?
# models (old)
class Team(models.Model):
# ...
attachments = models.ManyToManyField(Attachment, blank=True,
related_name="%(app_label)s_%(class)s_attachments")
images = models.ManyToManyField(ImageAttachment, blank=True,
related_name="%(app_label)s_%(class)s_images")
links = models.ManyToManyField(Link, blank=True,
related_name="%(app_label)s_%(class)s_links")
@dnoyes
dnoyes / gist:1889375
Created February 23, 2012 02:39
html5 audio
<script>
var a = new Audio();
var sources = [
'topsecret1.wav',
'topsecret2.wav',
'topsecret3.wav'];
function playSound() {
var i = Math.floor(Math.random()*3);
a.pause();
@dnoyes
dnoyes / gist:1889579
Created February 23, 2012 03:00
html5 audio
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var a = new Audio();
var sources = [
'http://www.pacdv.com/sounds/fart-sounds/fart-2.wav',
'http://www.pacdv.com/sounds/fart-sounds/fart-3.wav',