Skip to content

Instantly share code, notes, and snippets.

/**
*
*
* ScaleBitmap
*
* @author Didier Brun
* @author Jerôme Decoster
* @version 1.1
*
*/
#!/usr/bin/env python
#
# Converts any integer into a base [BASE] number. I have chosen 62
# as it is meant to represent the integers using all the alphanumeric
# characters, [no special characters] = {0..9}, {A..Z}, {a..z}
#
# I plan on using this to shorten the representation of possibly long ids,
# a la url shortenters
#
@amix
amix / amazon_sender.py
Created May 17, 2011 13:39
Amazon SES helper script using boto
# -*- coding: utf-8 -*-
"""
amazon_sender.py
~~~~~~~~
Python helper class that can send emails using Amazon SES and boto.
The biggest feature of this class is that encodings are handled properly.
It can send both text and html emails.
This implementation is using Python's standard library (which opens up for a lot more options).
@saghul
saghul / zmq_websocket_gateway.py
Created June 28, 2011 18:49
A ZeroMQ - WebSocket gateway
# coding=utf8
# Copyright (C) 2011 Saúl Ibarra Corretgé <saghul@gmail.com>
#
import hashlib
import os
import re
import socket
import struct
@iveney
iveney / utf2gbk.py
Created July 24, 2011 19:57
Rename files that have GBK encoded filenames but wrongly encoded in UTF8
#!/usr/bin/env python
import sys
import os
import unicodedata
for name in sys.argv[1:]:
try:
new_name = unicodedata.normalize("NFC", name.decode('utf8'))
new_name = new_name.encode('latin-1').decode('gbk')
@workmajj
workmajj / brubeck-install.sh
Created September 18, 2011 22:40
Basic OS X install script for Brubeck.
#!/usr/bin/env sh
# Brubeck install script cribbed from: http://brubeck.io/installing.html
# Version numbers and directories.
ZMQ_VERSION="2.1.9"
VIRTUALENVWRAPPER_SH="/usr/local/bin/virtualenvwrapper.sh"
VIRTUALENV_NAME="brubeck"
@j2labs
j2labs / brubeck_installer.sh
Created September 26, 2011 03:30
Brubeck Installer for Ubuntu
#!/bin/sh
###
### Settings
###
ZMQ_VERSION="zeromq-2.1.9"
MONGREL2_VERSION="mongrel2-1.7.5"
PREV_DIR=$PWD
SRC_DIR=$HOME/src
@mikeyk
mikeyk / gist:1329319
Created October 31, 2011 22:56
Testing storage of millions of keys in Redis
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])
@jordanorelli
jordanorelli / mongrel2.conf
Created November 8, 2011 18:03
brubeck project structure concept
static_dir = Dir(
base='static/',
index_file='index.html',
default_ctype='text/plain'
)
brubeck_handler = Handler(
send_spec='ipc://run/mongrel2_send',
send_ident='039eba8a-e879-40fc-9d33-52afb318d4bc',
recv_spec='ipc://run/mongrel2_recv',
@kachayev
kachayev / tic-tac-toe.py
Created November 22, 2011 23:50
Tornado demo application: TCP server to tic-tac-toe multiplayer game
"""Simple TCP server for playing Tic-Tac-Toe game.
Use Player-to-Player game mode based on naming auth.
No thoughts about distribution or pub/sub mode
(for monitoring or something like this). Just
basic functionality.
"""
import time
import logging