View nn.h
#ifndef __NN_H
#define __NN_H
/* Data structures.
* Nets are not so 'dynamic', but enough to support
* an arbitrary number of layers, with arbitrary units for layer.
* Only fully connected feed-forward networks are supported. */
struct AnnLayer {
int units;
double *output; /* output[i], output of i-th unit */
View memorydoctor.md

127.0.0.1:6379> memory doctor

"Hi Sam, I can't find any memory issue in your instance. I can only account for what occurs on this base."

127.0.0.1:6379> flushall

OK

127.0.0.1:6379> memory doctor

View mem.txt
127.0.0.1:6379> memory help
1) "MEMORY USAGE <key> [SAMPLES <count>] - Estimate memory usage of key"
2) "MEMORY OVERHEAD - Show memory usage details"
127.0.0.1:6379> memory overhead
1) "total.allocated"
2) (integer) 1014672
3) "startup.allocated"
4) (integer) 962496
5) "replication.backlog"
View crash.txt
------ DUMPING CODE AROUND EIP ------
Symbol: debugCommand (base: 0x1075e6dd0)
Module: /Users/antirez/hack/redis/src/./redis-server (base 0x10759a000)
$ xxd -r -p /tmp/dump.hex /tmp/dump.bin
$ objdump --adjust-vma=0x1075e6dd0 -D -b binary -m i386:x86-64 /tmp/dump.bin
------
69047:M 09 Sep 10:52:18.277 # dump of function (hexdump of 1360 bytes):
554889e54157415641554154534881ec881000004989fe4c8b251a5207004d8b24244c8965d0418b5e3083fb01752a4c3b65d00f85ee0d0000488d35e973
06004c89f74881c4881000005b415c415d415e415f5de9c7c1fcff4d8b6e38498b45084c8b7808488d35ff7306004c89ffe87ccb050085c00f847f020000
488d35197a06004c89ffe865cb050085c00f843d040000488d350b7a06004c89ffe84ecb050085c00f84a4030000488d35fc7906004c89ffe837cb050085
View gist:25095acfde328bcc139640893e33c11f
----- DUMPING CODE AROUND EIP ------
Symbol: debugCommand (base: 0x4624c0)
Module: ./redis-server *:6379 (base 0x400000)
$ xxd -r -p /tmp/dump.hex /tmp/dump.bin
$ objdump --adjust-vma=0x4624c0 -D -b binary -m i386:x86-64 /tmp/dump.bin
------
21015:M 08 Sep 23:12:22.833 # dump of function (hexdump of 592 bytes):
415741564155415455534889fb4881ec58100000448b673064488b042528000000488984244810000031c04183fc010f847b0300004c8b6f38be22834e00498b4508488b68084889efe852d5fbff85c00f84fa010000be46454f004889efe83dd5fbff85c00f8465010000be4f454f004889efe828d5fbff85c00f8488010000be57454f004889efe813d5fbff85c00f8473010000be1be74f004889efe8fed4fbff85c00f845e040000be69454f004889efe8e9d4fbff85c00f84f10c0000be77454f004889efe8d4d4fbff85c00f84ec030000be9a454f004889efe8bfd4fbff85c00f84d7020000be07874e004889efe8aad4fbff85c00f85420300004183fc030f842b060000be22464f004889efe88bd4fbff85c0750e418d4424fd83f8010f86c9060000be3c464f004889efe86cd4fbff85c0750a4183fc020f8424080000be43464f004889efe851d4fbff85c00f85d90300004183fc030f84c0080000be5b4
View bla.c
dictEntry *dictFind(dict *d, const void *key)
{
dictEntryVector *dv;
unsigned int h, idx, table;
if (d->ht[0].used + d->ht[1].used == 0) return NULL; /* dict is empty */
if (dictIsRehashing(d)) _dictRehashStep(d);
h = dictHashKey(d, key);
for (table = 0; table <= 1; table++) {
idx = h & d->ht[table].sizemask;
View gist:761649fa91df0ed594f75effbaa6d77c
./redis-check-rdb dump.rdb :rdb-check*: ??
[offset 0] Checking RDB file dump.rdb
[offset 32] AUX FIELD redis-ver = '999.999.999'
[offset 46] AUX FIELD redis-bits = '64'
[offset 58] AUX FIELD ctime = '1467380086'
[offset 73] AUX FIELD used-mem = '1049664'
[offset 75] Selecting DB ID 0
--- RDB ERROR DETECTED ---
[offset 4113] Internal error in RDB reading function at rdb.c:468 -> Unknown RDB string encoding type 14
[additional info] While doing: read-object-value
View weighted_random_ele.md

Random weighted element with Redis sorted sets

Imagine you have elements A, B and C with weights 1, 2 and 3. You compute the sum of the weights, which is 1+2+3 = 6

At this point you add all the elements into a sorted set using this algorithm:

SUM = ELEMENTS.TOTAL_WEIGHT // 6 in this case.
SCORE = 0
View convert.c
#include <stdio.h>
#include <limits.h>
int main(void) {
int a;
unsigned int b;
a = -10;
printf("Before: %d\n", a);