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
# Roles Dictionary Values Example (1,2,4,8,16,32...) Up to 32 values | |
roles = {"addUsers": 1, "updatePermissions": 2, "uploadAttachments": 4, "createPosts": 8} | |
# Check if permission 9 has updatePermissions | |
# bitand will return 0 if False and a number if True | |
>>> 9&roles['updatePermissions'] | |
0 | |
# Check if permission 9 has addUsers |
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
roles = {"addUsers": 1, "updatePermissions": 2, "uploadAttachments": 4, "createPosts": 8} |
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
$.extend($.expr[":"], { | |
"starts-with": function(elem, i, data, set) { | |
var text = $.trim($(elem).text()), | |
term = data[3]; | |
return text.indexOf(term) === 0; | |
}, | |
"ends-with": function(elem, i, data, set) { | |
var text = $.trim($(elem).text()), | |
term = data[3]; | |
return text.lastIndexOf(term) === text.length - term.length; |
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
beautifulsoup4==4.1.3 | |
Django==1.4.2 | |
Fabric==1.4.3 | |
argparse==1.2.1 | |
django-appconf==0.5 | |
django-compressor==1.2 | |
psycopg2==2.4.5 | |
pycrypto==2.6 | |
ssh==1.8.0 | |
wsgiref==0.1.2 |
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 update_requirements(): | |
requirements = os.path.join(env.home, 'requirements') | |
with prefix('source %s/bin/activate' % env.python_path): | |
with cd(requirements): | |
cmd=['pip install'] | |
cmd += ['--requirement %s' % os.path.join(requirements, 'apps.txt')] | |
print(cmd) | |
run(' '.join(cmd)) |
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 Category(models.Model): | |
name = models.CharField(max_length=200) | |
def __unicode__(self): | |
return self.name | |
class Post(models.Model): | |
title = models.TextField(max_length=200) | |
content = HTMLField() | |
excerpt = HTMLField() | |
above_fold = models.BooleanField(default=False) |
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
{% for post in latest_blog_posts %} | |
<div class="row"> | |
<div> | |
<h2 class="post-title"><a href="/blog/post/{{ post.id }}/">{{ post.title }}</a></h2> | |
<h5 class="post-date">{{ post.pub_date }} - {% for cat in post.category.all %}{{ cat.name }}{% if not forloop.last %},{% endif %}{% endfor %}</h5> | |
<p class="lead">{% autoescape off %}{{ post.content|safe }}{% endautoescape %}</p> | |
</div> | |
</div> | |
<hr> | |
{% endfor %} |
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 HomeController < ApplicationController | |
def index @posts = RSS::Parser.parse(open('http://johngag.tumblr.com/rss').read, false).items | |
end | |
end | |
<%= link_to post.title, post.link, :target => "_parent" %> | |
<%= render :partial => "home/post", :collection => @posts.first(5) %> |
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
var world = {"Africa":["Algeria","Angola","Benin","Botswana","Burkina","Burundi","Cameroon","Cape Verde","Central African Republic","Chad","Comoros","Congo","Djibouti","Egypt","Equatorial Guinea","Eritrea","Ethiopia","Gabon","Gambia","Ghana","Guinea","Guinea-Bissau","Ivory Coast","Kenya","Lesotho","Liberia","Libya","Madagascar","Malawi","Mali","Mauritania","Mauritius","Morocco","Mozambique","Namibia","Niger","Nigeria","Rwanda","Sao Tome and Principe","Senegal","Seychelles","Sierra Leone","Somalia","South Africa","South Sudan","Sudan","Swaziland","Tanzania","Togo","Tunisia","Uganda","Zambia","Zimbabwe"], | |
"Asia":["Afghanistan","Bahrain","Bangladesh","Bhutan","Brunei","Burma","Cambodia","China","East Timor","India","Indonesia","Iran","Iraq","Israel","Japan","Jordan","Kazakhstan","North Korea","South Korea","Kuwait","Kyrgyzstan","Laos","Lebanon","Malaysia","Maldives","Mongolia","Nepal","Oman","Pakistan","Philippines","Qatar","Russian Federation","Saudi Arabia","Singapore","Sri Lanka","Syria","Tajikistan","Thailan |
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
tpl = { | |
templates: {}, | |
loadTemplates: function (names, callback) { | |
var that = this; | |
var loadTemplate = function (index) { | |
var name = names[index]; |
NewerOlder