Delete a bunch of scripts

This commit is contained in:
Ev Bogdanov 2017-08-16 13:54:35 +03:00
parent 3aa6845583
commit f2cdfeba2b
9 changed files with 3 additions and 257 deletions

38
bin/a+
View file

@ -1,38 +0,0 @@
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use open qw(:std :utf8);
my ($d) = @ARGV;
$d = "=>" unless $d;
my $max = 0;
my @ls = ();
my @rs = ();
my $i = 1;
my $t = "";
while (<STDIN>) {
if ($i == 1) {
$t = $1 if /^(\s+)/;
$i += 1;
}
$_ =~ s/^\s+|\s+$//g;
my @ls_rs = split $d, $_, 2;
my $len = length $ls_rs[0];
$max = $len if $len > $max;
push @ls, $ls_rs[0];
push @rs, $ls_rs[1];
}
for (my $i = 0; $i < @ls; $i += 1) {
my $l = $ls[$i];
my $r = $rs[$i];
my $n = $max - length $l;
my $s = " " x $n;
$l .= $s;
print $t, $l, $d, $r;
print "\n" unless $i + 1 == @ls;
}

View file

@ -1,5 +0,0 @@
#!/usr/bin/env perl
while (<STDIN>) {
print join "", map { ucfirst $_ } (split "_", $_);
}

View file

@ -1,7 +0,0 @@
#!/usr/bin/env perl
while (<STDIN>) {
s/([A-Z]+)([A-Z][a-z])/$1_$2/g;
s/([a-z\d])([A-Z])/$1_$2/g;
print lc;
}

5
bin/d
View file

@ -1,5 +0,0 @@
#!/usr/bin/env perl
open FH, "| 9p write acme/$ENV{winid}/addr";
print FH ",";
system "9p write acme/$ENV{winid}/data </dev/null";

View file

@ -1,9 +0,0 @@
#!/usr/bin/env bash
if [ $# -ne 1 ]
then
echo 'gimme erlang module, pls'
exit 1
fi
erl -man "$1" | nobs+

View file

@ -1,47 +0,0 @@
#!/usr/bin/env bash
if [ $# -eq 0 ]; then
echo 'Usage: erun mod.erl arg1 arg2 ...'
exit 1
fi
## FILE WITH SOURCE CODE
## -----------------------------------------------------------------------------
file="$1"
if [ ! -f "$file" ]; then
echo 'File not found'
exit 1
fi
## ERLANG MODULE TO RUN
## -----------------------------------------------------------------------------
mod=$(echo $file | sed -e 's/.erl//')
## ARGUMENTS TO PASS TO THE MODULE
## -----------------------------------------------------------------------------
shift
args="$@"
if [ ! "$args" ]; then
# Without arguments main/0 will be called. Force main/1
args="''"
fi
## COMPILE AND RUN
## -----------------------------------------------------------------------------
erlc $file
if [ $? -ne 0 ]; then
exit 1
fi
# Module should implement main/1 function
erl -noshell +pc unicode -run $mod main $args -s init stop
## CLEAN UP
## -----------------------------------------------------------------------------
rm "$mod.beam"

View file

@ -1,72 +0,0 @@
#!/usr/bin/env perl
use strict;
use warnings;
## USAGE
## -----------------------------------------------------------------------------
## firefox:
## put+ ff
## chrome:
## put+ ch
## safari:
## put+ sa
## DATA
## -----------------------------------------------------------------------------
use constant FIREFOX => 'ff';
use constant CHROME => 'ch';
use constant SAFARI => 'sa';
my $browser = $ARGV[0] || CHROME;
my $osascript;
## ACME 'Put'
## -----------------------------------------------------------------------------
open my $fh, "| 9p write acme/$ENV{winid}/ctl";
print $fh "put\n";
close $fh;
## FIREFOX SCRIPT (SADLY, IT'S FULL OF BUGS)
## -----------------------------------------------------------------------------
if ($browser eq FIREFOX) {
$osascript = 'tell application "Firefox"
activate
delay 2
tell application "System Events"
keystroke "r" using command down
end tell
end tell';
}
## CHROME SCRIPT
## -----------------------------------------------------------------------------
if ($browser eq CHROME) {
## wait for server update
sleep 2;
$osascript = 'tell application "Google Chrome" to reload active tab of window 1';
}
## SAFARI SCRIPT
## -----------------------------------------------------------------------------
if ($browser eq SAFARI) {
## also wait for server update
sleep 2;
$osascript = 'tell application "Safari"
set docUrl to URL of document 1
set URL of document 1 to docUrl
end tell';
}
## RUN SCRIPT
## -----------------------------------------------------------------------------
system "osascript -e '$osascript'";

63
bin/w+
View file

@ -1,63 +0,0 @@
#!/usr/bin/env perl
use strict;
use warnings;
use feature 'say';
use utf8;
use open qw(:std :utf8);
my $WIDTH_DEFAULT = 80;
my $WIDTH = $ARGV[0] || $WIDTH_DEFAULT;
sub main {
my $buf = '';
while (my $line = <STDIN>) {
if ($line =~ /^\s+$/) {
say $buf;
say '' if ($buf);
$buf = '';
next;
}
if ($buf) {
$line = $buf . $line;
}
my ($head, $tail) = handle_str($line);
say $head;
$buf = handle_buf($tail);
}
say $buf if $buf;
}
sub handle_buf {
my $buf = shift;
my $len = length($buf);
if ($len == $WIDTH) {
say $buf;
return '';
}
if ($len < $WIDTH) {
return $buf;
}
## $len > $WIDTH
my ($head, $tail) = handle_str($buf);
say $head;
handle_buf($tail);
}
sub handle_str {
my $str = shift;
if ($str =~ m/^(.{0,$WIDTH})\s(.*)$/) {
return ($1, $2);
}
## no spaces here: 0..$WIDTH
if ($str =~ m/^(\S*)\s(.*)$/) {
return ($1, $2);
}
## no whitespace at all
if ($str =~ m/^(\S+)$/) {
return ($1, '');
}
die "ooops!";
}
main();