This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/stackexchange/__init__.py b/stackexchange/__init__.py | |
index c257838..32e3fb7 100644 | |
--- a/stackexchange/__init__.py | |
+++ b/stackexchange/__init__.py | |
@@ -542,7 +542,7 @@ through here.""" | |
try: | |
if isinstance(ob, datetime.datetime): | |
return str(time.mktime(ob.timetuple())) | |
- elif isinstance(ob, str): | |
+ elif isinstance(ob, basestring): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import collections | |
import ctypes | |
import ctypes.util | |
# bit masks | |
IN_ISDIR = 0x40000000 | |
IN_ALL_EVENTS = 0xfff | |
class inotify_event_struct(ctypes.Structure): | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python port of half duplex FIFO program : http://developers.sun.com/solaris/articles/named_pipes.html | |
import sys | |
import config | |
def main(): | |
if len(sys.argv) < 2: | |
print 'Usage : %s <string to be sent to the server>' % sys.argv[0] | |
sys.exit(0) | |
wr = open(config.HALF_DUPLEX, 'wb') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Michael Kerrisk : "The Linux Programming Interface" CH.44 : sequence number server(Python Implementation) | |
# fifo_seqnum_client | |
import atexit | |
import os | |
import struct | |
import sys | |
import config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://en.wikipedia.org/wiki/Bloom_filter#Counting_filters | |
# http://www.michaelnielsen.org/ddi/why-bloom-filters-work-the-way-they-do/ | |
import hashlib | |
class BloomFilter(object): | |
def __init__(self, m, k): | |
self.m = m | |
self.k = k | |
self.array = [0 for i in range(m)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# http://www.rabbitmq.com/tutorials/tutorial-two-python.html | |
import pika | |
import sys | |
connection = pika.BlockingConnection(pika.ConnectionParameters( | |
host='localhost')) | |
channel = connection.channel() | |
message = ' '.join(sys.argv[1:]) or "Hello World!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# zabbix_get.py : Python port of zabbix_get | |
# http://www.zabbix.com/documentation/1.8/protocols/agent | |
# http://www.zabbix.com/wiki/doc/tech/proto/zabbixagentprotocol | |
import argparse | |
import socket | |
import struct | |
import sys | |
def str2packed(data): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pika.adapters import BlockingConnection | |
connection = BlockingConnection() | |
channel = connection.channel() | |
def callback(ch, method, properties, body): | |
print " [x] Received %r" % (body,) | |
channel.basic_consume(callback, | |
queue='test_queue', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://basho.com/blog/technical/2012/10/16/Basho-Package-Repos-Now-Online/ | |
$ curl http://apt.basho.com/gpg/basho.apt.key | sudo apt-key add - | |
% Total % Received % Xferd Average Speed Time Time Time Current | |
Dload Upload Total Spent Left Speed | |
100 1016 100 1016 0 0 1407 0 --:--:-- --:--:-- --:--:-- 4861 | |
OK | |
$ sudo bash -c "echo deb http://apt.basho.com `lsb_release -sc` main > /etc/apt/sources.list.d/basho.list" | |
$ sudo apt-get update | |
... | |
Ign http://apt.basho.com precise/main Translation-en_US |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The Linux Programming Interface Listing 57-6 | |
$ python ud_ucase_sv.py & | |
[1] 437 | |
$ python ud_ucase_cl.py hello world | |
Server received 5 bytes from /tmp/ud_ucase.452 | |
Response 1 : HELLO | |
Server received 5 bytes from /tmp/ud_ucase.452 | |
Response 2 : WORLD | |
$ python ud_ucase_cl.py 'long message' | |
Server received 10 bytes from /tmp/ud_ucase.763 |
OlderNewer