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 time | |
class TimeIt(object): | |
def __init__(self, name): | |
self.name = name | |
def __enter__(self, *args, **kwargs): | |
self.start_t = time.time() | |
def __exit__(self, *args, **kwargs): |
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
#include <stdio.h> | |
#include <hiredis/hiredis.h> | |
int redis_set(char *key, char *value) { | |
redisContext *c = redisConnect("127.0.0.1", 6379); | |
if (c != NULL && c->err) { | |
printf("Error connecting to redis: %s\n", c->errstr); | |
return -1; | |
} | |
redisCommand(c, "SET %s %s", key, value); |
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
/* read stuff from udp (on given port) and write it to stdout */ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <strings.h> | |
#include <sys/socket.h> | |
#include <netinet/in.h> | |
int main(int argc, char *argv[]) |
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 | |
import time | |
import signal | |
import sys | |
import redis | |
import socket | |
def stop(sig, frame): | |
sys.stdout.flush() # flush whatever is there! | |
sys.stderr.write("Stopping due to {}\n".format(sig)) |
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
def human_time_string(delta): | |
''' | |
Return a nice human readable "X days[, Y hours [and Y minutes]]" string | |
for a given datetime.timedelta | |
''' | |
minutes = delta.seconds // 60 | |
hours = delta.seconds // 3600 | |
minutes -= hours * 60 # subtract hours | |
days = delta.days |
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 sys | |
import redis | |
import time | |
i = 0 | |
conn = redis.Connection('localhost', 6379) | |
start_t = time.time() | |
for line in sys.stdin.xreadlines(): |
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 time | |
timings = ( | |
(1, 'up'), | |
(2, 'down'), | |
(7, 'up'), | |
(8, 'down'), | |
(13, 'up'), | |
(14, 'down'), | |
(19, 'up'), |
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 threading | |
import time | |
from functools import wraps | |
FN_LOCKS = {} | |
class Lock(object): | |
def __init__(self, func_id): | |
global FN_LOCKS |
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
user www-data; | |
worker_processes auto; | |
pid /run/nginx.pid; | |
events { | |
worker_connections 768; | |
# multi_accept on; | |
} | |
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
# This is a list of Circle CI environment variables, pulled on Feb 9th 2017 @ 00:10 | |
# This can be useful for example when running tests inside a docker and you wish to | |
# pass environment variables into the docker via docker-compose. That's why I made | |
# this list by starting a build with SSH enabled, and executing: | |
# | |
# ubuntu@box103:~$ env|grep ^CI|cut -d\= -f1|sort -u | |
CI | |
CI_PULL_REQUEST | |
CI_PULL_REQUESTS |