Skip to content

Instantly share code, notes, and snippets.

@kristovatlas
kristovatlas / randsim.py
Last active December 27, 2017 22:40
simulating the broadcasting of Bitcoin transactions and first-hop reception by sybil attacker
import itertools
from random import randint
#p = 0.95
OTHER_NODES = 10000
MY_NODES = 4410
MY_CONNECTIONS = 8 * MY_NODES #my nodes are malicious and make 8 connections per peer
ALL_NODES = OTHER_NODES + MY_CONNECTIONS
NUM_BROADCASTED = 2
@kristovatlas
kristovatlas / README.md
Created April 16, 2018 01:22
How to verify Trezor Bridge on MacOS (and maybe other operating systems)

Background reading

Verification Steps

  1. Visit https://wallet.trezor.io/data/bridge/latest/index.html. For MacOS, you download a .pkg file.
  2. From https://wallet.trezor.io/data/bridge/latest/index.html also download the PGP signature file.
  3. The Satoshi Labs CTO signs the Bridge releases. Download his PGP key from his Keybase signature: https://keybase.io/stick This means at least that someone created an account with his identity and bothered to link a specific PGP key. If you retain this key over time, you can be sure that it wasn't recently swapped out. You can find same PGP under his identity in various places on the web: https://duckduckgo.com/?q=Pavol+Rusn%C3%A1k+pgp+key&ia=web
NUM_FIB_NUMS = 100
F1 = 0
F2 = 1
POS = 2
print "0,0"
print "1,1"
for count in range(1, NUM_FIB_NUMS + 1):
@kristovatlas
kristovatlas / emailer.py
Created September 16, 2020 17:08
Send GMail
#python3
# Usage: emailer.send(recipient_email, mail_subject, message)
#https://stackabuse.com/how-to-send-emails-with-gmail-using-python/
import smtplib
gmail_user = 'username@gmail.com'
gmail_password = 'password_goes_here'
sent_from = gmail_user
def send(recipients, subject, body):
@kristovatlas
kristovatlas / evidence.py
Created October 23, 2020 20:10
evidence.py
"""
https://twitter.com/elliot_olds/status/1319364546880942080
To keep calculations simple, let's fix population size to 100
"""
POPULATION = 100
FRED_PROB_FIRST = 1/(0.6 * POPULATION)
NOT_FRED_PROB_FIRST = 1-FRED_PROB_FIRST
def prob_no_blood_type(population, num_crime_scene):
@kristovatlas
kristovatlas / prettify_json.py
Last active December 30, 2025 04:00
Prettify JSON-y looking things locally
import ast
import json
import sys
def parse_nested_json(obj):
"""Recursively parse any string values that are valid JSON into objects."""
if isinstance(obj, dict):
return {k: parse_nested_json(v) for k, v in obj.items()}
elif isinstance(obj, list):
return [parse_nested_json(i) for i in obj]
@kristovatlas
kristovatlas / fix_railway_log.py
Created January 6, 2026 20:40
Fix Railway breaking up logs across lines
import sys
def main():
if len(sys.argv) != 2:
print("Usage: python fix_railway_logs.py <log_file>")
sys.exit(1)
filename = sys.argv[1]
prefix_length = 38
content_parts = []
@kristovatlas
kristovatlas / ascii_to_markdown_tbl.py
Last active February 25, 2026 18:29
stuff to make claude code terminal output suitable for other formats
import sys
def is_separator(line):
"""Check if a line is a horizontal separator (e.g. ├───┼───┤, ╞═══╪═══╡, etc.)"""
stripped = line.strip()
# Separator lines are made up of box-drawing border characters and have no letter/digit content
border_chars = set('─━═┼╪╫┬┴├┤┌┐└┘╔╗╚╝╠╣╦╩╬╞╡╥╨╤╧╟╢+|-=')
return bool(stripped) and all(c in border_chars or c.isspace() for c in stripped)
@kristovatlas
kristovatlas / install-claude-verified-linux.sh
Last active September 8, 2026 16:23
Install Claude Code based on known-good hash instead of curl-bashing; Install Codex with Socket.dev Firewall
#!/usr/bin/env bash
# install-claude-verified.sh — download and install Claude Code with full
# signature verification, no unauthenticated bootstrap script.
#
# Usage: ./install-claude-verified.sh [VERSION]
# VERSION defaults to whatever $REPO/latest reports.
# Requires: curl, gpg, jq, sha256sum
# Trust anchor: the pinned fingerprint below (from code.claude.com/docs/en/setup).
#
# Template tip: vendor the key file into your image at $VENDORED_KEY and this
@kristovatlas
kristovatlas / STYLE-GUIDE.md
Last active August 10, 2026 18:59
LLM blog style guide

Blog writing style guide

Notes for engineering blog writing. The goal: read like a human engineer wrote it, not like it came out of a chatbot. Two big reasons. It's more credible with a technical audience, and obvious AI-generated prose reads as low-effort regardless of how good the underlying work is.

0. The goal is a human voice, not a word filter

Read this first. Everything below is a heuristic toward prose a person would write, not a checklist to satisfy mechanically.

  • Over-correction is its own tell. Prose that dodges every banned word but comes out clipped, choppy, and stripped of personality lands in a different uncanny valley. Keep the occasional analogy, aside, and bit of structure that a real writer would use.
  • Don't swap one crutch for another. If every em-dash becomes a parenthesis, parentheses are the new tell. If banned words get replaced by near-synonyms, nothing changed.