Skip to content

Instantly share code, notes, and snippets.

@HelloZeroNet
HelloZeroNet / hash_dos_test.py
Created February 19, 2020 10:59
Dict key access speed test
import msgpack
import msgpack.fallback
import time
import random
def test_dict_key_access(keys):
s = time.time()
data = {}
for key in keys:
@HelloZeroNet
HelloZeroNet / summary.txt
Created November 3, 2019 19:01
git summary --line
$ git summary --line
project : ZeroNet-py3
lines : 60541
authors :
34892 shortcutme 57.6%
18225 HelloZeroNet 30.1%
1129 ZeroNet 1.9%
748 Matthew Bell 1.2%
631 Ivanq 1.0%
@HelloZeroNet
HelloZeroNet / pystone.py
Created August 8, 2019 16:26
Python3 compatible pystone
#! /usr/bin/env python3
"""
"PYSTONE" Benchmark Program
Version: Python/1.1 (corresponds to C/1.1 plus 2 Pystone fixes)
Author: Reinhold P. Weicker, CACM Vol 27, No 10, 10/84 pg. 1013.
Translated from ADA to C by Rick Richardson.
@HelloZeroNet
HelloZeroNet / test_limit.py
Last active July 18, 2019 01:22
Test opened socket and file limit in Python
from __future__ import print_function
import ctypes, socket, time
import gevent.monkey
gevent.monkey.patch_all()
print("Max stdio:", ctypes.cdll.msvcr100._getmaxstdio())
# print("Max stdio:", ctypes.cdll.msvcr100._setmaxstdio(2048))
# via https://github.com/ariccio/DuplicateFileFinder/blob/master/py_duplicate_pysummer.py
@HelloZeroNet
HelloZeroNet / bitcoin.py
Last active December 5, 2023 09:31
Bitcoin signature signing and verficiation using coincurve
import hashlib
import struct
from coincurve import PrivateKey, PublicKey
from base58 import b58encode_check, b58decode_check
from hmac import compare_digest
RECID_MIN = 0
RECID_MAX = 3
RECID_UNCOMPR = 27
LEN_COMPACT_SIG = 65
@HelloZeroNet
HelloZeroNet / test_broadcast_all.py
Last active February 25, 2018 13:55
UDP broadcast test
import gevent.monkey
import time, sys, socket, struct
gevent.monkey.patch_all(sys=True)
broadcast_port = 11112
def getMyIps():
local_ips = []
# get local ip using UDP and a broadcast address
@HelloZeroNet
HelloZeroNet / ZeroFrame.js
Created December 4, 2016 23:31 — forked from GomZik/ZeroFrame.js
ZeroFrame api ES6
const CMD_INNER_READY = 'innerReady'
const CMD_RESPONSE = 'response'
const CMD_WRAPPER_READY = 'wrapperReady'
const CMD_PING = 'ping'
const CMD_PONG = 'pong'
const CMD_WRAPPER_OPENED_WEBSOCKET = 'wrapperOpenedWebsocket'
const CMD_WRAPPER_CLOSE_WEBSOCKET = 'wrapperClosedWebsocket'
class ZeroFrame {
constructor(url) {
import zipfile, time
import cStringIO as StringIO
data = StringIO.StringIO()
req = open("archive.zip@ref=master", "rb")
while True:
buff = req.read(1024)
if not buff:
break
data.write(buff)
import time
import json
import os
import sys
import re
import socket
from subprocess import call
from bitcoinrpc.authproxy import AuthServiceProxy
@HelloZeroNet
HelloZeroNet / handler.py
Created May 8, 2016 08:44
Http version check disabled gevent websocket handler
# Modified: Werkzeug Debugger workaround in run_websocket(self):
import base64
import hashlib
import warnings
from gevent.pywsgi import WSGIHandler
from .websocket import WebSocket, Stream
from .logging import create_logger