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 artie.applications import timer | |
@timer(10) | |
def hi(irc): | |
""" | |
Sends a message to every channel the bot is in every 10 seconds. | |
""" | |
for channel in irc.channels: | |
irc.msg(channel, 'hi i am artie') |
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 os | |
import re | |
def find(expression, path='.', type='df'): | |
""" | |
Find files or directories. | |
>>> list(find(r'.*\.py$', type='f')) | |
['./find.py'] | |
""" |
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 | |
""" | |
HTTP server listens for GET requests on `PORT` with query *filename* and | |
opens *~/filename* with TextMate. | |
""" | |
import BaseHTTPServer | |
import os | |
import urlparse |
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 | |
""" | |
# highlight | |
Highlight terms in stdin with different colors. | |
Example usage: | |
$ tail -f /some/log_file | highlight batch3 slave master darwin | |
""" |
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
(12:01a) (sumeet@shanoa:~)$ `which python2.7` ./timethese.py string_concat.py 10000000 | |
# Running code block #1 | |
assert ''.join(('abc', 'def', 'ghi')) == 'abcdefghi' | |
Took 2.855692 seconds to run 10000000 times. | |
# Running code block #2 | |
assert 'abc' + 'def' + 'ghi' == 'abcdefghi' |
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
package main | |
import ( | |
"http" | |
"exec" | |
) | |
func Copy(response http.ResponseWriter, request *http.Request) { |
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 PRIVMSGTestCase(IRCClientTestCase): | |
"""Test a garbage response to a private message. | |
SERVER: :[email protected] PRIVMSG Wiz :Are you receiving this message ? | |
CLIENT: u said "Are you receiving this message ?" | |
""" |
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 time | |
class Stopwatch(object): | |
"""A stopwatch utility for timing execution that can be used as a regular | |
object or as a context manager. | |
NOTE: This should not be used an accurate benchmark of Python code, but a | |
way to check how much time has elapsed between actions. And this does not | |
account for changes or blips in the system clock. |
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
" for typos | |
map :W :w | |
map :E :e |
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
map <F1> <Esc> | |
imap <F1> <Esc> |
OlderNewer