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 shlex as shlex_ | |
from subprocess import Popen, PIPE | |
def shell(args, input=None, stdout=PIPE, stderr=PIPE, shlex=False, **kwargs): | |
"""Gets the output of a command run in a subprocess. | |
Arguments: | |
args: A sequence of strings, or a single string if shlex=True. | |
input: A string to be written to the process's stdin. | |
Any extra keyword arguments are forwarded to Popen. |
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 | |
from twisted.internet import reactor | |
from twisted.internet.task import LoopingCall, Cooperator | |
import pygame | |
import pygame.font | |
pygame.display.init() | |
pygame.font.init() |
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
main = lambda port: (lambda dt: (lambda mm: (lambda n: (map(lambda r: (lambda | |
rr: setattr(n, *rr) if (type(rr) is tuple and len(rr) == 2) else None)(r()), | |
[lambda: map(setattr, *zip(*[(n, m, __import__(m)) for m in mm.m.decode('ba' | |
'se64').split()])), lambda: map(n.s['signal.signal'], (n.s['signal.SIGINT'], | |
n.s['signal.SIGTERM']), [lambda s, f: (n.s['sys.exit']() if n.f else [n.sa( | |
mm.l[0], n.o)] and n.u('f', True) or n.fc(n.l))] * 2), lambda: setattr(mm, | |
'l', mm.l.decode('base64').split('~~~')), lambda: ('sw', n.s['types.Functio' | |
'nType'] (compile("try:\n\tv = n.select.select(n.so, n.w(), [])\nexcept n.s" | |
"elect.error, e:\n\tif e[0] != n.errno.EINTR: raise\nelse:\n\tn.u('sr', v)", | |
'', 'exec'), dict(n=n, OSError=OSError))),lambda: ('l', n.s['socket.socket'] |
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 sys | |
from twisted.internet import defer, protocol, task, endpoints | |
from twisted.python import log | |
class ProxyClientProtocol(protocol.Protocol): | |
def connectionMade(self): | |
log.msg("Client: connected to peer") |
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/python | |
import subprocess | |
import plistlib | |
import os.path | |
import errno | |
def check_output(cmd, *a, **kw): | |
proc = subprocess.Popen(cmd, *a, **kw) | |
stdout, stderr = proc.communicate() | |
if proc.returncode: |
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
# -*- coding: utf-8 -*- | |
# | |
# Copyright 2013 Liftoff Software Corporation | |
# | |
# For license information see LICENSE.txt | |
# Meta | |
__version__ = '1.0.0' | |
__version_info__ = (1, 0, 0) | |
__license__ = "Apache 2.0" |
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 sqlite3 | |
from collections import defaultdict | |
DATABASE = 'C:/Misc/myscripts/workprototype/workprototype.db' | |
conn = sqlite3.connect(database=DATABASE) | |
curs = conn.cursor() | |
prod_dict = {} | |
curs.execute('select name, desc from companies') |
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 sys | |
from twisted.internet import defer, endpoints, protocol, reactor, task | |
from twisted.python import log | |
from twisted.words.protocols import irc | |
class MyFirstIRCProtocol(irc.IRCClient): | |
nickname = 'MyFirstIrcBot' |
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
from ometa.grammar import OMeta | |
from ometa.interp import TrampolinedGrammarInterpreter | |
from parsley import makeGrammar | |
import sys | |
grammar = """ | |
hex_digit = digit | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' |
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 pprint | |
import sys | |
import oauth2 | |
from twisted.internet import defer, task | |
from twisted.web.client import Agent, HTTPConnectionPool | |
import twits | |
OlderNewer