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> | |
int bsearch(int left, int right, int find, int *a) { | |
if (left > right) | |
return -1; | |
int mid = (left + right) / 2; | |
if (find == a[mid]) |
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
for i in {1..100}; do echo foo; done | |
for ((i=1; i<=100; i++)); do echo foo; done | |
for `seq 1 100`; do echo foo; done | |
# while version | |
i=1; while [ $i -le 100 ]; do echo foo; i=$(($i+1)); done |
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
local store = {} | |
local function add(key, value) | |
store[key] = value | |
end | |
local function get(key) | |
return store[key] | |
end |
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
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 |
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/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 |
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
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 |
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
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 |
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
# LOL!!1 | |
alias wtf='dmesg' | |
alias onoz='cat /var/log/errors.log' | |
alias rtfm='man' | |
alias visible='echo' | |
alias invisible='cat' | |
alias moar='more' |
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 <event.h> | |
#include <evhttp.h> | |
#include <stdlib.h> | |
struct server { | |
struct event_base *base; | |
struct evhttp *http; | |
}; |
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 <stdlib.h> | |
#include <string.h> | |
struct array { | |
int pos; | |
char *pointers[1024]; | |
}; | |
static struct array arr; |