Skip to content

Instantly share code, notes, and snippets.

View Attumm's full-sized avatar

Attumm

  • Amsterdam
View GitHub Profile
from confluent_kafka import Consumer, KafkaError
import time
c = Consumer({'bootstrap.servers': 'localhost:9092', 'group.id': 'first',
'default.topic.config': {'auto.offset.reset': 'smallest'}})
c.subscribe(['test_once_ok_ok_ok'])
start = time.time()
running = True
items = []
import asyncio
@asyncio.coroutine
def do_three_things(n):
print("{} start".format(n))
message = yield from create_message_one(n)
print(message)
message = yield from create_message_two(n)
print(message)
message = yield from create_message_three(n)
import sys
import subprocess
import shlex
import time
import threading
interval = 2 # in seconds
command = 'ping 8.8.8.8'
def print_(s):
import os
import re
import socket
import ssl
import sys
import time
from collections import namedtuple
import ConfigParser
import httplib
import time
from collections import deque
def time_lookup(l, i):
start = time.time()
r = i in l
return time.time() - start
def dict_lookup(d, i):
start = time.time()
package main
//golang implentation of heap algo
//https://en.wikipedia.org/wiki/Heap%27s_algorithm
//Result datastructure should be changed to fit your needs
func permutations(a []int) [][]int {
n := len(a)
result := [][]int{}
c := make([]int, n)
# start 10 workers
# python worker.py -w 10
# produce 100 item with
# python worker.py -p 100
import sys
import time
import syslog
package main
import "fmt"
func main() {
result := make(chan string, 1000)
entrophy := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
go combinations(entrophy, 7, result)
i := 1
for val := range result {
import time
from workers import RedisQueue
from workers import startapp
config = {
"namespace": "removeme",
"key": "tasks",
"redis_config": {},
"maxsize": 100
}
@Attumm
Attumm / logs.py
Last active August 28, 2018 23:15
import sys
from syslog import syslog as syslog_func
from datetime import datetime
def stdout_func(msg):
sys.stdout.write(msg + '\n')
class Logs: