Skip to content

Instantly share code, notes, and snippets.

View alejandrobernardis's full-sized avatar
🐻

Alejandro M. BERNARDIS alejandrobernardis

🐻
View GitHub Profile
#!/usr/bin/env python
"""This is a demonstration of sharing file descriptors across processes.
It uses Tornado (need a recent post-2.0 version from github) and the
multiprocessing module (from python 2.6+). To run it, start one copy
of fdserver.py and one or more copies of testserver.py (in different
terminals, or backgrounded, etc). Fetch http://localhost:8000 and
you'll see the requests getting answered by different processes (it's
normal for several requests to go to the same process under light
load, but under heavier load it tends to even out).
@alejandrobernardis
alejandrobernardis / pycharm.py
Created May 5, 2015 13:33
PyCharm Template
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
# Copyright (c) ${YEAR} Asumi Kamikaze Inc.
# Licensed under the MIT License.
# Author: Alejandro M. Bernardis
# Email: alejandro (dot) bernardis (at) asumikamikaze (dot) com
# Created: ${DAY}/${MONTH_NAME_SHORT}/${YEAR} ${HOUR}:${MINUTE}

Keybase proof

I hereby claim:

  • I am alejandrobernardis on github.
  • I am abernardis (https://keybase.io/abernardis) on keybase.
  • I have a public key whose fingerprint is 0B58 EC83 D7A8 6CF2 793C D003 07A2 572D D367 D6D0

To claim this, I am signing this object:

@alejandrobernardis
alejandrobernardis / run.py
Last active August 29, 2015 14:17 — forked from bdarnell/run.py
import macropy.activate
import test
"""Demo of streaming requests with Tornado.
This script features a client using AsyncHTTPClient's body_producer
feature to slowly produce a large request body, and two server
handlers to receive this body (one is a proxy that forwards to the
other, also using body_producer).
It also demonstrates flow control: if --client_delay is smaller than
--server_delay, the client will eventually be suspended to allow the
server to catch up. You can see this in the logs, as the "client
import time
from tornado.concurrent import run_on_executor
from concurrent.futures import ThreadPoolExecutor # `pip install futures` for python2
MAX_WORKERS = 4
class Handler(tornado.web.RequestHandler):
executor = ThreadPoolExecutor(max_workers=MAX_WORKERS)
@alejandrobernardis
alejandrobernardis / demo.py
Created February 12, 2015 22:29
tornado forking
#
# https://groups.google.com/d/msg/python-tornado/1LsOhqwOOTI/2Sp7RSM7sfcJ
#
#
import os
import time
from tornado import gen, ioloop, httpserver, web
def fork_processes(num_processes):
@alejandrobernardis
alejandrobernardis / Makefile
Last active August 29, 2015 14:14
Angular Template (makefile)
DEPLOY_PATH := ./deploy
NODE_PATH := ./node_modules
STATIC_PATH := ./static
STATIC_STRUCT := ./static/{component,style,data,image,script,stylus,vendor,view}
VENDOR_PATH := ./static/vendor
OK := " - Ok."
NOT_FOUND := " - Not found."
FAIL := " - Fail."
SERVER_PID := /tmp/pyserver.pid
@alejandrobernardis
alejandrobernardis / KCVersion.java
Last active August 29, 2015 14:14
ANT # Control de Versiones - Version Control
package kc.ant;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Properties;
public class KCVersion {
/**
tar cfvz ./Desktop/dots.tar.gz .profile .profile.pysave .gitconfig .tm_properties .vimrc .viminfo