Skip to content

Instantly share code, notes, and snippets.

View 140am's full-sized avatar

Manuel Kreutz 140am

View GitHub Profile
@140am
140am / ipc_test.py
Last active June 26, 2023 14:46
Simple Python / ØMQ IPC (Inter Process Communication) performance benchmark
""" Simple IPC benchmark test
Test throughput of 512 KB messages sent between two python processes using:
- multiprocessing pipe
- zeroMQ PUSH/PULL
- zeroMQ DEALER/DEALER
Result:
@140am
140am / gist:7463028
Last active May 3, 2022 16:12
Exampel of arrow Key Navigation via Statechart events in JavaScript. from http://stativ.us
$(document).bind('keydown', function(evt){
var myStatechart = window.myStatechart, kid,
keyKey = {'38':'Up', '39': 'Right', '40':'Down', '37': 'Left', '13': 'Enter'};
console.log('Which: ', evt.which);
kid = keyKey[evt.which];
if (kid) myStatechart.sendEvent('key'+kid);
});
@140am
140am / shimo_vpn.py
Created December 3, 2010 17:24
monitors an VPN connection and controls OSX Shimo.app in case of problems
#!/usr/bin/python
# OSX VPN monitor
#
# requires:
# - http://www.chungwasoft.com/shimo/
# - http://growl.info/
# - http://appscript.sourceforge.net/
import sys
import socket
""" Python HTTP client implementations benchmark
# Bandwidth Throughput
INFO:__main__:TEST: pycurl
INFO:__main__:pycurl: Returned status in 17 ms
INFO:__main__:Completed read of 1527248057 bytes in 15410 ms at 756 Mbps
INFO:__main__:TEST: urllib2
INFO:__main__:urllib2: Returned status in 18 ms
@140am
140am / Dockerfile
Created September 24, 2019 02:06
emacs in docker
FROM ubuntu:16.04
MAINTAINER Manuel Kreutz <manuel@140.am>
RUN apt-get update && \
apt-get install -y curl git software-properties-common build-essential && \
apt-get clean
# install emacs 26 from ppa
RUN add-apt-repository ppa:kelleyk/emacs && \
@140am
140am / observer.py
Created June 18, 2011 08:35
python observer pattern example
import pdb
import time
import threading
class Event(object):
pass
class Observable(object):
def __init__(self):
self.callbacks = []
@140am
140am / pytumblr_example.py
Created January 23, 2014 06:24
Example of using the Python Tumblr API v2 Client
""" Tumblr API Example - Python CLI
"""
import oauth2
import urlparse
import pytumblr
REQUEST_TOKEN_URL = 'http://www.tumblr.com/oauth/request_token'
AUTHORIZATION_URL = 'http://www.tumblr.com/oauth/authorize'
ACCESS_TOKEN_URL = 'http://www.tumblr.com/oauth/access_token'
@140am
140am / gist:563342
Last active August 12, 2016 22:38
print SQL CREATE from "sqlalchemy" DB tables
>>> from sqlalchemy.schema import CreateTable
>>> print CreateTable(model.TrafficLog.__table__)
@140am
140am / butler_service.py
Last active August 12, 2016 22:35
Example of using "butler" Python library to communicate between multiple processes (local or distributed)
""" Example of how to get started with the `butler` library for RPC calls
Defines 3 example classes we want to expose for RPC use (ServiceA, ServiceB, ServiceC)
which all have a 'test' method.
Start a Router and register all the Service classes (`services_objects`)
python butler_service.py --service
Start only a Router process:
@140am
140am / test_amqp.py
Last active August 12, 2016 22:28
Example of a helper to listen & debug the OpenStack MQ event bus
import logging
import json
import dateutil.parser
import pika
FORMAT = '%(asctime)-15s %(levelname)s: %(message)s'
logging.basicConfig(
format = FORMAT,
level = logging.DEBUG
)