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
# How to use PG Point type in SQAlchemy | |
# | |
# Most of the code comes from here: | |
# http://initd.org/psycopg/docs/advanced.html#adapting-new-types | |
import re | |
import sqlalchemy | |
import psycopg2 | |
from psycopg2.extensions import adapt, register_adapter, AsIs |
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 | |
import tornado.ioloop | |
import psycopg2 | |
import psycopg2.extensions | |
io_loop = tornado.ioloop.IOLoop.instance() | |
conn = psycopg2.connect('dbname=mytest user=lbolla password=secret') | |
conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT) | |
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
all: go.so | |
go.o: go.c | |
gcc -std=c99 -c -fPIC go.c -o go.o | |
go.so: go.o | |
gcc -shared -Wl,-soname,libgo.so -o libgo.so go.o |
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
[MyDB] | |
Description = My Database | |
Driver = FreeTDS | |
Servername = W7WS6CL832J # MSSQL server name | |
Database = mydb | |
UID = username | |
PWD = password | |
Port = 1433 | |
Charset = UTF-8 |
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 threading import Thread | |
def busy_sleep(n): | |
while n > 0: | |
n -= 1 | |
N = 99999999 | |
t1 = Thread(target=busy_sleep, args=(N, )) |
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 concurrent.futures | |
class ProcessManager(object): | |
def __init__(self): | |
self.pool = concurrent.futures.ProcessPoolExecutor() | |
self.futures = {} | |
def submit(self, f, *args, **kwargs): |
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 os | |
import time | |
from subprocess import Popen | |
def check_zombies(expected_nzombies): | |
# NOTE: don't use Popen() here | |
output = os.popen(r"ps aux | grep ' Z' | grep -v grep").read() | |
got_nzombies = len(output.splitlines()) | |
if got_nzombies > 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 random | |
import string | |
import cherrypy | |
class StringGenerator(object): | |
@cherrypy.expose | |
def index(self): | |
return """<html> |
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 StringIO | |
import cPickle | |
small = [{i: i} for i in xrange(9)] | |
medium = [{i: i} for i in xrange(999)] | |
large = [{i: i} for i in xrange(999999)] | |
def dumps(obj): | |
return cPickle.dumps(obj) |
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
(flycheck-define-checker javascript-flow | |
"A JavaScript syntax and style checker using Flow. | |
See URL `http://flowtype.org/'." | |
:command ("flow" source-original) | |
:error-patterns | |
((error line-start | |
(file-name) | |
":" | |
line |