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
#!/usr/bin/env bash | |
# Inspired from [flash.sh](https://github.com/tallguyjenks/fla.sh) | |
# See original license further down | |
# | |
# Copyright © 2024, Lucien Grondin (grondilu on github) | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the “Software”), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
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
# Metamath commentless grammar | |
# remove comments beforehand with | |
# .subst: / '$(' ~ '$)' .*? /, '', :g | |
unit grammar Metamath; | |
rule TOP { ^ <database> $ } | |
rule database { <outermost-scope-stmt>* } | |
rule outermost-scope-stmt { |
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
# This file contains that French "translation" of features of the | |
# Raku Programming Language. | |
# | |
# See tools/build/L10N/README.md for more explanation. | |
# KEY TRANSLATION | |
block-default défaut | |
block-else sinon | |
block-elsif ousi | |
block-for pour |
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
unit class QuadraticIrrational does Real; | |
# | |
# This role cannot meaningfully be converted | |
# into a core type, so we'll "burn the bridge" | |
method Bridge {!!!} | |
has UInt $.discriminant; | |
has Rat(Cool) ($.u, $.v); | |
submethod TWEAK { |
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
unit module Unum; | |
=begin LICENSE | |
Copyright © 2017 John L. Gustafson | |
Permission is hereby granted, free of charge, to any person obtaining a copy of | |
this software and associated documentation files (the "Software"), to deal in | |
the Software without restriction, including without limitation the rights to | |
use, copy, modify, merge, publish, distribute, sub-license, and/or sell copies | |
of the Software, and to permit persons to whom the Software is furnished to do | |
so, subject to the following conditions: |
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
#!/usr/bin/env bash | |
# Translated from https://github.com/bitpay/bitcore/blob/master/packages/bitcore-mnemonic/lib/pbkdf2.js | |
# /** | |
# * PBKDF2 | |
# * Credit to: https://github.com/stayradiated/pbkdf2-sha512 | |
# * Copyright (c) 2014, JP Richardson Copyright (c) 2010-2011 Intalio Pte, All Rights Reserved | |
# */ | |
declare hash_name="$1" key_str="$2" salt_str="$3" | |
declare -ai key salt u t block1 dk |
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
unit module Rice; | |
# L<https://en.wikipedia.org/wiki/Golomb_coding> | |
our sub encode(Int $n, UInt :$k = 2) { | |
my $d = 2**$k; | |
my $q = $n div $d; | |
my $b = sign(1 + sign($q)); | |
my $m = abs($q) + $b; | |
flat | |
$b xx $m, 1 - $b, |
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
grammar Bech32 { | |
constant @data-charset = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l'.comb; | |
constant %data-charset = @data-charset.pairs.invert; | |
sub polymod(@values --> UInt) { | |
constant @gen = 0x3b6a57b2, 0x26508e6d, 0x1ea119fa, 0x3d4233dd, 0x2a1462b3; | |
my uint32 $chk = 1; | |
for @values -> $v { | |
my $b = $chk +> 25; | |
$chk = ($chk +& 0x1ffffff) +< 5 +^ $v; |
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
#!/usr/bin/env raku | |
unit module Ed25519; | |
sub sha512(blob8 $b) returns blob8 { | |
given run <openssl dgst -sha512 -binary>, :in, :out, :bin { | |
.in.write: $b; | |
.in.close; | |
return .out.slurp: :close; | |
} | |
} |
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
"use strict"; | |
class Matrix { | |
constructor(a, b, c, d) { | |
if ([a,b,c,d].every(x => x instanceof Number || typeof(x) == "number")) { | |
this.n = 1; | |
} else if ([a,b,c,d].every(x => x instanceof Matrix && x.n == a.n)) { | |
this.n = a.n + 1; | |
} else throw new Error("wrong arguments type"); | |
this.a = a; |
NewerOlder