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
2017-1-2 | 59589 | |
---|---|---|
2017-1-3 | 61814 | |
2017-1-4 | 61589 | |
2017-1-5 | 62071 | |
2017-1-6 | 61665 | |
2017-1-9 | 61700 | |
2017-1-10 | 62132 | |
2017-1-11 | 62446 | |
2017-1-12 | 63954 | |
2017-1-13 | 63652 |
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 csv | |
import sys | |
if __name__ == '__main__': | |
if len(sys.argv) != 3: | |
sys.exit("%s <csv-file> <lines>" % sys.argv[0]) | |
infile, total = sys.argv[1], int(sys.argv[2]) | |
basename = infile.split('.csv')[0] | |
output_count = 0 | |
output_handler, file_handler = None, None |
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
### Keybase proof | |
I hereby claim: | |
* I am lucindo on github. | |
* I am lucindo (https://keybase.io/lucindo) on keybase. | |
* I have a public key ASBTuwODc0m6t_FcXwRVlIQKzAkgfuWI6ZNIz3TS_ZxP9Ao | |
To claim this, I am signing this object: |
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 java.util.Properties; | |
import org.apache.log4j.PropertyConfigurator; | |
class MyDummyApp { | |
public static void main(String []args) { | |
Properties properties=new Properties(); | |
properties.setProperty("log4j.rootLogger","DEBUG,stdout"); | |
properties.setProperty("log4j.rootCategory","DEBUG"); | |
properties.setProperty("log4j.appender.stdout", "org.apache.log4j.ConsoleAppender"); |
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
## Backoff for resquests.Session | |
# | |
# A common pattern for me when using the requests library is | |
# to make several HTTP requests to an endpoint using a Session | |
# in order to mantain an open connection to the server. | |
# | |
# Many times I had to set requests.adapters.DEFAULT_RETRIES to | |
# some value in order to avoid transient errors that a simple | |
# retry would take care of. | |
# |
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 | |
from collections import deque | |
from Queue import Queue | |
# Adding some control to Queue class | |
class ProcessQueue(Queue): | |
""" Extends Queue to add some control methods | |
Assumes only blocking put and get will be used | |
There's 2 common patterns to consume items from Queue | |
that are noisy and/or error prone: |
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 | |
# Simple Timer | |
class Timer: | |
def __init__(self): | |
self.reset() | |
def reset(self): | |
self._start = time.time() | |
def elapsed(self): # elapsed time in seconds (float) |
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
# Helper class for statistics | |
# see: http://www.johndcook.com/blog/standard_deviation/ | |
class Stats: | |
""" Uses Welford's method to calculate stats. | |
Assumes positive values. | |
It's not thread safe | |
stats = Stats("ConnectionTimeStats") | |
stats.add(0.223) | |
stats.add(1.343) |
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: https://www.youtube.com/watch?v=BHhA_ZKjyxo | |
# session management | |
tmux ls (or tmux list-sessions) | |
tmux new -s session-name | |
Ctrl-b d Detach from session | |
tmux attach -t [session name] | |
tmux kill-session -t session-name | |
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 <sys/klog.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
int main(void) { | |
int logsize = klogctl(10 /* SYSLOG_ACTION_SIZE_BUFFER */, 0, 0); | |
char *bufp = malloc(logsize); | |
klogctl(3 /* SYSLOG_ACTION_READ_ALL */, bufp, logsize); | |
write(1, bufp, logsize); |
NewerOlder