Skip to content

Instantly share code, notes, and snippets.

View iwanbk's full-sized avatar
🎯
Focusing

Iwan Budi Kusnanto iwanbk

🎯
Focusing
View GitHub Profile
package main
import (
"fmt"
"github.com/iwanbk/ogric"
"log"
"os"
)
const myNick = "botku"
http://web.archiveorange.com/archive/v/1XS1vAjrtSZXwtoV7Gzb
@iwanbk
iwanbk / gist:1992013
Created March 7, 2012 08:47
multiprocess gevent wsgi server
#original code from http://pastebin.com/EDwwNhqq
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(("0.0.0.0", port))
fork()
address = socket.fromfd(s.fileno(), socket.AF_INET, socket.SOCK_STREAM)
address.listen()
@iwanbk
iwanbk / gevent-multiprocess.py
Created April 23, 2012 09:28 — forked from denik/gevent-multiprocess.py
gevent-multiprocess
import sys
from gevent import server
from gevent.baseserver import _tcp_listener
from gevent.monkey import patch_all; patch_all()
from multiprocessing import Process, current_process, cpu_count
def note(format, *args):
sys.stderr.write('[%s]\t%s\n' % (current_process().name, format%args))
@iwanbk
iwanbk / client.py
Created May 1, 2012 10:18 — forked from stevvooe/client.py
A minimal python to go json-rpc implemention, sans HTTP
import json
import socket
s = socket.create_connection(("127.0.0.1", 5090))
s.sendall(json.dumps(({"id": 1, "method": "Hello.Hello", "params": ["hello"]})))
print s.recv(4096)
"""
BOSH Client
-----------
Quite simple BOSH client used by Django-XMPPAuth
For now, it only supports the DIGEST-MD5 authentication method.
"""
import httplib, sys, random
# The upstream server doesn't need a prefix! no need for wss:// or http:// because nginx will upgrade to http1.1 in the config below
upstream yeomanserver {
server localhost:3000;
}
server {
listen 443;
server_name legionofevil.org;
root html;
#!KAMAILIO
#
# Kamailio (OpenSER) SIP Server v3.1 - default configuration script
# - web: http://www.kamailio.org
# - git: http://sip-router.org
#
# Direct your questions about this file to: <sr-users@lists.sip-router.org>
#
# Refer to the Core CookBook at http://www.kamailio.org/dokuwiki/doku.php
# for an explanation of possible statements, functions and parameters.
@iwanbk
iwanbk / gist:5856778
Created June 25, 2013 08:03
SIPML5 log
State machine: c0000_Started_2_Outgoing_X_oINVITE
SIPml-...svn=179 (line 1)
ICE servers:[{"url":"stun:23.21.150.121:3478"},{"url":"stun:216.93.246.18:3478"},{"url":"stun:66.228.45.110:3478"},{"url":"stun:173.194.78.127:19302"}]
SIPml-...svn=179 (line 1)
onGetUserMediaSuccess
SIPml-...svn=179 (line 1)
createOffer
SIPml-...svn=179 (line 1)
==session event = m_stream_audio_local_added
SIPml-...svn=179 (line 1)
@iwanbk
iwanbk / bench_client.py
Created April 23, 2012 06:33
flask with ujson & json benchmark
#!/usr/bin/env python
import timeit
import jsonrpclib
import ujson
import requests
N_TEST = 10000
server_json = jsonrpclib.Server('http://localhost:8000/json/')