Skip to content

Instantly share code, notes, and snippets.

View snahor's full-sized avatar

Hans Roman snahor

  • Wakanda
View GitHub Profile
@eykd
eykd / pycon_2014.md
Last active August 29, 2015 13:59
PyCon 2014 notes

Friday, April 11

DNS

  • Lynn Root
  • roguelynn.com
  • roguelynn-spy.herokuapp.com

Use scapy python library for sniffing network traffic. Chrome does one DNS request for each autocomplete guess. Interesting.

#!/usr/bin/env python
# vim: ai ts=4 sts=4 et sw=4 encoding=utf-8
import time
import pygsm
import Queue
from rapidsms.message import Message
from rapidsms.connection import Connection
@maxpert
maxpert / hash_test.go
Created March 16, 2015 02:18
JumpConsistentHash
package main
import "fmt"
type hash_function func (uint64, int32) int32
func main() {
for j := 1; j < 32; j++ {
simulate_rebalance("JumpConsistentHash", 32, int32(32 + j), JumpConsistentHash)
simulate_rebalance("ModConsistentHash", 32, int32(32 + j), ModConsistentHash)
import sys
from zmq import FORWARDER, PUB, SUB, SUBSCRIBE
from zmq.devices import Device
if __name__ == "__main__":
usage = 'usage: chat_bridge pub_address sub_address'
if len (sys.argv) != 3:
print usage
sys.exit(1)
import hashlib
import base64
import hmac
import time
def _decrypt_cookie(name, value, cookie_secret, include_name=True):
def _cookie_signature(*parts):
hash = hmac.new(cookie_secret,
digestmod=hashlib.sha1)
@bdarnell
bdarnell / result_collector.py
Created December 14, 2010 20:27
result_collector.py
import functools
import logging
import sys
class ResultCollector(object):
'''Like a BarrierCallback, but saves results passed to the callback.
>>> rc = ResultCollector()
>>> cb_foo = rc.get_callback('foo')
>>> cb_bar = rc.get_callback('bar')
@msabramo
msabramo / new_gist.py
Created January 3, 2011 06:42
Take input from stdin and create a new public gist with it
#!/usr/bin/env python
import getpass, mechanize, optparse, os.path, sys
parser = optparse.OptionParser()
parser.add_option('--login')
parser.add_option('--password')
parser.add_option('--filename')
parser.add_option('--description')
parser.add_option('--private', action='store_true', default=False)
@tsoporan
tsoporan / results.py
Created June 23, 2011 03:44 — forked from lrvick/results.py
Get async celery results from nested subtasks as they complete
from tasks import task1
def get_results(queries):
query_procs = task1.delay(queries).get()
tasks = []
for query_proc in query_procs:
tasks.extend(query_proc.subtasks)
while tasks:
current_task = tasks.pop(0)
@pjjw
pjjw / install-hiphop-fresh.sh
Created August 8, 2011 01:30 — forked from kamermans/install-hiphop-fresh.sh
Script for installing and compiling HipHop for PHP on a fresh install of Ubuntu 11.04 x64
#!/bin/bash
# HipHop for PHP scripted installation
# by Steve Kamerman, July 12, 2011
echo -e "\e[00;31m**** Installing Prerequisites\e[00m"
sudo apt-get --yes install autoconf binutils-dev ccache cmake g++ gcc git-core libboost-dev libboost-filesystem-dev libboost-program-options-dev libboost-system-dev libbz2-dev libcap-dev libc-client2007e-dev libcurl4-openssl-dev libgd2-xpm-dev libgoogle-perftools-dev libicu-dev libmcrypt-dev libmemcached-dev libmysqlclient-dev libncurses-dev libonig-dev libpcre3-dev libreadline-dev libtbb-dev libtool libxml2-dev memcached openssl php5-imagick php5-mcrypt wget zlib1g-dev
echo -e "\e[00;31m**** Getting HIPHOP in 5 seconds ****\e[00m"
@sjhewitt
sjhewitt / gist:1392377
Created November 24, 2011 21:48
Thoonk Listener Mixin
class ListenerMixin(object):
def __init__(self):
self.handlers = {}
def _channels_for_feed(self, name):
return ("feed.publish:"+name, "feed.edit:"+name, "feed.retract:"+name,
"feed.position:"+name, "job.finish:"+name)
def subscribe(self, channels):
"""Subclasses should override this to subscribe to channels"""