Skip to content

Instantly share code, notes, and snippets.

View LarryRuane's full-sized avatar

Larry Ruane LarryRuane

View GitHub Profile
@LarryRuane
LarryRuane / fives.rs
Created December 10, 2018 18:22
count the number of times "5" appears when counting from 1 to 1000
fn main() {
let mut c = 0;
for i in 1..=1000 {
let mut j = i;
while j > 0 {
if j % 10 == 5 {
c += 1;
}
j /= 10;
}
(gdb) p tx
$4 = {
<CMerkleTx> = {
<CTransaction> = {
hash = {
<base_blob<256>> = {
data = "\026(\276\235\371\062\367R\212\276\300\202\335D\205\225mWh\366q\221\233\257?\377\250\315\302\035\373\030"
}, <No data fields>},
static SPROUT_MIN_CURRENT_VERSION = 1,
static SPROUT_MAX_CURRENT_VERSION = 2,
@LarryRuane
LarryRuane / ack-tree-hash-demo.sh
Last active August 1, 2019 16:36
Better ACK - squash interaction using git tree hash
#!/bin/bash
#
# This script demonstrates how to use the git tree hash to allow squashing
# after ACKs without invalidating the ACK.
#
# ACKs in PRs often mention the commit hash being approved, but if the developer
# then squashes before the merge, this changes the commit hash (the post-squash
# commit hash doesn't match the latest pre-squash commit hash). This is because
# the commit hash depends on things that squashing changes.
#
@LarryRuane
LarryRuane / patch.diff
Created November 21, 2019 17:24
patch to https://github.com/fullstorydev/grpcurl to enable repeating the given RPCs for performance measurements
diff --git a/cmd/grpcurl/grpcurl.go b/cmd/grpcurl/grpcurl.go
index aaa3bbf..92489ef 100644
--- a/cmd/grpcurl/grpcurl.go
+++ b/cmd/grpcurl/grpcurl.go
@@ -115,6 +115,9 @@ var (
Enable verbose output.`))
serverName = flags.String("servername", "", prettify(`
Override server name when validating TLS certificate.`))
+ repeatCount = flags.Int("repeat", 1, prettify(`
+ Submit the rpc the given number of times (default 1), for performance
{
"cells": [
{
"cell_type": "code",
"execution_count": 60,
"metadata": {},
"outputs": [],
"source": [
"############## PLEASE RUN THIS CELL FIRST! ###################\n",
"\n",
@LarryRuane
LarryRuane / review-force-push-demo.sh
Created January 14, 2020 15:41
bash script to demonstrate how a reviewer can see what changed after a force-push
#!/usr/bin/env bash
#
# This script demonstrates how a reviewer can see only what's
# changed after a developer has overwritten a commit by doing a
# force-push to correct a bug or make a reviewer-requested change.
# The reviewer doesn't really want to have to re-review the entire
# change; it may be hard to pick out exactly what was force-pushed.
#
# The key idea is for the reviewer to make a temporary branch before
# re-fetching the developer's branch.
@LarryRuane
LarryRuane / reorg-testing.md
Created April 16, 2020 17:35
reorg testing using darksidewalletd

Reorg testing

Currently, in this branch, the lightwalletd knows a pre-determined range of 101 blocks, 663150 - 663250. These are real mainnet blocks that contain several transactions that include shielded payments to or from the "developer wallet".

From now on, we'll just abbreviate these heights by dropping the 663 prefix.

Initial state

@LarryRuane
LarryRuane / memo-cli.md
Last active June 11, 2020 23:44
How to send and receives encrypted Zcash transaction memos using zcash-cli

Memos for full-nodes

This document explains how to send and receive encrypted Zcash transaction memos using zcash-cli (the RPC interface). The not-so-user-friendly aspect of the RPC interface is that the memos are in hexadecimal string format. (The various wallets, such as Zecwallet and ZECC wallet, hid this detail from their users.) So to send as ascii text string as a memo requires first converting the string to hex, and to read the memo later as a text string requires converting from hex back to a string.

Tools

The following two tools will be handy.

#!/bin/bash
# reproduce https://github.com/zcash/zcash/issues/4301
test ! -f zcashd && { echo ./zcashd not found;exit 1;}
rm -rf dd
mkdir dd
(echo regtest=1 ; testnet=1 ; echo rpcuser=u ; echo rpcpassword=p) > dd/zcash.conf
./zcashd -datadir=dd -nuparams=5ba81b19:1 -nuparams=76b809bb:2 -nuparams=2bb40e60:3 -nuparams=f5b9230b:4 &
sleep 8
./zcash-cli -datadir=dd generate 4
./zcash-cli -datadir=dd z_getnewaddress sapling >testzaddr
@LarryRuane
LarryRuane / corrupt-block.diff
Created July 28, 2020 22:29
make the number of transactions field (just beyond header) 0xff instead of 0xfd (illegal)
--- before 2020-07-28 17:12:10.039607983 -0500
+++ after 2020-07-28 17:21:12.859607983 -0500
@@ -1,7 +1,7 @@
00000000: 0b11 0907 e7e1 0100 0200 0000 01e9 7a2c ..............z,
00000010: fabb 443a 6a13 51a1 22f7 59cf 4d72 00c9 ..D:j.Q.".Y.Mr..
00000020: c8c2 18b3 ad30 9661 0000 0000 c6c3 d1f5 .....0.a........
00000030: 6e72 3ad0 b05b e01f 88e0 c688 8158 0e9a nr:..[.......X..
00000040: b6ed 2517 c457 11e1 35fb 9382 e1b8 ac53 ..%..W..5......S
-00000050: ffff 001d 0002 622a fd4c 0101 0000 0001 ......b*.L......
+00000050: ffff 001d 0002 622a ff00 0000 0000 0000 ......b*.L......