Skip to content

Instantly share code, notes, and snippets.

@thr0wn
thr0wn / mandelbrot.py
Last active April 3, 2023 12:47
Mandelbrot set generated using python turtle
import turtle
import math
def mandelbrot(z , c , n=20):
if abs(z) > 10 ** 12:
return float("nan")
elif n > 0:
return mandelbrot(z ** 2 + c, c, n - 1)
else:
return z ** 2 + c
@thr0wn
thr0wn / forca.py
Created August 20, 2016 00:42
Jogo da forca
import random
words = ['jamelao', 'rato-borrachudo', 'e_nois_que_voa_bruxao', 'olha_o_bicho_vindo_moleque']
selectedWord = random.choice(words)
successes, errors = [], 0
print("Jogo da forca")
while len(successes) < len(selectedWord) and errors < 2 * len(selectedWord):
c = input("palpite: ")
try:
@thr0wn
thr0wn / eventemitter.js
Created May 2, 2017 01:40 — forked from mudge/eventemitter.js
A very simple EventEmitter in pure JavaScript (suitable for both node.js and browsers).
/* Polyfill indexOf. */
var indexOf;
if (typeof Array.prototype.indexOf === 'function') {
indexOf = function (haystack, needle) {
return haystack.indexOf(needle);
};
} else {
indexOf = function (haystack, needle) {
var i = 0, length = haystack.length, idx = -1, found = false;
function makeMembrane(){
var revokableWrappingHandler = Proxy.revocable({}, {
get: function(target, name){
return (...args) => wrap(Reflect[name](...args));
}
});
var revoke = revokableWrappingHandler.revoke;
var wrappingHandler = revokableWrappingHandler.proxy;
var un2wrapped = new WeakMap();
@thr0wn
thr0wn / Dicelicia.js
Created December 5, 2019 22:02
WIP - Dice robot
const sendBch = require("./send-bch");
let BITBOX = require("bitbox-sdk").BITBOX;
let bitbox = new BITBOX();
const Mnemonic =
"...";
const Addrx2 = "bitcoincash:qz9cq5rlkdrjy2zkfzqscq847q9n07mu5y7hj8fcge";
const Addrx10 = "bitcoincash:qz9cq5pgwgx68wfevx0t78xalkh33xa0v5wlx6nppx";
@thr0wn
thr0wn / swap.cash
Last active October 30, 2020 06:51
pragma cashscript ^0.4.0;
contract Swap() {
function claimToken(sig selfSig, pubkey selfPk, pubkey otherPk, datasig selfDatasig, datasig otherDatasig, bytes message) {
// Check that the message was signed by both parts
require(checkDataSig(selfDatasig, message, otherPk));
require(checkDataSig(otherDatasig, message, selfPk));
// check itself sig
require(checkSig(selfSig, selfPk));
@thr0wn
thr0wn / hathor-explorer-ideias.md
Last active November 26, 2020 21:26
Hathor explorer ideias
Hathor Logo

Hathor - Ideias para o explorer

1. Top tokens

Feature muito interessante que existe em alguns explorers (e.g: Etherscan, BCH Explorer). Basicamente a ideia é exibir os tokens mais presentes nas últimas transações da Hathor Network para uma determinada janela de tempo (inicialmente poderia ser fixo nas últimas 24h).

@thr0wn
thr0wn / design-wallet-lib.md
Last active November 26, 2020 16:35
Ideas para o design da wallet-lib
Hathor Logo

Hathor - Ideias para o design da wallet-lib

Os pontos abaixo são funcionalidades de alto nível para usuários que precisem apenas receber ou enviar tokens. Embora bem simples, eles podem auxiliar a jornada de desenvolvedores que conhecem pouco de blockchain.

@thr0wn
thr0wn / tx-mining-service.patch
Last active December 2, 2020 16:29
tx-mining-service patch
diff --git a/Pipfile b/Pipfile
index 7abf186..2e73894 100644
--- a/Pipfile
+++ b/Pipfile
@@ -20,6 +20,7 @@ aiohttp = "*"
base58 = "*"
structlog = "*"
prometheus-client = "*"
+aiohttp_cors="*"
@thr0wn
thr0wn / yiimp<>bitcoind.md
Last active January 20, 2021 14:33
JSON RPC messages between yiimp and bitcoind daemon

Request: {"method":"getmininginfo","params":[],"id":1}

Response: {"result":{"blocks":1,"currentblockweight":4000,"currentblocktx":0,"difficulty":4.656542373906925e-10,"networkhashps":6.363322379955621e-09,"pooledtx":0,"chain":"regtest","warnings":""},"error":null,"id":1}


Request: {"method":"getwalletinfo","params":[],"id":2}

Response: {"result":{"walletname":"","walletversion":169900,"balance":0.00000000,"unconfirmed_balance":0.00000000,"immature_balance":0.00000000,"txcount":0,"keypoololdest":1610400333,"keypoolsize":1000,"hdseedid":"2b351f2ac3ac3bb7c2ded74edf616365b84bb8b1","keypoolsize_hd_internal":999,"paytxfee":0.00000000,"private_keys_enabled":true,"avoid_reuse":false,"scanning":false},"error":null,"id":2}