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
To install redis from debian backports we need to add the backports sources. | |
1. Add to /etc/apt/sources.list: | |
deb http://backports.debian.org/debian-backports squeeze-backports main | |
2. Retrieve debian key | |
$ gpg --keyserver pgp.mit.edu --recv-keys AED4B06F473041FA |
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
To install node.js and coffee-script inside a virtualenv and keep it self-contained: | |
1. Activate the virtualenv:: | |
$ workon test | |
2. Move inside the virtualenv directory:: | |
(test)$ cdvirtualenv |
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.contrib.sessions.backends.base import SessionBase, CreateError | |
from django.conf import settings | |
from django.utils.encoding import force_unicode | |
import redis | |
class SessionStore(SessionBase): | |
""" Redis store for sessions""" | |
def __init__(self, session_key=None): | |
self.redis = redis.Redis( |
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.test import TestCase | |
from django.core.files.base import ContentFile | |
from django.core.files.storage import default_storage | |
class ToolsTest(TestCase): | |
def test_file(self): | |
"""Creates a tmp file""" | |
tmp_file = default_storage.save('tools/default.txt', | |
ContentFile('default content')) |
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
https://github.com/theteam/ubuntu-start/blob/develop/www/script/uStart.ParallaxCarousel.js#L120 | |
https://github.com/theteam/ubuntu-start/blob/develop/www/script/uStart.ParallaxCarousel.js#L123 | |
https://github.com/theteam/ubuntu-start/blob/develop/www/script/base.js#L52 |
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
<!-- this usually goes in <project-root>/templates/uni_form/field.html --> | |
{% if field.is_hidden %} | |
{{ field }} | |
{% else %} | |
<div class="clearfix {% if field.errors %}error{% endif %}"> | |
<label for="{{ field.auto_id }}" {% if field.field.required %}class="requiredField"{% endif %}> | |
{{ field.label|safe }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %} | |
</label> | |
<div class="input"> |
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
def secured_download(func): | |
"""Wraps a view to server files securely ONLY when a | |
``FileField`` is returned | |
Uses Django when ``DEBUG`` is on else NGINX | |
""" | |
def wrapper(request, *args, **kwargs): | |
response = func(request, *args, **kwargs) | |
if isinstance(response, FieldFile): | |
# response is a ``FieldFile`` we should serve it | |
if settings.DEBUG: |
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
Get google closure compiler to evaluate your javascript code on your emacs | |
-------------------------------------------------------------------------- | |
- Download the google closure compiler, unzip it and place ``compiler.jar`` somewhere accessible | |
(e.g. ``~/bin/compiler.jar``):: | |
http://closure-compiler.googlecode.com/files/compiler-latest.zip | |
- Create a shell script to run closure on a file (e.g. closure.sh):: |
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 NyanCatMiddleware(object): | |
"""Nyan Nyan Nyan""" | |
def process_response(self, request, response): | |
response['X-Cat'] = "Nyan nyan nyan nyan" | |
return response |
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
#!/bin/bash | |
# This hook is run after a new virtualenv is activated. | |
echo cd `pwd` > $VIRTUAL_ENV/bin/postactivate | |
echo "Hook created to move to current directory" |
NewerOlder