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 mongoengine | |
| class MongoModelSerializer(serializers.ModelSerializer): | |
| def get_default_fields(self): | |
| cls = self.opts.model | |
| opts = get_concrete_model(cls) | |
| #pk_field = opts.pk | |
| fields = [] | |
| fields += [getattr(opts, field) for field in opts._fields] | |
| #fields += [field for field in opts.many_to_many if field.serialize] |
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 sys | |
| import argparse | |
| def get_env(): | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument('--env', default='active') | |
| opts, remaining = parser.parse_known_args() | |
| print opts.env |
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
| #!/usr/bin/env python | |
| #install: pip install redis | |
| import redis | |
| r1 = redis.StrictRedis(host='localhost', port=6379, db=1) | |
| r2 = redis.StrictRedis(host='localhost', port=6379, db=2) | |
| hash_name = 'hash:setting:view' |
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
| <?php | |
| ini_set('memory_limit', '2G'); | |
| $data = new MyObject(3000000); | |
| benchmark('msgpack', 'msgpack_pack', 'msgpack_unpack', $data); | |
| benchmark('serialize', 'serialize', 'unserialize', $data); |