Skip to content

Instantly share code, notes, and snippets.

This file has been truncated, but you can view the full file.
(module
(type $0 (func (param i32 i32)))
(type $1 (func (param i32 i32 i32 i32 i32 i32) (result i32)))
(type $2 (func (param i32)))
(type $3 (func (result i32)))
(type $4 (func (param i32 i32 i32 i32) (result i32)))
(type $5 (func (param i32 i32 i32) (result i32)))
(type $6 (func))
(type $7 (func (param i32) (result i32)))
(type $8 (func (param i32 i32 i32)))
@chjj
chjj / fisqrt.js
Last active March 27, 2017 21:35
// Fast inverse square root in javascript
// https://en.wikipedia.org/wiki/Fast_inverse_square_root#Overview_of_the_code
// Example:
// > 1 / Math.sqrt(0.15625)
// 2.5298221281347035
// > Math.pow(0.15625, -0.5)
// 2.5298221281347035
// > Q_rsqrt(0.15625)
// 2.5254863388218056
78d841612ec3cfa069040348a45bbb0eca7006cdc01ed4be18d51ee8c0fd07bf
d2fe25f0ecc567158923131f12ab10b370463cebace765a0f9bfc4b3e655b183
3120a3bef7c2d904d6742c375214594420e90f953d54d391ccaefdce5ae60910
$ node net.js
writing pub
received pub: 026c975cf8cffd1fe2109aa042e2800eb8358864bb7b4961386cb95f3d98355d97 (33)
writing greeting
received res
connected
SingleFundingResponse {
  channelID: 0,
 channelDerivationPoint: ,
function serializeList(items) {
var size = 0;
var i, p, data;
for (i = 0; i < items.length; i++)
size += 4 + items[i].length;
data = new Buffer(size);
p = 0;
# Track fedex/ups/usps/iparcel/upsmi packages.
track-package() {
local open track fedex ups usps len url i \
urls upsmi iparcel iparcel_ usps_ dhl ontrac
if test -z "$1"; then
return 1
fi
if test "$1" = 'open'; then
@chjj
chjj / scrypt.js
Last active November 18, 2018 04:09
javascript scrypt implementation
/*!
* scrypt
* Copyright (c) 2016, Christopher Jeffrey (MIT License).
*
* Ported from:
* https://github.com/Tarsnap/scrypt/blob/master/lib/crypto/crypto_scrypt-ref.c
*
* Copyright 2009 Colin Percival
* All rights reserved.
*
@chjj
chjj / bitcoin.md
Created April 16, 2016 09:52
The bitcoin paper in markdown (because PDFs suck)

Bitcoin: A Peer-to-Peer Electronic Cash System

Satoshi Nakamoto satoshin@gmx.com (www.bitcoin.org)

Abstract. A purely peer-to-peer version of electronic cash would allow online payments to be sent directly from one party to another without going through a financial institution. Digital signatures provide part of the solution, but the main benefits are lost if a trusted third party is still required to prevent double-spending. We propose a solution to the double-spending problem using a peer-to-peer network. The network timestamps transactions by hashing them into

'use strict';
// original: https://gist.github.com/indutny/8d0f5376ee643962a9f0
const BN = require('bn.js');
const elliptic = require('elliptic');
const bcoin = require('bcoin');
const ecdsa = new elliptic.ec('secp256k1');
/**
* Hashes signed by satoshi which do not appear on the blockchain.
* All of these hashes and signatures verify against satoshi's original public key of:
* 0411db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5cb2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3
*
* First TX in bitcoin history:
* https://blockchain.info/tx/f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16?show_adv=true
*
* The pubkey used to redeem the funds:
* https://blockchain.info/tx-index/14862/0