Skip to content

Instantly share code, notes, and snippets.

parts = request.path.split('/')
try:
active_menu = parts[1]
except IndexError:
active_menu = ''
try:
active_section = parts[2]
except IndexError:
active_section = ''
{% load tree_tag %}
{% tree object_list with level as level %}
<ul{% ifequal tree.level 1 %} class="root"{% endifequal %}>
{% node %}
<li>{{ tree.node.title }}{% subtree %}</li>
{% endnode %}
</ul>
{% endtree %}
class Article extends Publication
initialize: (@title, @content) ->
render: ->
@$(".title").html @title
@$(".content").html @content
@yumike
yumike / requirements.txt
Created February 1, 2012 13:27
Better pip requirements file format with indented dependencies (already working)
Django==1.3.0
django-celery==2.2.4
celery==2.2.7
anyjson==0.3.1
kombu==1.2.0
amqplib==1.0.0
python-dateutil==1.5
django-picklefield==0.1.9
django_compressor==1.1.2
django-appconf==0.4.1
from django.utils import simplejson as json
class JSONRequestMixin(object):
def get_request_data(self):
return json.loads(self.request.body)
@yumike
yumike / blocks.py
Created December 8, 2011 06:45
Thoughts about RSpec for Python
# codec: blocks
describe('articles.views.ArticleView'):
context('when user has permissions'):
it('should add new article'):
# some code
it('should delete existing article'):
@yumike
yumike / app.py
Created November 30, 2011 06:36
Flask app with Gears
from flask import Flask
from flask_gears import Gears
app = Flask(__name__)
gears = Gears()
gears.init_app(app)
func(one, two,
three, four)
# or
func(
one, two,
three, four)
Mailer.send(
sender = 'john@example.com',
recipients = ['alex@example.com', 'kate@example.com'],
context_data = {'site': site},
template_name = 'mailer/messages/message')
ModelMailer.send(
object = message,
request = request,