Skip to content

Instantly share code, notes, and snippets.

View hartred's full-sized avatar

Artiom Semashko hartred

  • Poland, Wroclaw
View GitHub Profile
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/home/asemashko/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
@hartred
hartred / sip_example.py
Created March 23, 2018 11:10
Twisted SIP protocol example
from twisted.internet import reactor
from twisted.protocols import sip
from twisted.internet.protocol import ServerFactory
class SipProxy(sip.Proxy):
def __init__(self):
sip.Proxy.__init__(self,host='192.168.1.3',port=5060)
self.tries=0
def handle_request(self,message,addr):
import importlib
import os
SETTINGS_MODULE = os.environ('SETTINGS_MODULE')
class Borg:
_shared_state = {}
@hartred
hartred / tests.py
Created August 16, 2016 08:49
custom decorator for writing profiling information to a file
def profile_memory(output):
if isinstance(output, str):
output = open(output, 'w')
def decorator(func):
@profile(stream=output)
@functools.wraps(func)
def wrapper(*args, **kwargs):
result = func(*args, **kwargs)
return result