Skip to content

Instantly share code, notes, and snippets.

View portlandhodl's full-sized avatar
🍊
💊

Portland.HODL portlandhodl

🍊
💊
View GitHub Profile
@portlandhodl
portlandhodl / smt.md
Last active March 8, 2025 12:22
Sparse Merkle Trees

Notes about Sparse Merkle Trees

  • The primary issue with a SMT is the calculation between each leaf and their intersection with other leaves.
  • A tree with a single sparse element is very easy as you just can add that element in an calculate the path up the tree.
  • When you have multiple keys then you need to make sure when you calculate the path up the tree you need to consider the impact other leaves have on your path to get to the root.
@portlandhodl
portlandhodl / sha256_test.cpp
Last active February 8, 2025 21:11
Double Sha256 Benchamrk w/ Hardware Support
#include <iostream>
#include <chrono>
#include <openssl/sha.h>
#include <cpuid.h>
bool check_sha_support() {
unsigned int eax, ebx, ecx, edx;
if (__get_cpuid(7, &eax, &ebx, &ecx, &edx)) {
return (ebx & (1 << 29)) != 0; // Check bit 29 for SHA extensions
}
@portlandhodl
portlandhodl / main.rs
Created December 17, 2024 23:48
Get Block Template Rust Example 1
use actix_web::{get, web, App, HttpResponse, HttpServer, Responder};
use bitcoincore_rpc::{Auth, Client, RpcApi};
use serde_json::Value;
struct AppState {
btc_client: Client,
}
#[get("/blocktemplate")]
async fn get_block_template(data: web::Data<AppState>) -> impl Responder {
@portlandhodl
portlandhodl / aws2_init.sh
Created October 4, 2024 07:19
Amazon AWS Linux2 Quick Docker Init and Update Scrupt
#!/bin/bash
# Update the system
sudo yum update -y
# Install Docker
sudo amazon-linux-extras install docker -y
sudo systemctl start docker
sudo systemctl enable docker
sudo usermod -aG docker ec2-user
@portlandhodl
portlandhodl / mtp-run-plot.py
Created August 27, 2024 22:58
Plotting MTP vs Timestamp Over 10000 Blocks
import requests
import csv
from datetime import datetime
import time
import matplotlib.pyplot as plt
import pandas as pd
# Bitcoin node RPC connection details
rpc_user = 'your_rpc_username'
rpc_password = 'your_rpc_password'
@portlandhodl
portlandhodl / mtp_run_plot.py
Created August 27, 2024 22:56
Plotting MTP vs Timestamp Over 10000 Blocks.
import requests
import csv
from datetime import datetime
import time
import matplotlib.pyplot as plt
import pandas as pd
# Bitcoin node RPC connection details
rpc_user = 'your_rpc_username'
rpc_password = 'your_rpc_password'
@portlandhodl
portlandhodl / bitaxe_diff.go
Created August 4, 2024 01:55
Waybar Bitaxe Difficulty Widget
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
)
type SystemInfo struct {
@portlandhodl
portlandhodl / errors.log
Created July 5, 2024 23:00
Clang++ Cuda Errors
clang++ -x cuda --cuda-gpu-arch=sm_61 -I/opt/cuda/lib64 axpy.cu -o axpy -L/opt/cuda/lib32 -lcudart_static -ldl -lrt -pthread
clang++: warning: CUDA version is newer than the latest supported version 12.3 [-Wunknown-cuda-version]
In file included from <built-in>:1:
In file included from /usr/local/lib/clang/18/include/__clang_cuda_runtime_wrapper.h:41:
In file included from /usr/local/lib/clang/18/include/cuda_wrappers/cmath:27:
In file included from /usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/cmath:49:
/usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/bits/std_abs.h:137:7: error: __float128 is not supported on this target
137 | abs(__float128 __x)
| ^
@portlandhodl
portlandhodl / axpy.cu
Created July 5, 2024 22:56
Cuda Clang++ Hello World
#include <iostream>
__global__ void axpy(float a, float* x, float* y) {
y[threadIdx.x] = a * x[threadIdx.x];
}
int main(int argc, char* argv[]) {
const int kDataLen = 4;
float a = 2.0f;
@portlandhodl
portlandhodl / rpi_keyboard_latency_tester.py
Last active January 17, 2024 13:08
A Raspberry Pi Keyboard Latency Tester GPIO18
###
# Portland.HODL USB HID Latency Tester
# Engineered for RaspberryPi(4/5)
import csv
import hid
import time
import RPi.GPIO as GPIO
def list_hid_devices():