Skip to content

Instantly share code, notes, and snippets.

@gitzhou
gitzhou / prime-filter.c
Created October 21, 2015 09:00
筛法求质数-C代码
// prime.c
// aaron67.cc
#include <stdio.h>
#include <string.h>
const int N = 1000000;
const int PRINT_N_INTEGER_PER_LINE = 10;
int main() {
@gitzhou
gitzhou / mutli-thread-test.java
Created October 27, 2015 09:21
java mutli-thread test
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
class MultiThread implements Runnable {
private Item item;
private CountDownLatch signal;
@gitzhou
gitzhou / two-eggs-problem.cpp
Created November 25, 2015 15:33
Problem of Two Eggs
//
// main.cpp
// two-eggs-problem
//
// Created by aaron67 on 15/2/12.
// Copyright (c) 2015年 aaron67. All rights reserved.
//
// 参考:http://ppwwyyxx.com/2013/Problem-of-Two-Eggs/
//
// 题目描述:
//
// main.cpp
// hex-to-oct
//
// Created by aaron67 on 2017/1/23.
// Copyright © 2017年 aaron67. All rights reserved.
//
#include <iostream>
#include <string>
//
// main.cpp
// hex-to-oct
//
// Created by aaron67 on 2017/1/23.
// Copyright © 2017年 aaron67. All rights reserved.
//
#include <iostream>
#include <iomanip>
@gitzhou
gitzhou / Preferences.sublime-settings
Last active March 14, 2017 16:13
My Sublime Text Settings
{
"auto_complete": true,
"auto_complete_commit_on_tab": true,
// 在选中区域搜索
"auto_find_in_selection": true,
"bold_folder_labels": true,
"color_scheme": "Packages/Color Scheme - Default/Monokai Bright.tmTheme",
"create_window_at_startup": false,
"draw_white_space": "all",
"highlight_line": true,
// https://github.com/crypto-browserify/pbkdf2
//
const crypto = require('crypto');
const hash = 'sha512'
const round = 2048
const seed_bytes = 64
var mnemonic = 'furnace tunnel buyer merry feature stamp brown client fine stomach company blossom'
var passphrase = ''
from bitsv.base58 import b58encode, b58decode
from bitsv.crypto import ECPrivateKey, sha256, hash160
from binascii import hexlify
#
# pip install bitsv
#
# https://aaron67.cc/2019/01/04/bitcoin-address/
#
print()
@gitzhou
gitzhou / test.py
Created June 8, 2020 19:02
Get local time of specific timezone from UTC
from pytz import timezone
from datetime import datetime
now = timezone('Asia/Shanghai').fromutc(datetime.utcnow())
print(now.strftime('%Y-%m-%d %H:%M:%S'))
@gitzhou
gitzhou / sign.py
Last active October 16, 2020 18:56
from ec_point_operation import curve, add, scalar_multiply
from modular_inverse import modular_multiplicative_inverse
from crypto import double_sha256
import random
def hash_to_int(message: bytes) -> int:
"""Calculate the bitcoin double-sha256 hash of the message, return as an integer"""
h = double_sha256(message)
return int.from_bytes(h, byteorder='big')