Skip to content

Instantly share code, notes, and snippets.

View rgs1's full-sized avatar
🎯
Focusing

Raúl Gutiérrez Segalés rgs1

🎯
Focusing
View GitHub Profile
// gcc -Wall -I/usr/include/zookeeper -lzookeeper_mt get.c -o get
#include <errno.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include "zookeeper.h"
from kazoo.client import KazooClient
k = KazooClient("localhost:2181", timeout=5)
k.start()
k.create("/test", "")
# or k.set("/test", "")
@rgs1
rgs1 / gist:9356362
Created March 4, 2014 21:40
A write request's journey in ZooKeeper
client → write request → zk_server_1
write request is sent to the leader
leader fans out a transaction proposal to all followers
↓ ↓ ↓ ↓
def gen(v)
if v.length == 1
yield v
end
v.each { |i|
gen(v.slice(1, v.length)) { |v1|
yield [i] + v1
}
}
end
def gen(v)
if v.length == 1
yield v
end
v.each { |i|
gen(v.select { |j| j != i }) { |v1|
yield [i] + v1
}
}
end
✔ ruby gen.rb mi nombre es alki
mi nombre es alki
mi nombre alki es
mi es nombre alki
mi es alki nombre
mi alki nombre es
mi alki es nombre
nombre mi es alki
nombre mi alki es
nombre es mi alki
#include <ctype.h>
#include <stdio.h>
#include <string.h>
static int match(const char *query, const char *username);
static void do_search(const char *query, char **usernames, int ulen);
static int lex_smaller(const char *a, const char *b);
void typeahead(char **usernames, int usernames_length, char **queries, int queries_length) {
int i;
diff --git a/kazoo/tests/test_client.py b/kazoo/tests/test_client.py
index 2c7dcd16bf3b..a2c670dac6ea 100644
--- a/kazoo/tests/test_client.py
+++ b/kazoo/tests/test_client.py
@@ -1,3 +1,4 @@
+import socket
import sys
import threading
import time
@@ -222,7 +223,7 @@ class TestConnection(KazooTestCase):
commit ff99c46b4db900ca7710771a7f7cb5f65e3416e9
Author: Raul Gutierrez S <rgs@itevenworks.net>
Date: Fri Apr 25 14:06:20 2014 -0700
Reset watches when entering CONNECTED state
Signed-off-by: Raul Gutierrez S <rgs@itevenworks.net>
diff --git a/kazoo/client.py b/kazoo/client.py
index fb32b97782a5..45908dfad167 100644
/*
* Local Variables:
* compile-command: "gcc -Wall -I/usr/include/zookeeper -lzookeeper_mt states.c -o states"
* End:
*/
#include <errno.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>