Skip to content

Instantly share code, notes, and snippets.

Avatar

Guillaume Aubert gaubert

View GitHub Profile
View serv.py (simple echo server)
# Echo server program
import socket
HOST = '' # Symbolic name meaning the local host
PORT = 9001 # Arbitrary non-privileged port
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1)
print "listenning on %s , port = %d"%(HOST,PORT)
while 1:
View websocketserver.py
import struct
import socket
import hashlib
import sys
from select import select
import re
import logging
class WebSocket(object):
handshake = (
@gaubert
gaubert / curl_post
Created Oct 21, 2010
quick and dirty script for posting a file content with curl (second file also changes the HTTP Header
View curl_post
#!/bin/bash
if [ ! -e "$1" ]; then
echo "Error: Need a file to post"
echo "Usage: curl_post file_to_post.file"
exit 1
fi
if [ -c "$1" ]
then
@gaubert
gaubert / lruqueue.py
Created Dec 14, 2010
0MQ lruqueue implementation
View lruqueue.py
"""
Least-recently used (LRU) queue device
Clients and workers are shown here in-process
Author: Guillaume Aubert (gaubert) <guillaume(dot)aubert(at)gmail(dot)com>
"""
import threading
@gaubert
gaubert / lruqueue2.py
Created Dec 15, 2010
lruqueue2 example implementation
View lruqueue2.py
"""
Least-recently used (LRU) queue device
Demonstrates use of the multipart messages in python
Author: Guillaume Aubert (gaubert) <guillaume(dot)aubert(at)gmail(dot)com>
"""
import threading
@gaubert
gaubert / msgqueue.py
Created Dec 15, 2010
0MQ msgqueue.py zguide implementation
View msgqueue.py
"""
Simple message queuing broker
Same as request-reply broker but using QUEUE device
Author: Guillaume Aubert (gaubert) <guillaume(dot)aubert(at)gmail(dot)com>
"""
@gaubert
gaubert / mtserver.py
Created Dec 15, 2010
0MQ zguide mtserver python implementation
View mtserver.py
"""
Multithreaded Hello World server
Author: Guillaume Aubert (gaubert) <guillaume(dot)aubert(at)gmail(dot)com>
"""
import time
import threading
import zmq
@gaubert
gaubert / mtrelay.py
Created Dec 15, 2010
0MQ zguide mtrelay implementation
View mtrelay.py
"""
Multithreaded relay
Author: Guillaume Aubert (gaubert) <guillaume(dot)aubert(at)gmail(dot)com>
"""
import threading
import zmq
@gaubert
gaubert / .lftp.mockup.rc
Created Feb 11, 2011
~/.lftp.rc parameters detailed
View .lftp.mockup.rc
########## SETTINGS
# On startup, lftp executes ~/.lftprc and ~/.lftp/rc. You can place aliases and 'set' commands
# there. Some people prefer to see full protocol debug, use 'debug' to turn the debug on.
# Certain commands and settings take a time interval parameter. It has the format Nx[Nx...], where N is time amount
# (floating point) and x is time unit: d - days, h - hours, m - minutes, s - seconds. Default unit is second. E.g.
# 5h30m or 5.5h. Also the interval can be 'infinity', 'inf', 'never', 'forever' - it means infinite interval. E.g.
# 'sleep forever' or 'set dns:cache-expire never'.
@gaubert
gaubert / simple-nginx-webdav.sh
Created Jul 4, 2011 — forked from dysinger/simple-nginx-webdav.sh
A simple nginx/webdav setup for use with things like mobile-org
View simple-nginx-webdav.sh
#!/bin/sh
# on ubuntu: need some utils & dev libs
sudo apt-get install apache2-utils openssl libssl-dev libpcre3-dev
# compile nginx
cd /tmp
curl http://nginx.org/download/nginx-0.7.64.tar.gz | tar xz
cd nginx*
./configure --with-http_ssl_module --with-http_dav_module \