Skip to content

Instantly share code, notes, and snippets.

@e000
e000 / rc4.py
Created March 3, 2011 01:53
nice rc4
class RC4:
def __init__(self, key):
self._key, x, box, kl = key, 0, range(256), len(key)
for i in xrange(256):
x = (x + box[i] + ord(key[i % kl])) & 0xff
box[i], box[x] = box[x], box[i]
self._box = box
def crypt(self, data):
from twisted.conch.ssh import transport, userauth, connection, common, keys, channel, forwarding
from twisted.internet import defer, protocol, reactor, interfaces, base, address, error
import socket
import types
from twisted.python import failure
from twisted.internet.protocol import connectionDone
__all__ = ['SSHTransport', 'SSHTransportFactory', 'SSHConnection', 'SSHForwardConnector', 'SSHForwardTransport']
class SSHTransport(transport.SSHClientTransport):
def connected(conn):
print 'connected', conn
conn.connectTCP('irc.ircneto.rk', 6667, IRCFactory())
pass
import json
def gotData(data):
data = json.loads(data)
for user in data['data']:
>>> Image.query.filter(Image.name.contains('jpg')).first()
<Image #1 [CONTEXT177.jpg] @ [/media/truecrypt1/Pictures/CONTEXT177.jpg] in <Folder #1 [Unfiled, 13649 items]>>
>>> img = _
>>> img.tags
[<Tag u''>]
>>> # empty tag
...
>>> from models import getTag
>>> img.tags[:] = []
>>> img.tags
from texttable import Texttable
import re
_ignParens = re.compile('\(.*?\)')
def countDelim(text, delim = ' | '):
text = _ignParens.sub('', text)
return text.count(delim)
def renderTable(input, sub = False):
if not input:
return []
from texttable import Texttable
import re
_ignParens = re.compile('\(.*?\)')
def countDelim(text, delim = ' | '):
text = _ignParens.sub('', text) # get rid of the stuff inside of parens when searching for ' | '
return text.count(delim)
def renderTable(input, sub = False):
input = input[:] # make a copy of the input, so it doesn't eat the one in the cache.
[00:26:38] <Zalgo> Input interpretation:
[00:26:38] <Zalgo> The Matrix Revolutions (movie) | Men in Black II (movie)
[00:26:38] <Zalgo> Basic information:
[00:26:38] <Zalgo> +--------------+-------------------------------------------+---------------------------------------+
[00:26:38] <Zalgo> | | The Matrix Revolutions | Men in Black II |
[00:26:38] <Zalgo> +--------------+-------------------------------------------+---------------------------------------+
[00:26:38] <Zalgo> | title | The Matrix Revolutions | Men in Black II |
[00:26:38] <Zalgo> +--------------+-------------------------------------------+---------------------------------------+
[00:26:38] <Zalgo> | directors | Andy Wachowski | Lana Wachowski | Barry Sonnenfeld |
[00:26:38] <Zalgo> +--------------+-------------------------------------------+----------------------------------
[00:42:21] <e> !wa the matrix revolutions, men in black II
[00:42:22] -Zalgo- Attempting to calculate using Wolfram Alpha...
[00:42:23] -Zalgo- Calculation complete in 1.833927 seconds.
[00:42:23] -Zalgo- Input interpretation:
[00:42:23] -Zalgo- The Matrix Revolutions (movie) | Men in Black II (movie)
[00:42:23] -Zalgo- Basic information:
[00:42:23] -Zalgo- +--------------+-------------------------------------------+---------------------------------------+
[00:42:23] -Zalgo- | | The Matrix Revolutions | Men in Black II |
[00:42:23] -Zalgo- +--------------+-------------------------------------------+---------------------------------------+
[00:42:23] -Zalgo- | title | The Matrix Revolutions | Men in Black II |
<e> !wa nobel prize
-Zalgo- Attempting to calculate using Wolfram Alpha...
-Zalgo- Calculation complete in 1.543207 seconds.
-Zalgo- Input interpretation:
-Zalgo- Nobel Prize
-Zalgo- Result:
-Zalgo- +------+---------------------------+------------+------------------------+------------------+
-Zalgo- | year | recipient | field | country of achievement | country of birth |
-Zalgo- +------+---------------------------+------------+------------------------+------------------+
-Zalgo- | 2010 | Akira Suzuki | chemistry | Japan | Japan |
[01:32:55] <Sandman> 2000 api calls
[01:32:55] -Zalgo- Attempting to calculate using Wolfram Alpha...
[01:32:56] -Zalgo- Calculation complete in 1.217716 seconds.
[01:32:56] -Zalgo- Input interpretation:
[01:32:56] -Zalgo- Fight Club (movie) | The Shawshank Redemption (movie)
[01:32:56] -Zalgo- Basic information:
[01:32:56] -Zalgo- +--------------------------------+--------------------------------+--------------------------------+
[01:32:56] -Zalgo- | | Fight Club | The Shawshank Redemption |
[01:32:56] -Zalgo- +--------------------------------+--------------------------------+--------------------------------+
[01:32:56] -Zalgo- | title | Fight Club | The Shawshank Redemption |