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
| [wraithan@wraithbeast ~] | |
| $ python3 | |
| Python 3.2.2 (default, Sep 5 2011, 04:52:19) | |
| [GCC 4.6.1 20110819 (prerelease)] on linux2 | |
| Type "help", "copyright", "credits" or "license" for more information. | |
| >>> None < 3 | |
| Traceback (most recent call last): | |
| File "<stdin>", line 1, in <module> | |
| TypeError: unorderable types: NoneType() < int() | |
| >>> |
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
| Python 3.2.2 (default, Sep 5 2011, 04:52:19) | |
| [GCC 4.6.1 20110819 (prerelease)] on linux2 | |
| Type "help", "copyright", "credits" or "license" for more information. | |
| >>> if True: | |
| ... foo = 5 | |
| ... | |
| >>>> print(foo) | |
| 5 |
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 visible(self, loc): | |
| ' determine which squares are visible to the given player ' | |
| if self.vision == None: | |
| if not hasattr(self, 'vision_offsets_2'): | |
| # precalculate squares around an ant to set as visible | |
| self.vision_offsets_2 = [] | |
| mx = int(sqrt(self.viewradius2)) | |
| for d_row in range(-mx,mx+1): | |
| for d_col in range(-mx,mx+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
| def visible(self, loc): | |
| ' determine which squares are visible to the given player ' | |
| if self.vision == None: | |
| if not hasattr(self, 'vision_offsets_2'): | |
| # precalculate squares around an ant to set as visible | |
| self.vision_offsets_2 = [] | |
| mx = int(sqrt(self.viewradius2)) | |
| for d_row in range(-mx,mx+1): | |
| for d_col in range(-mx,mx+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 copy import deepcopy | |
| from timeit import Timer | |
| list_o_lists = [[1,2,3,4],[1,2,3,4],[1,2,3,4],[1,2,3,4]] | |
| def deepcopy_f(): | |
| meh = deepcopy(list_o_lists) | |
| def slice_f(): |
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
| >>>> a = [[1]] * 10 | |
| >>>> a | |
| [[1], [1], [1], [1], [1], [1], [1], [1], [1], [1]] | |
| >>>> a[0][0] = 20 | |
| >>>> a | |
| [[20], [20], [20], [20], [20], [20], [20], [20], [20], [20]] | |
| >>>> |
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 datetime import datetime | |
| from timeit import Timer | |
| def verbose_f(): | |
| now = datetime.now() | |
| new_dt = datetime(now.year, now.month, now.day, now.hour, now.minute, now.second, now.microsecond, now.tzinfo) | |
| def terse_f(): | |
| now = datetime.now() | |
| new_dt = datetime.combine(now.date(), now.time()) |
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
| (9:28:07 PM) meredith mclain: heya! | |
| (9:28:11 PM) me: ohai bot | |
| (9:28:19 PM) meredith mclain: Im not a freaking bot | |
| (9:28:36 PM) me: orly | |
| (9:28:44 PM) meredith mclain: hey whats up? 23/F here. youu? | |
| (9:28:44 PM) me: So what are you selling? | |
| (9:28:52 PM) meredith mclain: hmm. have we chattted before? | |
| (9:28:54 PM) me: bot | |
| (9:29:02 PM) meredith mclain: Im not a freaking bot | |
| (9:29:10 PM) me: bot |
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
| <!doctype html> | |
| <html> | |
| <head> | |
| <title>{{page_name}}</title> | |
| </head> | |
| <body> | |
| <h1>{{page_name}}</h1> | |
| {% block content %} | |
| {% endblock content %} | |
| </body> |
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
| var fs = require('fs'); | |
| var redis_lib = require('redis'); | |
| var pub = redis_lib.createClient(); | |
| module.exports = { | |
| send_privmsg: function(to, message) { | |
| return pub.publish('out', JSON.stringify({ | |
| version: 1, | |
| type: 'privmsg', |