Skip to content

Instantly share code, notes, and snippets.

@CryptoManiac
CryptoManiac / example.ts
Last active November 20, 2022 11:59
Pooled Buffer allocator for NodeJS
import BufferPool from "./pool";
// Create pool of 2MB blocks
const Pool = new BufferPool(2 * 1024 * 1024, 1000);
// Allocate uninitialized buffer
const unsafe = Pool.allocUnsafe(1000);
// Allocate zero filled buffer
const safe = Pool.alloc(1000);
'use strict';
// Calculate N * 160 bits of hash value.
// Based on murmurhash160 by bryc (github.com/bryc)
// From: https://simonhf.wordpress.com/2010/09/25/murmurhash160/
function hash(key, bits=480) {
let result = Buffer.alloc(bits / 8);
for (let step = 0; step < bits / 160; ++step) {
@CryptoManiac
CryptoManiac / stratum-proxy.py
Created April 24, 2018 03:10
Generic NoDevfee proxy for ethereum
#!/usr/bin/python2.7
import sys
import socket
import threading
import json
from collections import OrderedDict
import binascii
import datetime
import time
#include <cassert>
#include <sys/timeb.h>
#ifdef _WIN32
# include <windows.h>
#else
# include <sys/time.h>
# include <unistd.h>
#endif
#include <sys/timeb.h>
#include <sys/types.h>
#include <vector>
#ifdef _WIN32
# include <windows.h>
#else
# include <sys/time.h>
# include <unistd.h>
#endif
#include <sys/timeb.h>
#include <sys/types.h>
#ifdef _WIN32
# include <windows.h>
#else
# include <sys/time.h>
# include <unistd.h>
#endif