Skip to content

Instantly share code, notes, and snippets.

View marek22k's full-sized avatar

Marek Küthe marek22k

View GitHub Profile

openpgp4fpr:9aa28159fceb3cd83bc212017e869146699108c7

@marek22k
marek22k / ixp_frnte_dn42_prefix.rb
Created May 30, 2022 17:59
Calculates the prefix assigned to the ASN based on the ASN.
# see https://explorer.dn42.dev/#/inet6num/fde0:93fa:7a0:2::_64
if ! ARGV[0]
puts "arg 0 is the asn"
end
asn = ARGV[0]
asn_bin = asn.to_i.to_s(2)
asn_low16 = asn_bin[0...16].to_i(2).to_s(16)
asn_high16 = asn_bin[16..-1].to_i(2).to_s(16)
@marek22k
marek22k / ping_yggdrasil_nodes.rb
Created April 9, 2022 14:08
This script pings all Yggdrasil nodes and then displays a recommendation of nodes.
# Copyright (c) 2022 Marek Kuethe
# License: WTFPL
# This script pings all Yggdrasil nodes and then displays a recommendation of
# nodes. The script is assumed to be in the public-peers folder. If not, a
# different folder can be given as an argument. Nodes that cannot be reached via
# TLS or TCP are omitted. Each node is pinged 20 times over TCP. There is a 0.2
# second pause after each ping.
@marek22k
marek22k / bf_interpreter.rb
Created January 18, 2022 10:18
Ruby script that interprets brainfuck code
class BrainfuckInterpreter
BF_CHARS = {
inc_ptr: ">",
dec_ptr: "<",
inc_val: "+",
dec_val: "-",
loop_begin: "[",
loop_end: "]",
@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
@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
did:3:kjzl6cwe1jw145qhgqg0i7npr4mfseimjhy1p8avysib8ca3bc9kj6mfnwwi80j
@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}"
@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 / 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,