This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
HOSTNAME="dummy" | |
IFACE="eth0" | |
LANG="en_US.UTF-8" | |
TIMEZONE="America/New_York" | |
# Hostname | |
echo $HOSTNAME > /etc/hostname |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'async' | |
require 'async/barrier' | |
require 'async/http/endpoint' | |
require 'async/websocket/client' | |
require 'nostrb/source' | |
module Nostrb | |
class Client | |
def initialize(relay_url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Pragma | |
ENUM = { | |
'auto_vacuum' => %w[none full incremental], | |
'synchronous' => %w[off normal full], | |
'temp_store' => %w[default file memory], | |
} | |
RO = %w[data_version freelist_count page_count] | |
RW = | |
%w[application_id analysis_limit auto_vacuum automatic_index |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://github.com/Gerg-L/nix-templates/blob/master/devShell%2Fflake.nix | |
{ | |
inputs = { | |
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | |
}; | |
outputs = | |
{ nixpkgs, ... }: | |
{ | |
devShells.x86_64-linux = | |
let |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[nix-shell:~/git/compsci]$ sh install_ruzzy.sh | |
<internal:/home/rwh/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require': libyaml-0.so.2: cannot open shared object file: No such file or directory - /home/rwh/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/x86_64-linux/psych.so (LoadError) | |
from <internal:/home/rwh/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require' | |
from /home/rwh/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/psych.rb:13:in `<top (required)>' | |
from <internal:/home/rwh/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require' | |
from <internal:/home/rwh/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require' | |
from /home/rwh/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/rubygems.rb:608:in `load_yaml' | |
from /home/rwh/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/rubygems/config_file.rb:346:in `load_file' | |
from /home/r |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rbconfig/sizeof' # can we use 64 bit ints? | |
require 'benchmark/ips' | |
require 'bitset' | |
# this should work well up to 64 bits on 64 bit platforms | |
# using native integers | |
# beyond that, Bignums will be generated | |
class BitsInt | |
attr_reader :int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'zlib' | |
require 'digest' | |
require 'openssl' | |
require 'benchmark/ips' | |
DIGESTS = %w[MD5 SHA1 SHA256 SHA384 SHA512 RMD160].map { |name| | |
Digest(name).new | |
} | |
OPENSSL_DIGESTS = %w[SHA1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[rwh@nixos:~/code/59774592dbaf12d47fa53d0c29c13e6d]$ ruby --version | |
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux] | |
[rwh@nixos:~/code/59774592dbaf12d47fa53d0c29c13e6d]$ ruby test_digest.rb | |
Run options: --seed 50097 | |
# Running: | |
.......... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bitset' | |
require 'zlib' | |
class BloomFilter | |
# just defaults, overrideable | |
SEED = 0 | |
FPR = 0.01 | |
def self.num_bits(num_items, fpr: FPR) | |
(-1 * num_items * Math.log(fpr) / Math.log(2) ** 2).ceil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'thread' | |
class ThreadInterrupt < RuntimeError; end | |
def try_ip | |
if rand(2).zero? | |
sleep 0.5 | |
true | |
else | |
sleep(rand(5) + 1) |
NewerOlder