This file contains hidden or 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 buildHuffmanCode(ftab) | |
if ftab.length == 1 | |
ftab | |
else | |
ftab = ftab.sort {|a,b| a[0] <=> b[0]} | |
left = ftab[0] | |
right = ftab[1] | |
freq = left[0]+right[0] | |
left = left[1].map{|x| x.merge({:code => "0"+x[:code]})} | |
right = right[1].map{|x| x.merge({:code => "1"+x[:code]})} |
This file contains hidden or 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
# Build an inverted index for a full-text search engine with Redis. | |
# Copyright (C) 2009 Salvatore Sanfilippo. Under the BSD License. | |
# USAGE: | |
# | |
# ruby invertedindex.rb add somedir/*.c | |
# ruby invertedindex.rb add somedir/*.txt | |
# ruby search your query string | |
require 'rubygems' | |
require 'redis' |
This file contains hidden or 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
#!/bin/sh | |
PIDFILE=/var/run/redis_6379.pid | |
EXEC=/usr/local/bin/redis-server | |
CONF="/etc/redis/6379.conf" | |
REDISPORT=6379 | |
case "$1" in | |
start) | |
if [ -f $PIDFILE ] |
This file contains hidden or 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
require 'rubygems' | |
require 'redis' | |
def main(opts={}) | |
r = Redis.new(opts) | |
um = 0 | |
while true do | |
newum = r.info[:used_memory] | |
if newum != um && um != 0 | |
diff = newum.to_i-um.to_i |
This file contains hidden or 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
% ssh -v -i ~/.ssh/DinamicheRosaKeyPair.pem [email protected] | |
OpenSSH_5.2p1, OpenSSL 0.9.8k 25 Mar 2009 | |
debug1: Reading configuration data /etc/ssh_config | |
debug1: Connecting to 79.125.10.167 [79.125.10.167] port 22. | |
debug1: Connection established. | |
debug1: identity file /Users/antirez/.ssh/DinamicheRosaKeyPair.pem type -1 | |
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.1p1 Debian-5ubuntu1 | |
debug1: match: OpenSSH_5.1p1 Debian-5ubuntu1 pat OpenSSH* | |
debug1: Enabling compatibility mode for protocol 2.0 | |
debug1: Local version string SSH-2.0-OpenSSH_5.2 |
This file contains hidden or 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
SET: 44318.59 requests per second | |
GET: 44149.78 requests per second | |
INCR: 46328.70 requests per second | |
LPUSH: 45325.79 requests per second | |
LPOP: 44466.67 requests per second | |
PING: 44287.61 requests per second |
This file contains hidden or 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
# Power law (log tail) distribution | |
# Copyright(C) 2010 Salvatore Sanfilippo | |
# this code is under the public domain | |
# min and max are both inclusive | |
# n is the distribution power: the higher, the more biased | |
def powerlaw(min,max,n) | |
max += 1 | |
pl = ((max**(n+1) - min**(n+1))*rand() + min**(n+1))**(1.0/(n+1)) | |
(max-1-pl.to_i)+min |
This file contains hidden or 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> | |
#include <limits.h> | |
#include <math.h> | |
unsigned long longtailprng(unsigned long min, unsigned long max, int n) { | |
unsigned long pl; | |
double r = (double)(random()&(INT_MAX-1))/INT_MAX; |
This file contains hidden or 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
Usage: redis-load ... options ... | |
host <hostname> Server hostname (default 127.0.0.1) | |
port <hostname> Server port (default 6379) | |
clients <clients> Number of parallel connections (default 50) | |
requests <requests> Total number of requests (default 10k) | |
writes <percentage> Percentage of writes (default 50, that is 50%) | |
mindatasize <size> Min data size of SET values in bytes (default 1) | |
maxdatasize <size> Min data size of SET values in bytes (default 64) | |
datasize <size> Set both min and max datasize to the same value |
This file contains hidden or 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
0 0 8335332 0 134.01M 0B | |
0 0 8335332 0 134.01M 0B | |
1272 0 8311296 -24036 134.11M 103.34K | |
2631 19 8261737 -49559 136.88M 2.77M | |
224 217 8309262 47525 137.10M 223.38K | |
89 905 8307781 -1481 136.73M -379.72K | |
359 1043 8324603 16822 135.72M -1.01M | |
293 1538 8319361 -5242 135.35M -382.36K | |
731 1045 8322341 2980 135.00M -352.77K | |
1030 679 8312372 -9969 134.87M -131.05K |
OlderNewer