Skip to content

Instantly share code, notes, and snippets.

Avatar

Richard Kiss richardkiss

View GitHub Profile
@richardkiss
richardkiss / comp-test.py
Last active Dec 23, 2021
offer-zlib-compression
View comp-test.py
import zlib
from chia.wallet.puzzles.load_clvm import load_clvm
from chia.wallet.puzzles import p2_delegated_puzzle_or_hidden_puzzle as standard_puzzle
from chia.wallet.puzzles.cc_loader import CC_MOD
OFFER_MOD = load_clvm("settlement_payments.clvm")
puzzle_dict = bytes(OFFER_MOD) + bytes(standard_puzzle.MOD) + bytes(CC_MOD)
@richardkiss
richardkiss / settlement_payments.md
Last active Oct 15, 2021
Ideas about Offers on Chia
View settlement_payments.md

We introduce a new puzzle, "settlement_payments", which pays out coins and make an announcement for each new coin created.

settlement_payments.cl:

(mod (coins_paid)
  ;; `coins_paid` is a list of notarized coin payments
  ;; a notarized coin payment is `(nonce puzzle_hash amount ...)`
 ;; Each notarized coin payment creates a `(CREATE_COIN puzzle_hash amount)` payment
@richardkiss
richardkiss / venv
Created Mar 18, 2021
A nice shell script to put all your venvs in the same place
View venv
#!/bin/sh
VENV_PATH=${@:-${VENV_BASE_PATH:-~/tmp/virtualenvs}}/`pwd | sed "s|/|_|g"`/venv
if [ -e $VENV_PATH ]
then
echo rm -rf $VENV_PATH
echo and try again
else
mkdir -p $VENV_PATH
View coloured-coins-notes.md

Idempotent clarifications

Here are a bunch of changes you can make for humans only. None of these changes should change how it compiles, so you should be able to change anything in this section and compare the resultant compile. It should be identical.

reformat

I've really love an automated pretty-printer akin to "black" for python or "cargo fmt" for rust so you can write whatever mess you want and have a computer indent it so it looks nice, but I haven't been able to find one yet.

View pycoin_custom_sign.py
from pycoin.encoding.hexbytes import b2h
from pycoin.intbytes import int2byte
from pycoin.key import Key
from pycoin.networks.registry import network_for_netcode
from pycoin.satoshi.der import sigencode_der
network = network_for_netcode('XTN')
Tx = network.tx
TxIn = network.tx.TxIn
@richardkiss
richardkiss / sl
Created Mar 30, 2018
A "mirror-image" ls in python, as discussed at https://news.ycombinator.com/item?id=16716150
View sl
#!/usr/bin/env python
import subprocess
import sys
output = subprocess.check_output(["ls"] + sys.argv[1:])
lines = output.split("\n")
View faq.md

Chia FAQ

Q: Where does the name "Chia" come from?

A: See Wikipedia.

View keybase.md

Keybase proof

I hereby claim:

  • I am richardkiss on github.
  • I am richardkiss (https://keybase.io/richardkiss) on keybase.
  • I have a public key whose fingerprint is 1BE0 3D39 4138 A2C2 E2EF 64D4 E0F4 3326 DBD8 AB6A

To claim this, I am signing this object:

View put_get_bug.py
#!/usr/bin/env python
"""
When PYTHONASYNCIODEBUG is set to 1, this causes a strange error:
TypeError: send() takes 2 positional arguments but 7 were given
Invoke as follows:
$ PYTHONASYNCIODEBUG=1 python3 put_get_bug.py
View Python 3.4 asyncio gc bug
#!/usr/bin/env python
"""
This is an example of what seems to be a garbage collection bug in Python 3.4.0
that does not exist in Python 3.3.3.
The example uses asyncio to create a producer that multiplexes to N consumers.
On my Mac, with N=100, 38 consumers are incorrectly garbage collected and only execute
once, dropping the surviving consumer count to 62.