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
function doHash(str, seed) { | |
var m = 0x5bd1e995; | |
var r = 24; | |
var h = seed ^ str.length; | |
var length = str.length; | |
var currentIndex = 0; | |
while (length >= 4) { | |
var k = UInt32(str, currentIndex); | |
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
package client; | |
import org.apache.log4j.AppenderSkeleton; | |
import org.apache.log4j.Layout; | |
import org.apache.log4j.Level; | |
import org.apache.log4j.helpers.CyclicBuffer; | |
import org.apache.log4j.helpers.LogLog; | |
import org.apache.log4j.helpers.OptionConverter; | |
import org.apache.log4j.spi.ErrorCode; | |
import org.apache.log4j.spi.LoggingEvent; |
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
--- kcthread.cc.orig 2010-04-01 22:59:17.000000000 -0400 | |
+++ kcthread.cc 2010-04-01 23:04:41.000000000 -0400 | |
@@ -178,12 +178,12 @@ Mutex::Mutex(Type type) { | |
break; | |
} | |
case ERRORCHECK: { | |
- if (::pthread_mutexattr_settype(&attr, ::PTHREAD_MUTEX_ERRORCHECK) != 0) | |
+ if (::pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK) != 0) | |
throw std::runtime_error("pthread_mutexattr_settype"); | |
break; |
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
--- ttutil.c.orig 2010-03-13 00:33:29.000000000 -0500 | |
+++ ttutil.c 2010-03-13 00:34:05.000000000 -0500 | |
@@ -127,7 +127,7 @@ int ttopensockunix(const char *path){ | |
struct sockaddr_un saun; | |
memset(&saun, 0, sizeof(saun)); | |
saun.sun_family = AF_UNIX; | |
- snprintf(saun.sun_path, SOCKPATHBUFSIZ, "%s", path); | |
+ strncpy(saun.sun_path, path, sizeof(saun.sun_path)-1); | |
int fd = socket(PF_UNIX, SOCK_STREAM, 0); | |
if(fd == -1) return -1; |
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
--- tcadb.c.orig 2010-03-11 09:55:29.000000000 -0500 | |
+++ tcadb.c 2010-03-13 15:34:13.000000000 -0500 | |
@@ -2423,6 +2423,25 @@ TCLIST *tcadbmisc(TCADB *adb, const char | |
tclistdel(rv); | |
rv = NULL; | |
} | |
+ } else if(!strcmp(name, "iterrec")){ | |
+ rv = tclistnew2(1); | |
+ int ksiz; | |
+ const char *kbuf = tcbdbcurkey3(adb->cur, &ksiz); |
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
=begin | |
Message Pack vs similar utilities | |
ruby 1.8.7 (2010-04-19 patchlevel 253) [i686-darwin10.0.0], MBARI 0x6770, Ruby Enterprise Edition 2010.02 | |
Packing | |
user system total real | |
pack: bert 18.320000 0.770000 19.090000 ( 19.101583) | |
pack: bson_ext 0.850000 0.030000 0.880000 ( 0.878398) | |
pack: json_ext 2.540000 0.040000 2.580000 ( 2.582495) |
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
# nginx with memcache module... after a request the connection to memcached closes, what gives? | |
http { | |
upstream memcache { | |
server 127.0.0.1:11211; | |
keepalive 1024 single; # with this or without http://mdounin.ru/hg/ngx_http_upstream_keepalive/ | |
} | |
server { | |
listen 80; |
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
scopes[:your_composite_scope_name] = proc{ Scope.new(your.combined.scopes.here, {}) } | |
def self.your_composite_scope_name(*args) | |
scopes[:your_composite_scope_name].call(self, *args) | |
end |
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
# Spoiler... | |
# user system total real | |
# Hash Ring 4.580000 0.040000 4.620000 ( 4.785069) | |
# Fash Hash Ring 0.080000 0.000000 0.080000 ( 0.087039) | |
# | |
require 'benchmark' | |
require 'rubygems' | |
require 'faker' | |
require 'hash_ring' | |
require 'fast_hash_ring' |
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
TokyoTyrant Single Node | |
user system total real | |
inserting data 0.320000 0.170000 0.490000 ( 1.415912) | |
reading data 0.310000 0.170000 0.480000 ( 1.394186) | |
TokyoTyrant Balanced 3 nodes using Ruby C Fast Hash Ring | |
user system total real | |
inserting data 0.300000 0.170000 0.470000 ( 1.464022) | |
reading data 0.350000 0.170000 0.520000 ( 1.489997) |