4 no warnings
qw(uninitialized redefine);
8 # two annoying dependencies
9 use Mojo
::IOLoop
::Stream
;
12 #use Mojo::SMTP::Client;
13 use File
::Slurp
qw(read_file write_file);
15 our $JSON = JSON
::XS
->new->allow_nonref;
16 our $JSONS = JSON
::XS
->new->allow_nonref;
17 $JSONS->canonical(1); # sorts hashes
19 use YAML
::Syck
qw(Dump DumpFile Load LoadFile);
21 use Storable
'dclone';
25 use Time
::HiRes
qw(gettimeofday usleep);
26 use List
::Util
qw(first max maxstr min minstr reduce shuffle sum);
27 use List
::MoreUtils
qw(natatime uniq);
28 use POSIX qw
'ceil floor';
31 #use HTML::Entities qw(encode_entities decode_entities);
32 use Unicode
::UCD
'charinfo';
33 use Encode
qw(encode_utf8 decode_utf8 is_utf8);
35 our @F; # is Ring re subs from below
37 our $MAX_FCURSION = 240;
38 our $RADIAN = 1.57079633;
39 our $NUM = qr/-?\d+(?:\.\d+)?/;
50 # ^ curves should optimise away, accord ion
54 use Exporter
'import';
55 our @EXPORT = qw(read_file write_file Dump DumpFile Load LoadFile dclone gettimeofday usleep first max maxstr min minstr reduce shuffle sum natatime uniq ceil floor pi2 encode_entities decode_entities charinfo encode_utf8 decode_utf8 is_utf8 enth snooze dig ind acu acum slm slim sjson ejson djson zjson mkuuid mkuid flatline hitime hexbe hexend unico k2 kk ki saybl saygr sayg sayre sayyl say saycol wdump ddump inter F_delta stack fwind);
59 encode_entities
(decode_utf8
(shift));
63 return Time
::HiRes
::usleep
((shift || 500) * 10);
67 Digest
::SHA
::sha1_hex
(encode_utf8
(shift))
71 "$_[0]".join "\n$_[0]", split "\n", $_[1]
76 push @
{$n->{$y}||=[]}, $c;
81 push @
{$n->{$y}||=[]}, $c;
86 $s =~ s/\.\.(\.|\d+)$//;
92 ($f,$t,$c) = (40,40,$f) if defined $f && !defined $t && !defined $c;
93 ($f,$t,$c) = ($f,$f,$t) if defined $t && defined $f && !defined $c;
94 $c = ($c=~/^(.{$t})/s)[0]."..".(length($c) - $f) if length($c) > $f;
112 eval { $j = $JSON->decode($m) };
113 die "JSON DECODE FUCKUP: $@\n\nfor $m\n\n\n\n" if $@
;
114 die "$m\n\nJSON decoded to ~undef~" unless defined $j;
128 UUID
::generate
(my $i);
129 UUID
::unparse
($i, my $s);
134 (mkuuid
() =~ /^(\w+)-.+$/)[0]
139 map { ref $_ eq "ARRAY" ? flatline
(@
$_) : $_ } @_
143 return join ".", gettimeofday
();
147 my@h = map { sprintf('%x', int($_)) } @_;
148 wantarray ?
@h : join'',@h;
152 $_[0] =~ /([0-f])?([0-f])?([0-f])?$/;
153 map { hex($_) } $1, $2, $3;
157 my ($int, $wantinfo) = @_;
158 my $h = sprintf("%x", $int);
159 my @s = eval '"\\x{'.$h.'}"';
160 push @s, charinfo
($int) if $wantinfo;
161 wantarray ?
@s : shift @s
172 my $lim = 150 - (150 * ($d / 3));
173 !ref $s || "$s" !~ /(ARRAY|HASH)/ && return "!%:$s";
176 $v = "~" unless defined $v;
178 ?
"$_=".($lum ?
"{ ".slim
($lim,ok
($v,$lum-1))." }" : "$v")
181 : "$_=".slim
(150,"$v")
186 my ($ar,$re,$d) = @_;
187 # s, depth limit, depth
189 ($ar,$re) = ($re,$ar) if ref $re && $ar =~ /^\d+$/; # goner
190 $re = 2 if !defined $re;
191 if ($re !~ /^\d+$/ && !$ar) {
195 my $array;$array = sub {
198 if (ref $n ne 'ARRAY' || $y > 3) {
199 return ref($n)||$n if ref $n ne 'HASH' || !defined $n->{t
};
202 '[ '.slim
((160 / $y) + 10,join(',',map{$array->($_,$y+1)}@
$n)).' ]'
204 if (!ref $ar || "$ar" !~ /(HASH)/) {
206 $s = $array->($ar) if ref $ar eq 'ARRAY';
210 return ref $ar if ref $ar =~ /^[A-Z][a-z]/;
211 my $lim = 150 - (150 * ($d / 3));
212 my @keys = sort keys %$ar;
213 @keys = ('name') if $ar->{name
} && $ar->{bb
};
214 @keys = ('t','y','c','sc') if $ar->{t
} && $ar->{y
} && ($ar->{c
} || $ar->{sc
});
215 if ($ar->{cv
} eq '0.3' && $ar->{aspace
} eq '0.6') {
216 my $t = {map{$_=>1}qw
'aspace in out ov pcv space spc mu i u thi'};
217 @keys = grep{!$t->{$_}}@keys;
222 $v = "~" unless defined $v;
223 ref $v eq 'HASH' ?
do {
224 $v->{bb
} && $v->{name
} ?
225 ($d > 1 && ($v->{name
} eq 'Duv' || $v->{name
} eq 'Pre') ?
"$_:$v->{name}"
226 : $d > 1 && $_ eq 'at' ?
"at:".slim
(5,$v->{t
})
228 "$_={@".$v->{name
}."&".slm
(3,$v->{id
})."@}"
231 $v eq $ar ?
"$k:same" :
232 "$_=".($re?
"{ ".slim
($lim,ki
($v,$re-1,$d))." }":"$v")
234 : ref $v eq 'ARRAY' ?
"$k=".$array->($v)
235 : "$_=".slim
(150,"$v")
240 saycol
(bright_blue
=> @_)
248 saycol
(bright_green
=> @_)
256 saycol
(bright_yellow
=> @_)
265 print colored
(join("\n", @_,""), $colour);
266 wantarray ?
@_ : shift @_
272 if (@_ && $thing =~ /^\d+$/) {
276 $Data::Dumper
::Maxdepth
= $maxdepth;
277 my $s = join "\n", map { s/ / /g; $_ } split /\n/, Dumper
($thing);
278 $s =~ s/^\$VAR1 = //;
289 1 || !( do { /^(\s*)hostinfo:/ && do { $ind = $1; 1 } }
295 split "\n", Dump
($thing);
302 $F[1]->{inter
} .= " -{".$ki."}\n";
307 my $then = $F[0]->{hitime
};
308 my $d = sprintf("%.3f",$now-$then);
309 $d = $d<1 ?
($d*1000).'ms' : $d.'s';
314 my $for = shift || 169;
315 $b = 1 unless defined $b;
317 while (my $f = join " ", (caller($b))[0,3,2]) {
318 last unless defined $f;
319 my $surface = $f =~ s/(Mojo)::Server::(Sand)Box::\w{24}/$1$2/g
320 || $f =~ m/^Mojo::IOLoop/
321 || $f =~ m/^Mojolicious::Controller/;
322 $f =~ s/(MojoSand\w+) (MojoSand\w+)::/$2::/;
334 return $way->{$point} if exists $way->{$point};
335 my @path = split /\/|\
./, $point;
344 return $h if defined $h;
346 return undef unless $point =~ /\*/;
347 die "sat rs findy $point";