Skip to content

Instantly share code, notes, and snippets.

@jgarzik
jgarzik / zcat.cc
Created February 28, 2018 06:21
Decompress gzip files to stdout
#include <stdio.h>
#include <stdexcept>
#include <unistd.h>
#include <fcntl.h>
#include <string>
#include <vector>
#include <string.h>
#include <assert.h>
#include <zlib.h>
@jgarzik
jgarzik / zcat.cc
Created February 28, 2018 05:57
Decompress gzip file to stdout
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string>
#include <vector>
#include <assert.h>
#include <zlib.h>
using namespace std;
@jgarzik
jgarzik / BidiPipe.h
Created February 15, 2018 02:07
Bi-directional pipe as thread queue
#ifndef __SRV_BIDIPIPE_H__
#define __SRV_BIDIPIPE_H__
#include "Util.h"
#ifndef ARRAYLEN
#define ARRAYLEN(array) (sizeof(array)/sizeof((array)[0]))
#endif // ARRAYLEN
class BidiPipe {
@jgarzik
jgarzik / eth-tx-prefix.cc
Created February 11, 2018 04:21
Reverse iterated index for latest per-account activity
/*
Build:
g++ -std=c++11 -O -Wall -g -o eth-tx-prefix eth-tx-prefix.cc -lrocksdb
Run:
./eth-tx-prefix
Clean:
@jgarzik
jgarzik / patch
Created June 16, 2017 20:10
Version patch
diff --git a/configure.ac b/configure.ac
index a9156c3..50509d6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
AC_PREREQ([2.60])
-define(_CLIENT_VERSION_MAJOR, 0)
+define(_CLIENT_VERSION_MAJOR, 1)
define(_CLIENT_VERSION_MINOR, 14)

Keybase proof

I hereby claim:

  • I am jgarzik on github.
  • I am jgarzik (https://keybase.io/jgarzik) on keybase.
  • I have a public key whose fingerprint is AF8B E07C 7049 F3A2 6B23 9D53 25B3 0832 0178 2B2F

To claim this, I am signing this object:

Verifying that +jgarzik is my openname (Bitcoin username). https://onename.io/jgarzik
@jgarzik
jgarzik / mmx-test.c
Created August 14, 2014 13:19
storing data in registers
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <time.h>
#include <stdint.h>
#include <stdbool.h>
#include <unistd.h>
@jgarzik
jgarzik / paychanproto.md
Last active August 29, 2015 13:57
Payment channel JSON-RPC protocol

This protocol describes a simple payment channel protocol, such as the one presented in https://en.bitcoin.it/wiki/Contracts#Example_7:_Rapidly-adjusted_.28micro.29payments_to_a_pre-determined_party

JSON-RPC methods shown here may be sent via HTTPS or stratum protocol. It is easily adaptable to protocol buffers or another favored marshalling method.

Open channel

Client requests a public key. Server responds with a public key (K2). K2, converted to a bitcoin address, forms the unique identifier for this payment channel. Each public key returned must be unique.