Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
#
# Bash script to setup headless Selenium (uses Xvfb and Chrome)
# (Tested on Ubuntu 12.04) trying on ubuntu server 14.04
# Add Google Chrome's repo to sources.list
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee -a /etc/apt/sources.list
# Install Google's public key used for signing packages (e.g. Chrome)
# (Source: http://www.google.com/linuxrepositories/)

Akka Cluster Implementation Notes

Slightly disorganized but reasonably complete notes on the algorithms, strategies and optimizations of the Akka Cluster implementation. Could use a lot more links and context etc., but was just written for my own understanding. Might be expanded later.

Links to papers and talks that have inspired the implementation can be found on the 10 last pages of this presentation.

Akka Gossip

Gossip state

This is the Gossip state representation:

import sys
import gevent
from gevent.monkey import patch_all; patch_all()
from gevent import server, event, socket
from multiprocessing import Process, current_process, cpu_count
"""
Simple multiprocess StreamServer that proxies messages between clients.
Avoids using a multiprocessing.Event since it blocks on a semaphore.
@bobofzhang
bobofzhang / gist:5612065
Last active December 17, 2015 12:49
read&write csv in python
import csv
ifile = open('test.csv', "rb")
reader = csv.reader(ifile)
rownum = 0
for row in reader:
# Save header row.
if rownum == 0:
header = row
else:
@bobofzhang
bobofzhang / plot_skies.R
Created December 5, 2012 12:16 — forked from cjbayesian/plot_skies.R
Observing Dark Worlds visualization
################## Plot training skies ###################
##
## corey.chivers@mail.mcgill.ca
##
##########################################################
## calculate a vector given
## x,y,e1,e2
gal_line<-function(g,scale=100)
{
@bobofzhang
bobofzhang / gist:4214743
Created December 5, 2012 11:02 — forked from tomerfiliba/gist:3698403
get the indexes of the top n elements in a numpy 2d-array
import numpy as np
import bottleneck as bn
def top_n_indexes(arr, n):
idx = bn.argpartsort(arr, arr.size-n, axis=None)[-n:]
width = arr.shape[1]
return [divmod(i, width) for i in idx]
np.random.seed(47)
# 参考URL: http://d.hatena.ne.jp/gmaxlab/20090329/1238329567
import httplib, ssl
#HTTPで上手くいく場合
http_session = httplib.HTTPConnection("squidのドメイン", 8080)
http_session.request("GET", "http://yahoo.co.jp/")
r1 = http_session.getresponse()
print r1.status, r1.reason
#HTTPSで失敗する場合
@bobofzhang
bobofzhang / gist:4166894
Created November 29, 2012 04:57 — forked from tomerfiliba/gist:3698403
get the indexes of the top n elements in a numpy 2d-array
import numpy as np
import bottleneck as bn
def top_n_indexes(arr, n):
idx = bn.argpartsort(arr, arr.size-n, axis=None)[-n:]
width = arr.shape[1]
return [divmod(i, width) for i in idx]
np.random.seed(47)
@bobofzhang
bobofzhang / gist:3903608
Created October 17, 2012 03:51
tcp server in akka&scalla, create actor for each connected client.
package test
import akka.actor._
class Slave extends Actor{
def receive = {
case IO.Read(socket, bytes) =>
println("Slave Received incoming data from socket")
case IO.Closed(socket: IO.SocketHandle, cause) =>