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
items { | |
dl { name => DELL6400, keyword:1 => computer, keyword:2 => DELL, keyword:3 => topseller } | |
hp { name => HP12345, keyword:1 => computer, keyword:2 => HP } | |
no { name => Nokia8210, keyword:1 => phone, keyword:2 => NOKIA } | |
} | |
// here I store keys of the items only, | |
// in reality I have denormalized most of items columns | |
keywords{ | |
computer { webpage => www.domain.com/computer , item:dl => dl , item:hp => hp } |
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
in CLI: | |
create column family a | |
with column_type = 'Standard' and | |
comparator = 'IntegerType' and | |
default_validation_class = 'UTF8Type' and | |
key_validation_class = 'IntegerType'; | |
======================= |
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 <signal.h> | |
#include <sys/time.h> | |
//#define DEBUG | |
//Default livetime is 1:30 | |
#define LIVETIME 90 |
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
Options for implementing HLL without read before write. | |
What I need: | |
I generally need something like grid / two dimentional array. | |
There will be 64, 128, 256, 512, 1024 grid "X" coordinate and 256 (because 1 byte can store 0-255 as value) grid "Y" coordinate. | |
There will be no value, but I can store there "1" (because we use PHP and it requires some value), | |
we can also store the byte value, in order to read data easier. |
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
""" | |
Simple Linear Probabilistic Counters | |
Credit for idea goes to: | |
http://highscalability.com/blog/2012/4/5/big-data-counting-how-to-count-a-billion-distinct-objects-us.html | |
http://highlyscalable.wordpress.com/2012/05/01/probabilistic-structures-web-analytics-data-mining/ | |
Installation: | |
pip install smhasher | |
pip install bitarray |
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 multiplicate2($a, $b){ | |
printf("%16b x %b\n%16b\n", $a, $b, $a * $b); | |
} | |
function multiplicate($a, $b){ | |
printf("%1s %32d x %8d = %d\n", "", $a, $b, $a * $b); | |
printf("%1s %32b x %8b\n", "", $a, $b); |
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 <stdlib.h> | |
#include <stdio.h> | |
/* | |
* Base class. It defines int area() method. | |
* The class is abstract so we did not made constructor. | |
* Calling the area() method will probably core dump. | |
*/ |
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
$ php | |
<? | |
error_reporting(E_ALL); | |
$a = 5 / 0; | |
var_dump($a); | |
<ctrl-d> |
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> | |
#define MAX 2000000000 | |
//#define IMPL 0 | |
int do_loop(int max); | |
int main(){ | |
printf("%d\n", do_loop(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
var fs = require('fs'); | |
var Q = require("q"); | |
/* | |
Q.all( | |
[ | |
Q.ninvoke(fs, "readFile", "/etc/hosts", "utf8") | |
] | |
) | |
*/ |