Skip to content

Instantly share code, notes, and snippets.

View etscrivner's full-sized avatar
🦋

Eric Scrivner etscrivner

🦋
View GitHub Profile
@etscrivner
etscrivner / rpc_doctest.cpp
Last active October 5, 2018 04:12
Bitcoin RPC API documentation helper object prototype.
#include <iostream>
#include <string>
#include <vector>
class RPCArgument {
public:
RPCArgument(const std::string& name,
const std::string& type,
const std::string& description,
bool required=false,
#!/usr/bin/env ksh
#
# Benchmark Project Euler 1 programs by running them through same datsets
# several times and computing the average.
#
Values=(1000 10000 100000 1000000 10000000)
echo "${Values[@]}"
Programs=("./c_euler_1" "./haskell_euler_1")
@etscrivner
etscrivner / main.c
Created April 5, 2018 19:39
Exercise 1A. Write a program to estimate the mean and standard deviation of a sample of n real numbers. Use a linked list to hold the n numbers for the calculation.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "result.h"
#include "number_list.h"
#include "population_statistics.h"
eResult read_numbers(NumberList *number_list)
@etscrivner
etscrivner / super_method_propagation.rb
Created June 19, 2017 19:48
Ruby propagates arguments up to super method calls for you
class Parent
def try_me(confirmed_only: true)
confirmed_only
end
end
class Child < Parent
def try_me(confirmed_only: true)
# Ruby will proxy the value of `confirmed_only` up to the super method invocation for you.
super
@etscrivner
etscrivner / base58checkencode.go
Created June 9, 2017 00:59
Base58Check Encoding In Go
package main
import (
"bytes"
"crypto/sha256"
"golang.org/x/crypto/ripemd160"
"fmt"
"math/big"
)
const Base58Alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
@etscrivner
etscrivner / signal_v_noise.rb
Created January 24, 2017 18:59
Why choosing good metrics is important.
require 'csv'
def percent_support_tickets(time)
1.0 - ((time + 5) / 200.0)
end
seed = Random.new_seed
prng = Random.new(seed)
puts "Seed: #{seed}"
@etscrivner
etscrivner / EIP150ReplaySafeSplit.sol
Last active January 29, 2017 08:23
Safe splitting contract that accounts for EIP-150 and ETH/ETC hard forks.
pragma solidity ^0.4.2;
contract EIP150ReplaySafeSplit {
// Fork oracle for EIP-150 fork
AmIOnEIP150Fork amIOnEIP150Fork = AmIOnEIP150Fork(/* To be deployed */);
// Fork oracle for ETH/ETC fork
AmIOnTheFork amIOnDAOFork = AmIOnTheFork(0x2bd2326c993dfaef84f696526064ff22eba5b362);
// This routine provides a way to route funds across Ethereum chain forks. It preserves
// the signature of split method from DAO hard-fork replay split contract. If the current
@etscrivner
etscrivner / AmIOnEIP150Fork.sol
Last active October 18, 2016 14:07
EIP-150 fork oracle.
pragma solidity ^0.4.2;
contract AmIOnEIP150Fork {
// Tracks whether or not hard fork is effective on this chain.
bool public forked = false;
// Event emitted on updates during fork window to indicate status.
event ForkedStatus(bool forked);
// This function should be called between block X and Y.
function update() {
@etscrivner
etscrivner / EIP150ForkConstant.sol
Last active October 17, 2016 17:04
Solidity contract used to determine the constant that should be used in EIP-150 fork oracle.
pragma solidity ^0.4.2;
contract EIP150ForkConstant {
// Used to determine gas constant
event GasConstant(uint first, uint second, uint third);
event OnFork(bool forked);
// This function should be called between block X and Y.
function run() {
uint beforeGas = 0;

Keybase proof

I hereby claim:

  • I am etscrivner on github.
  • I am escrivner (https://keybase.io/escrivner) on keybase.
  • I have a public key whose fingerprint is 74A8 F331 A8B7 C5D8 0879 52B4 5A2E 7AA7 837C C233

To claim this, I am signing this object: