Skip to content

Instantly share code, notes, and snippets.

View alejandrobernardis's full-sized avatar
🐻

Alejandro M. BERNARDIS alejandrobernardis

🐻
View GitHub Profile
@peterbe
peterbe / tornado_static.py
Created July 12, 2011 14:02
tornado_static
"""
tornado_static is a module for displaying static resources in a Tornado web
application.
It can take care of merging, compressing and giving URLs ideal renamings
suitable for aggressive HTTP caching.
(c) [email protected]
"""
@robcowie
robcowie / magiccrypt.py
Created September 4, 2011 01:14
AES-CBC shared-key crypto with hmac signing
# -*- coding: utf-8 -*-
"""Part of an answer to http://stackoverflow.com/questions/7296535/easy-to-use-python-encryption-library-wrapper/7296656#7296656"""
import hashlib
import hmac
import os
import random
from Crypto.Cipher import AES
@ewheeler
ewheeler / gist:1262989
Created October 4, 2011 22:12
flask + tornado + nginx + supervisord
# create stub, then run flask app in tornado on port 5000 (perhaps with supervisord config below http://supervisord.org/index.html)
#!/usr/bin/env python
from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from myflaskapp import app
http_server = HTTPServer(WSGIContainer(app))
@tsabat
tsabat / supervisor.conf
Created December 28, 2011 15:09
Sample supervisor config file
; Sample supervisor config file.
[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)
;chmod=0700 ; sockef file mode (default 0700)
;chown=nobody:nogroup ; socket file uid:gid owner
;username=user ; (default is no username (open server))
;password=123 ; (default is no password (open server))
;[inet_http_server] ; inet (TCP) server disabled by default
@benwah
benwah / mongo_serialize.py
Created June 28, 2012 04:43
Queryset / List of queryset serializer for mongoengine models.
import json
import datetime
from decimal import Decimal
from mongoengine.queryset import queryset_manager
from mongoengine.queryset import QuerySet
from mongoengine.base import BaseList, BaseDict, ObjectId
def list_encoder(inst, obj, field, force_string=False):
"""
@cmaitchison
cmaitchison / chef_solo_bootstrap.sh
Created August 17, 2012 09:45
CentOS 6.3 Chef-Solo bootstrap (RackSpace)
#!/bin/bash -xe
#THIS SCRIPT MUST BE RUN AS ROOT
ADMIN_USER=admin
ADMIN_GROUP=admin
#add admin group
(cat /etc/group | grep -E '\b$ADMIN_GROUP\b') || sudo groupadd $ADMIN_GROUP
@alejandrobernardis
alejandrobernardis / demo.py
Created September 14, 2012 06:32
Data Base, User Demo
from settings import DATABASE_USERS
from com.ak.common.security import token
from mongoengine import connect as mongo_connect
settings = dict(host='127.0.0.1', port=27017)
mongo_connect(DATABASE_USERS, **settings)
User.drop_collection()
u = User()
u.username = 'alejandro.bernardis'
u.password = 'alejandro.bernardis'
u.email = '[email protected]'
@ryanjbonnell
ryanjbonnell / gist:3880048
Last active March 23, 2023 18:01
Install Memcache on Mac OS X 10.8 "Mountain Lion"
# memcached requires libevent
cd /usr/local/src
curl -L -O http://cloud.github.com/downloads/libevent/libevent/libevent-2.0.17-stable.tar.gz
tar -xvzf libevent-2.0.17-stable.tar.gz
cd libevent-2.0.17-stable*
./configure
make
sudo make install
# Compile memcached utility
@bdarnell
bdarnell / tornado_tulip.py
Created January 20, 2013 22:31
Proof of concept tornado/tulip integration
"""Proof of concept tornado/tulip integration.
Works with the current development branch of both projects as of
Jan 20. Current status: The tornado test suite passes cleanly
on a tulip-backed IOLoop. The tornado-backed event loop for tulip
supports the core call_later and add_reader method families, but not
the higher-level networking methods.
To run the tornado test suite on tulip, make sure both projects
and this file are on your python path and run:
@lbolla
lbolla / futures_test.py
Last active April 24, 2023 17:59
Tornado and concurrent.futures
from concurrent.futures import ThreadPoolExecutor
from functools import partial, wraps
import time
import tornado.ioloop
import tornado.web
EXECUTOR = ThreadPoolExecutor(max_workers=4)