Skip to content

Instantly share code, notes, and snippets.

@chjj
chjj / .vimrc
Created February 12, 2019 07:11
mini vimrc
"
" ~/.vimrc
"
set nocompatible
set hidden
set ruler
set visualbell
set noerrorbells
set nostartofline
@chjj
chjj / bmocha.js
Last active November 28, 2018 21:49
#!/usr/bin/env node
/* eslint no-control-regex: "off" */
'use strict';
const assert = require('assert');
const Path = require('path');
const {
'use strict';
const path = require('path');
const fs = require('./lib/utils/fs');
async function findFiles(dir, match, ignore, files) {
const list = await fs.readdir(dir);
for (const name of list) {
if (ignore.has(name))
@chjj
chjj / sweep-bcc.js
Created August 8, 2017 01:07
Sweep BCC from trezor multisig
'use strict';
// Sweep bcc from trezor multisig.
const assert = require('assert');
const util = require('util');
const trezor = require('trezor.js-node');
const HDPublicKey = require('bcoin/lib/hd/public');
const HARDENED = 0x80000000;
@chjj
chjj / 1000-cost.json
Last active November 18, 2018 04:10
[
{
"hash": "0000000000000000018c59d807bff651ead9f8fd6eef075ee5cffcf98bf4674c",
"height": 464208,
"size": 998109,
"txs": 684,
"inputs": 6162,
"outputs": 1362,
"inputCost": 5578086,
"outputCost": 271012,
$ 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 / 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