bins/ix: move to "script" and switch to using okturing
This commit is contained in:
parent
a5b3a31c69
commit
6f21f362c3
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@
|
||||
result
|
||||
.DS_Store
|
||||
tags
|
||||
*.bak
|
34
bins/ix.nix
34
bins/ix.nix
@ -1,36 +1,4 @@
|
||||
{ perl }: ''
|
||||
#!${perl}/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use HTTP::Tiny;
|
||||
if ($^O eq "openbsd") {
|
||||
require OpenBSD::Pledge;
|
||||
require OpenBSD::Unveil;
|
||||
|
||||
OpenBSD::Unveil::unveil("/", "") or die;
|
||||
OpenBSD::Pledge::pledge(qw( stdio dns inet rpath )) or die;
|
||||
}
|
||||
|
||||
my $http = HTTP::Tiny->new();
|
||||
|
||||
sub slurp {
|
||||
my ($fh) = @_;
|
||||
local $/;
|
||||
<$fh>;
|
||||
}
|
||||
|
||||
sub ix {
|
||||
my ($input) = @_;
|
||||
my $url = "http://sprunge.us";
|
||||
my $form = [ sprunge => $input ];
|
||||
my $resp = $http->post_form($url, $form)
|
||||
or die "could not POST: $!";
|
||||
$resp->{content};
|
||||
}
|
||||
|
||||
my $input = slurp('STDIN');
|
||||
my $url = ix($input);
|
||||
print $url;
|
||||
${builtins.readFile ./ix/ix.pl}
|
||||
''
|
||||
|
42
bins/ix/ix.pl
Normal file
42
bins/ix/ix.pl
Normal file
@ -0,0 +1,42 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use HTTP::Tiny;
|
||||
if ( $^O eq "openbsd" ) {
|
||||
require OpenBSD::Pledge;
|
||||
require OpenBSD::Unveil;
|
||||
|
||||
OpenBSD::Unveil::unveil( "/", "" ) or die;
|
||||
OpenBSD::Pledge::pledge(qw( stdio dns inet rpath )) or die;
|
||||
}
|
||||
|
||||
my $http = HTTP::Tiny->new();
|
||||
|
||||
sub slurp {
|
||||
my ($fh) = @_;
|
||||
local $/;
|
||||
<$fh>;
|
||||
}
|
||||
|
||||
sub ix {
|
||||
my ($input) = @_;
|
||||
my $url = "http://okturing.com";
|
||||
my $form = [
|
||||
a_body => $input,
|
||||
submit => "submit",
|
||||
fake => "fake",
|
||||
a_func => "add_post"
|
||||
];
|
||||
my $resp = $http->post_form( $url, $form )
|
||||
or die "could not POST: $!";
|
||||
$resp->{content};
|
||||
}
|
||||
|
||||
my $input = slurp('STDIN');
|
||||
my $out = ix($input);
|
||||
foreach my $line ($out) {
|
||||
if ( $line =~ m/href="(.+okturing\.com\/src.+\/body)\"/ ) {
|
||||
print $1, "\n";
|
||||
last;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user