This file contains 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 | |
""" | |
Regex for URIs | |
These regex are directly derived from the collected ABNF in RFC3986 | |
(except for DIGIT, ALPHA and HEXDIG, defined by RFC2234). | |
They should be processed with re.VERBOSE. | |
""" |
This file contains 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 asyncore, socket | |
from dns import resolver, rdatatype, rdataclass, message | |
# Stolen from here: | |
# http://glyphy.com/asynchronous-dns-queries-python-2008-02-09 | |
class AsyncDNS(asyncore.dispatcher): | |
def __init__(self): | |
asyncore.dispatcher.__init__(self) |
This file contains 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, os, sys, time | |
class autolock(threading._RLock): | |
__enter__ = threading._RLock.acquire | |
__leave__ = threading._RLock.release | |
def __except__(self, type, value, traceback): | |
self.release() | |
if type is KeyboardInterrupt: | |
self.interrupt = value |
This file contains 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
scheme, host, path, params, query, fragment = urlparse.urlparse(uri) |
This file contains 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
define ppystack | |
while $pc < Py_Main || $pc > Py_GetArgcArgv | |
if $pc > eval_frame && $pc < PyEval_EvalCodeEx | |
set $__fn = PyString_AsString(co->co_filename) | |
set $__n = PyString_AsString(co->co_name) | |
printf "%s (%d): %s\n", $__fn, f->f_lineno, $__n | |
end | |
up-silently 1 | |
end |
This file contains 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 (var i:uint = 0; i < len; i++) { | |
var loader:URLLoader = new URLLoader(); | |
loader.addEventListener(Event.COMPLETE, fun (..._) {}); | |
loader.load(t[i]); | |
} | |
// 順次実行 | |
var i:uint = 0; (function cont (..._):void { if (i++ < parts) { | |
var loader:URLLoader = new URLLoader(); |
This file contains 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
## Function | |
traverse("object", obj, function(key, val) {console.log(key, val)}); | |
## Call | |
function traverse(key, jsonObj, func) { | |
if( typeof jsonObj == "object" ){ | |
$.each(jsonObj, function(k,v) { | |
traverse(k,v); | |
}) | |
} else { |
This file contains 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
LUAOBJECT_GRAMMAR = %q{ | |
grammar LuaObject | |
rule luaobj | |
space value space { def to_ruby; value.to_ruby; end } | |
end | |
rule value | |
nil / float / number / string / table / boolean | |
end |
This file contains 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 socket | |
def sockrecv(sock): | |
d = '' | |
while not d or d[-1] != '\n': | |
d += sock.recv(8192) | |
return d | |
This file contains 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
>>> d = {k:v for k,v in enumerate('ABCD') if v not in 'CB'} | |
>>> print(d) | |
{0: 'A', 3: 'D'} | |
>>> type(d) | |
<class 'dict'> |
OlderNewer