This file contains hidden or 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
| """ | |
| Sometimes you just don't want to display every permission django has, | |
| you just want a short list showing the permissions for some of your apps (or even django core apps). | |
| GROUP_PERMISSIONS_MODELS must be a list of your app models. | |
| Dotted path (in lowercase) required, app name + model class name. | |
| tested on Django 1.6 (should work on +1.3) | |
| """ |
This file contains hidden or 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
| """ | |
| Result: | |
| TIMEZONE_CHOICES = [ | |
| ("Africa", [ | |
| ("Africa/Abidjan", "Abidjan"), | |
| ("Africa/Accra", "Accra"), | |
| #... | |
| ]), | |
| ("America", [ |
This file contains hidden or 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
| describe "post tests", -> | |
| post = null | |
| beforeEach -> | |
| #jasmine-jquery | |
| #fixtures = do jasmine.getFixtures | |
| #fixtures.fixturesPath = 'base/test/fixtures/' | |
| #loadFixtures 'bookmark.html' | |
| post = spyOn $, 'post' |
This file contains hidden or 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 is just a cool example on how to write coros in javascript Ecma6. | |
| * Licence: MIT | |
| * Author: esteban castro borsani | |
| */ | |
| var http = require('http'); | |
| var fs = require('fs'); | |
| var path = require('path'); | |
| var Q = require("q"); | |
| var co = require("co"); |
This file contains hidden or 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
| /* | |
| Author: Esteban Castro Borsani | |
| Licence: MIT | |
| */ | |
| /* | |
| This is a schema validator... errrgh.... this is the first step to create a json validator. | |
| It does not do any validation, but it iterates over nested objects and arrays defined in your schema, recording the full path for error outputs. | |
| REQUIRES: lodash |
This file contains hidden or 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
| if __name__ == '__main__': | |
| import os | |
| from subprocess import call | |
| BASE = os.getcwd() | |
| for root, dirs, files in os.walk("./spirit"): | |
| if 'locale' not in dirs: | |
| continue |
This file contains hidden or 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
| import hashlib | |
| def get_hash(file): | |
| md5 = hashlib.md5() | |
| for c in file.chunks(): | |
| md5.update(c) | |
| return md5.hexdigest() |
This file contains hidden or 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
| import weakref | |
| class _BoundMethodWeakref: | |
| def __init__(self, func): | |
| self.func_name = func.__name__ | |
| self.wref = weakref.ref(func.__self__) #__self__ returns the class http://docs.python.org/reference/datamodel.html | |
| def __call__(self): | |
| func_cls = self.wref() |
This file contains hidden or 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
| import threading | |
| #import logging | |
| #logger = logging.getLogger(__name__) | |
| import idle_queue | |
| from weak_ref import weak_ref | |
| class Event: | |
| def __init__(self, name): |
This file contains hidden or 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
| # Untested | |
| def merge(dict_a, dict_b, **kwargs): | |
| assert isinstance(dict_a, dict), \ | |
| "A dict was expected in %s" % kwargs.pop('node_name', 'first param') | |
| for k, v in dict_b.items(): | |
| if isinstance(v, dict): | |
| merge(dict_a.setdefault(k, {}), v, node_name=k) | |
| continue |
OlderNewer