This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
import reversion | |
from reversion.models import Revision | |
from django.db import transaction | |
from django.db.models.signals import m2m_changed | |
class M2MRevisionManager(reversion.revisions.RevisionManager): | |
def register(self, model=None, adapter_cls=reversion.VersionAdapter, **field_overrides): | |
m2m_fields = model._meta.local_many_to_many | |
for f in m2m_fields: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Procfile | |
requirements.txt | |
runtime.txt | |
manage.py | |
project_name/ | |
----wsgi.py | |
----settings/ | |
--------local.py | |
--------production.py | |
--------base.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FooAdmin(VersionAdmin): | |
def construct_change_message(self, request, form, formsets): | |
return "FOO" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("#your-button").click(function() { | |
// Remove the old audio tag. | |
$("#your-audio-container").find("audio").remove() | |
// Add a new audio tag in. | |
$("#your-audio-container").append($("<audio/>", { | |
src: "new-audio-file.mp3", | |
controls: true, | |
preload: true | |
})); | |
// Apply the html5media shim on legacy browsers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
html5media.configureFlowplayer = function(element, config) { | |
config.clip.onStart = function() { | |
}; | |
config.clip.onPause = function() { | |
}; | |
return config; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@register.filter | |
def search_description(obj, query): | |
for term in [query] + query.split(): | |
pattern = re.compile(re.escape(term), re.IGNORECASE) | |
if pattern.search(obj.title): | |
return obj.description | |
for content in (obj.description, obj.content): | |
match = pattern.search(content) | |
if match: | |
start = max(match.start() - 100, 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
How to add code samples in GitHub: | |
``` | |
def your_code(): | |
goes_here() | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Indent container contents on new lines. | |
some_tuple = ( | |
("foo", "bar"), | |
("baz", "bat"), # Always add trailing commas. | |
) | |
some_dict = { | |
"foo": "bar", | |
"baz": "bat", | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* LESS stylesheet loader. | |
* | |
* Load a LESS stylesheet using style!main.less . This will load | |
* a stylesheet on the path ../css/main.less, compile it to CSS, | |
* and inject it in the page. | |
* | |
* During the optimization step with r.js, the stylesheet will be | |
* inlined with the javascript file. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-----BEGIN PGP SIGNED MESSAGE----- | |
Hash: SHA1 | |
Dave Hall 20/01/2014 | |
-----BEGIN PGP SIGNATURE----- | |
Comment: GPGTools - http://gpgtools.org | |
iQEcBAEBAgAGBQJS3YYEAAoJEIayWs+cr8YFXD8H/j/K0yjIW/gOalmT5sW8twk6 | |
AfL9cJ4/PjM5wDnB3s879Wr4+OjHfIocwGt5czd8c2xqdo3t4EvySnBKRivDafx4 | |
bNhqiXBGApGiA0fCgxGBSSBdAo4SDtTO7qMmDb0TiGXjg33j83TX1AiY/M0IyobO |