Skip to content

Instantly share code, notes, and snippets.

View marek22k's full-sized avatar

Marek Küthe marek22k

View GitHub Profile
@marek22k
marek22k / split_mnemonic_phrase.rb
Created October 5, 2021 17:57
Splits a mnemonic phrase into several cards. When a card is found, not all of the words are known.
# Splits a mnemonic phrase into several cards. When a card is found, not all of
# the words are known. This increases security. The program is written in Ruby.
# It asks for the phrase and the number of cards during runtime. The phrase is
# never sent (to any servers). It is not a malicious program. Since the source
# code is open source and free, this can be verified.
# Copyright (c) 2021 Marek Küthe
# This work is free. You can redistribute it and/or modify it under the
# terms of the Do What The Fuck You Want To Public License, Version 2,
@marek22k
marek22k / PayingBillsTogether.sol
Last active November 4, 2021 12:36
Community projects often involve collecting donations. This contract makes it easy to keep an overview and to carry out a collection campaign.
// SPDX-License-Identifier: WTFPL
/*
Copyright (c) 2021 Marek Küthe
This work is free. You can redistribute it and/or modify it under the
terms of the Do What The Fuck You Want To Public License, Version 2,
as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
*/
pragma solidity ^0.8.7;
@marek22k
marek22k / StringBytes32Converter.rb
Created November 5, 2021 16:40
Ruby program that can convert a string into Bytes32 or vice versa. (Can be used with Solidity or Smart Contracts)
require "erb"
def print_help
ERB.new(DATA.read).run
end
if ARGV.length != 2
print_help
exit
end
@marek22k
marek22k / AddressScoring.sol
Created November 6, 2021 15:41
Can be used to rate addresses in a network. Each address has a voting right. A score from 0 to 255 is calculated.
// SPDX-License-Identifier: WTFPL
pragma solidity ^0.8.7;
contract AddressScoring {
struct Entry {
uint value;
bool exist;
}
@marek22k
marek22k / Faucet.sol
Last active November 9, 2021 16:49
The faucet is designed to just give you some "change" to get started.
// SPDX-License-Identifier: WTFPL
pragma solidity ^0.8.9;
/*
The faucet is designed to just give you some "change" to get started. However,
since you don't have any money yourself at the start and therefore cannot do the
faucet, there is a "friends" function. A friend can make a request to the faucet
and you only get enough that you can make a request to the faucet yourself. From
this you get your starting credit. You can request a maximum of once for a friend,
@marek22k
marek22k / scan_eval.rb
Created November 15, 2021 20:41
Calculates the paid transaction fees based on a CSV export from etherscan / bscan / polygonscan
require "csv"
if ! File.readable ARGV[0]
puts "I cannot read the file"
end
file = CSV.open(ARGV[0], "r")
data = file.read
crypto_column = 10
@marek22k
marek22k / ethaddr.rb
Created December 12, 2021 18:59
Same functionality as helpeth addressDetails
require "icap"
require "eth"
addr = ARGV[0]
if ! (addr == addr.downcase) && (! Eth::Utils.valid_address? addr)
puts "The supplied address failed the checksum test. It might be invalid."
end
puts "Address: #{addr.downcase}"
did:3:kjzl6cwe1jw145qhgqg0i7npr4mfseimjhy1p8avysib8ca3bc9kj6mfnwwi80j
@marek22k
marek22k / meshname_server.rb
Last active January 5, 2022 00:41
Meshname DNS Server
require "meshname"
require "resolv"
require "async/dns"
def parse_address str
case str
when /\A\[(?<address> .* )\]:(?<port> \d+ )\z/x
address, port = $~[:address], $~[:port]
when /\A(?<address> [^:]+ ):(?<port> \d+ )\z/x
@marek22k
marek22k / bf_compiler.rb
Created January 12, 2022 22:57
Ruby script that compiles Brainfuck code into C code.
def print_help
puts <<HELP
ruby ./bf_compile.rb [OPTIONS] [NUM_CELLS] file_to_compile.bf
Options:
-comments Don't translate Brainfuck comments into C
-stdlib Do not use stdlib.h to determine the successful exit status (EXIT_SUCCESSFUL)
-static Deactivates the analysis in order to generate a static output for input-independent code.
-analyzer Deactivates the analyzer
+tabs Used tabs instead of spaces for the indentations