Skip to content

Instantly share code, notes, and snippets.

View hitchhooker's full-sized avatar
🌴

Tom Mi hitchhooker

🌴
View GitHub Profile
@hitchhooker
hitchhooker / software-distribution.md
Created April 3, 2024 00:33
a few steps to verifiable open source distribution

To achieve a trustworthy distribution of software, both the binary publisher (e.g., a software developer or company) and the end users play critical roles. Here's a step-by-step breakdown of how this process works, focusing first on the publisher's responsibilities and then on what end users must do to verify the software in a safe manner.

Steps for the Binary Publisher

  1. Compile the Source Code: Compile the source code into a binary or build. This should be done in a clean, controlled environment to ensure that the build is reproducible and hasn't been tampered with.

  2. Generate a SHA-512 Hash: Use a tool to calculate the SHA-512 hash of the compiled binary. This hash serves as a unique fingerprint of the binary.

  3. Sign the Hash: Digitally sign the SHA-512 hash using a private key. The digital signature ensures that the hash hasn't been altered and verifies the identity of the signer.

RFC: Enhanced Collective Contributions

Introduction

This RFC proposes an enhancement to the Referenda Pallet of the Polkadot network to introduce a feature for collective contributions towards decision deposits of referenda. This proposal aims to increase participatory governance by enabling stakeholders to collaboratively fund referenda deposits. A key aspect of this proposal is the inclusion of a configurable feature flag within the pallet, allowing for network-specific activation of this functionality.

@hitchhooker
hitchhooker / kava_top10_peers.sh
Last active February 9, 2024 18:10
Get full peers.txt list from https://polkachu.com/live_peers/kava and save it as peers.txt and execute this script in same folder to get optimal persistent_peers for your node to sync faster. requirements: apt install parallel
#!/bin/bash
# Define a function to ping and print latency with the full address
ping_and_save() {
peer="$1"
ip=$(echo "$peer" | cut -d'@' -f2 | cut -d':' -f1)
# Perform the ping and extract the average latency
avg_latency=$(ping -c 4 $ip | tail -1 | awk -F'/' '{print $5}')
if [ ! -z "$avg_latency" ]; then
#!/bin/bash
validators=$(curl https://beefy.rotko.net/api | jq -c '.candidates1kv[]')
for validator in $validators; do
name=$(echo $validator | jq -r '.name')
address=$(echo $validator | jq -r '.address')
matrix_address=$(echo $validator | jq -r '.matrix')
message="Hey $matrix_address! Your validator node - $name with the address $address is still using [dummy keys](https://kusama-staging.w3f.community/validators/beefy/dummy) for beefy set by fellowship. Could you rotate your validator keys and set new keys for the validator so we can get runtime upgraded. Thanks heaps for your support securing the network!"
matrix-commander --credentials ~/.config/matrix-commander/hitchhooker.json --room "$matrix_address" --message "$message"
@hitchhooker
hitchhooker / paseo.sh
Created January 3, 2024 04:47
paseo.sh
#!/bin/bash
# Variables
polkadot_bin_dir="/opt/polkadot"
paseo_spec_file="$polkadot_bin_dir/paseo.raw.json"
paseo_spec_url="https://raw.githubusercontent.com/paseo-network/runtimes/main/chain-specs/paseo.raw.json"
service_file="/etc/systemd/system/polkadot.service"
name="Rotko Networks - pso01"
role="validator"
@hitchhooker
hitchhooker / benchtool-amd-r9-7940hs-linux66amd
Created November 26, 2023 16:22
benchtool results with porofile
user@pc01 𓅨 ~ ➤ bed4e50|master⚡
4726 ± cargo run --profile benchmark criterion ⏎ [2d0h17m] ✹ ✭
Finished benchmark [optimized + debuginfo] target(s) in 0.14s
Running `/home/user/src/polkavm/target/benchmark/benchtool criterion`
Benchmarking runtime/pinky/polkavm_no_gas
Benchmarking runtime/pinky/polkavm_no_gas: Warming up for 3.0000 s
Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 8.0s or enable flat sampling.
Benchmarking runtime/pinky/polkavm_no_gas: Collecting 10 samples in estimated 7.9787 s (55 iterations)
Benchmarking runtime/pinky/polkavm_no_gas: Analyzing
@hitchhooker
hitchhooker / polkaplot.py
Created November 26, 2023 16:19
draw polkavm benchtool results from json data in nanoseconds
# Code to match the provided JSON data
import matplotlib.pyplot as plt
import numpy as np
# data in JSON data
data = {
"runtime": {
"pinky": {
"polkavm_no_gas": 3423400,
<?php
try {
// Database connection setup
$photosDb = new PDO(/* your DSN, username, password, and other options */);
// Set PDO to throw exceptions on error
$photosDb->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Set default fetch mode to associative array
$photosDb->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
// This value should be hardcoded or safely assigned,
@hitchhooker
hitchhooker / alarm.cron
Created August 9, 2023 23:53
crontab alarm clock
# alarm 7.20
20 7 * * * /bin/bash -c 'echo -e "main(i){for(i=0;;i++)putchar(((i*(i>>8|i>>9)&46&i>>8))^(i&i>>13|i>>6));}" | gcc -x c - && ./a.out | aplay'
@hitchhooker
hitchhooker / ai.com redirector
Created August 4, 2023 18:28
to provide solution against elon musk tyranny of buying my muscle memory. install caddy to your operatiing system and write these config to redirect ai.com without issues to chat.openai.com in your system
#!/bin/bash
# Create a backup of the existing /etc/hosts file
cp /etc/hosts /etc/hosts.backup
# Add the ai.com entry to the /etc/hosts file
echo "127.0.0.1 ai.com" >> /etc/hosts
# Create a Caddyfile with the desired configuration
cat > /etc/caddy/Caddyfile << EOL