Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions The_Message/tools/convert.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/perl

#This script takes a 8 bit binary string (that is, 0s and 1s as text) with a "0b" prefix as input,
#and outputs the original input, and its decimal, octal, and hexadecimal values to stdout.
#It also writes the input as binary to the file output.data
#example usage:
# $ echo -e "0b10101010\n0b01010101" | ./convert.pl
# 0b10101010 170 252 AA
# 0b01010101 85 125 55
# $ xxd output.data
# 00000000: aa55 .U
#
#You may use e.g. awk for adding the "0b" if your strings don't have that prefix yet.
use strict;
use warnings;
open( FH, ">output.data" ) or die "dang it!\n";

foreach my $line ( <STDIN> ){
chomp $line;
my $decvalue = oct($line);
my $octvalue = sprintf("%o", $decvalue);
my $hexvalue = sprintf("%X", $decvalue);
my $binary = pack ('W*', $decvalue);
print "$line $decvalue $octvalue $hexvalue\n";
syswrite ( FH, $binary );
}
close FH;
14 changes: 14 additions & 0 deletions The_Message/tools/hilbertpoints.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/perl

#This script will output the points of a space filling curve to stdout.
#For more information, see also: https://metacpan.org/pod/Math::PlanePath::HilbertCurve
#usage: ./hilbertpoints.pl
use Math::PlanePath::HilbertCurve;

my $path = Math::PlanePath::HilbertCurve->new;
my @a = (0..65535);
my $i = 0;
for $i(@a){
my($x, $y) = $path->n_to_xy($i);
print "$x $y\n"
}
Loading