This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
local config = { host="localhost", port=6379 } | |
local socket = require("socket") | |
local server = assert(socket.bind(config.host, config.port)) | |
local ip, port = server:getsockname() | |
print(string.format("listening on %s:%s", ip, port)) | |
local store = {} | |
local function add(key, value) | |
store[key] = value |
#!/usr/local/ruby/bin/ruby | |
require "rubygems" | |
require "redis" | |
require "eventmachine" | |
require "eventmachine-tail" | |
LOG = "/tmp/foo" | |
R = Redis.new(:host => "10.1.10.2") | |
class Reader < EventMachine::FileTail |
class Stats | |
QUEUES = ["bounced", "connect", "conversations", "deferred", "host", "lost", "sent"] | |
def self.lookup(pattern) | |
h = {} | |
REDIS.keys(pattern).map { |k,v| h[k] = REDIS[k] } | |
h | |
end | |
def self.day_for(ip) | |
# method should return a hash of count queues for 24 hours |
h = {} | |
Stats::QUEUES.size.times do |i| | |
a[i] = Thread.new { | |
queue = Stats::QUEUES[i-1] | |
h["#{queue}:#{ip}:24"] = return_day_for(ip,queue) | |
} | |
end |
# LOL!!1 | |
alias wtf='dmesg' | |
alias onoz='cat /var/log/errors.log' | |
alias rtfm='man' | |
alias visible='echo' | |
alias invisible='cat' | |
alias moar='more' |
#include <stdio.h> | |
#include <event.h> | |
#include <evhttp.h> | |
#include <stdlib.h> | |
struct server { | |
struct event_base *base; | |
struct evhttp *http; | |
}; |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
struct array { | |
int pos; | |
char *pointers[1024]; | |
}; | |
static struct array arr; |
typedef struct { | |
int pos; | |
int size; | |
char *data; | |
} stack; | |
#define INITIAL_SIZE 1024 | |
stack *init_stack() { | |
pos = 0; |
#!/usr/bin/perl | |
my @statuses = ("ESTABLISHED","SYN_SENT","SYN_RECV","FIN_WAIT1","FIN_WAIT2","TIME_WAIT","CLOSED","CLOSE_WAIT","LAST_ACK","CLOSING","UNKNOWN"); | |
my @ports = ( "80", "443" ); | |
my %data = (); | |
my $netstat = 'netstat -ant | awk \'$4 ~ /:(80|443)$/ && $6 != "LISTEN" { split($4,a,":"); print a[2],$6;}\' | sort | uniq -c'; | |
# initialize to 0 | |
foreach $status (@statuses) { |
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer