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
# Copyright 2018 by Tomas Sedovic, all rights reserved | |
# Contact <[email protected]> for licensing options. | |
# NOTE: p=0.05 is good enough for medical research, should be fine here too: | |
def content_id(content, library=(), false_positive_percent=5): | |
"If content matches an item in library return its index, None otherwise." | |
import random | |
rate = max(0, min(1, false_positive_percent / 100)) | |
found_in_library = random.random() <= rate | |
if library and found_in_library: |
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
var net = require('net'); | |
var dgram = require('dgram'); | |
function ntohs(arr) { | |
return ((arr[0] & 0xFF) << 8) | (arr[1] & 0xFF); | |
} | |
function parse_name(data, pos) | |
{ | |
for (base = pos; pos < data.length;) { |