Skip to content

Instantly share code, notes, and snippets.

Christopher Jeffrey (JJ) chjj

Block or report user

Report or block chjj

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ser-list.js
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;
View track.sh
# 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 Nov 18, 2018
javascript scrypt implementation
View scrypt.js
/*!
* 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.
*
View fisqrt.js
// 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
View gist:358d4b1ab1a9ad3e2f9c2421db6d4794
78d841612ec3cfa069040348a45bbb0eca7006cdc01ed4be18d51ee8c0fd07bf
d2fe25f0ecc567158923131f12ab10b370463cebace765a0f9bfc4b3e655b183
3120a3bef7c2d904d6742c375214594420e90f953d54d391ccaefdce5ae60910
@chjj
chjj / bitcoin.md
Created Apr 16, 2016
The bitcoin paper in markdown (because PDFs suck)
View bitcoin.md

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

View satoshi-sigs.js
/**
* 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
View normalize-der.js
exports.normalize = function normalize(signature) {
var data, p, len, rlen, slen;
if (Buffer.isBuffer(signature))
signature = Array.prototype.slice.call(signature);
else if (typeof signature === 'string')
signature = utils.toArray(signature, 'hex');
data = signature.slice();
p = { place: 0 };
View github_error
┌─ chjj@slickrick ~/work/node_modules/bcoin [wallet-bip45$]
└ $ git push origin wallet-bip45
Counting objects: 7, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 1.38 KiB | 0 bytes/s, done.
Total 7 (delta 5), reused 0 (delta 0)
remote: /data/github/current/config/basic.rb:67:in `require': cannot load such file -- /data/github/current//data/github/current/vendor/ruby/b3255a8b572160bf249b5019c1ec93e667d547ee/lib/ruby/2.1.0/x86_64-linux/rbconfig.rb (LoadError)
remote: from /data/github/current/config/basic.rb:67:in `require'
remote: from /data/github/current/config/basic.rb:210:in `<top (required)>'
@chjj
chjj / view-pdf.sh
Created Mar 24, 2013
A terminal PDF viewer
View view-pdf.sh
#!/bin/sh
pandoc -t html -o - -f pdf "$1" | w3m -T text/html
You can’t perform that action at this time.