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
| def nn(name): | |
| if len(name) < 3: | |
| return name | |
| return '%s%d%s' % ( | |
| name[0], len(name) - 2, name[-1] | |
| ) |
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
| class SpaceS(PolymorphicS): | |
| def process_filter_geo_polygon(self, key, val, action): | |
| return { | |
| "geo_polygon": { | |
| key: { | |
| "points":[dict(lat=y, lon=x) for x, y in val] | |
| } | |
| } | |
| } |
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
| from geventirc import message | |
| class Pass(message.Command): | |
| def __init__(self, password, prefix=None): | |
| params = [password] | |
| super(Pass, self).__init__(params, prefix=prefix) |
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
| botbits.handlers.SalutationMatcher: | |
| nick: aholebot | |
| salutations: | |
| - "get lost {}" | |
| - "you are unloved, {}" | |
| - "{} has no mother" | |
| - "nice chat message, {}" | |
| - "i hate you {}" |
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
| def p(n): | |
| if n == 0: | |
| return '1' | |
| return str(2 ** n) + p(n - 1) |
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
| from fabric.api import * | |
| from fabric.operations import run | |
| env.user = 'remoteuser' | |
| env.webroot = '/usr/local/blah/htdocs' | |
| env['disable_known_hosts'] = True | |
| def production_provision(): |
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 subprocess | |
| import sys | |
| import lxml.html | |
| import requests | |
| if __name__ == '__main__': | |
| url, selector = sys.argv[-2:] | |
| response = requests.get(url) |
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
| <json anAttr="<json anotherAttr=\"<json value=\"Foobar\"/>\"/>"/> |
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 subprocess | |
| import sys | |
| if __name__ == '__main__': | |
| """ | |
| Example: robotalk.py "Please do not violate me, robot." | |
| """ | |
| text = sys.argv[-1] | |
| s = ' '.join([' '.join(bin(ord(x))[2:]) for x in text]) |
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
| def from_native(self, data, files): | |
| identity = self.get_identity(data) | |
| if identity: | |
| obj = self.opts.model.objects.get(id=identity) | |
| dirty = False | |
| for field_name, field_serializer in self.fields.items(): | |
| val = field_serializer.from_native(data[field_name]) | |
| if getattr(obj, field_name) != val: | |
| setattr(obj, field_name, val) | |
| dirty = True |
OlderNewer