Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

stop spec'ing xhtml for tidy; add simple img uploader

  • Loading branch information...
commit 1f01ee5fc650e7591a9e0a4642f4a991d2c3ea79 1 parent e8d3285
@dbushong authored
Showing with 50 additions and 1 deletion.
  1. +49 −0 bin-shared/ssurl
  2. +1 −1  dot.tidyrc
View
49 bin-shared/ssurl
@@ -0,0 +1,49 @@
+#!/usr/bin/perl
+#
+# ssurl - upload a screenshot and get a public url for it
+# TODO: support multiple services, don't do just screenshots
+#
+
+use strict;
+use warnings;
+use Getopt::Std;
+use File::Basename;
+use utf8;
+
+my $dir = (getpwuid($<))[7] . '/Desktop';
+my $num = 1;
+
+my $prog = basename($0);
+my %opt;
+getopts('hd:n:', \%opt);
+usage() if $opt{h} || @ARGV;
+sub usage {
+ die <<EOU;
+usage: $prog [-d dir] [-n num]
+ -d: dir to check for new screenshots; default: $dir
+ -n: number most recent to upload; default: $num
+EOU
+}
+
+$dir = $opt{d} if $opt{d};
+$num = $opt{n} if $opt{n};
+
+opendir(my $dh, $dir) || die $!;
+my @shots = sort {
+ (stat("$dir/$b"))[9] <=> (stat("$dir/$a"))[9]
+} grep(/^(Screenshot(-\d+)?|screenshot\d+)\.png$/, readdir($dh));
+closedir($dh);
+
+splice(@shots, $num);
+
+for my $file (@shots) {
+ # TODO: use LWP
+ open(my $fh, '-|', 'curl', '-F', "file=\@$dir/$file;type=image/png", '-is',
+ '-F', '__submit=Upload', 'http://simimage.com/')
+ || die $!;
+ my $res = do { local $/; <$fh> };
+ close($fh);
+ $res =~ /HTTP\/1.1 302 Found.+?[lL]ocation:\s+(\S+)/s
+ || die "couldn't find redirect\n";
+ print "http://simimage.com/f$1\n";
+}
View
2  dot.tidyrc
@@ -4,6 +4,6 @@ wrap-php: no
tab-size: 8
indent: yes
indent-spaces: 2
-output-xhtml: yes
+#output-xhtml: yes
char-encoding: raw
fix-bad-comments: no
Please sign in to comment.
Something went wrong with that request. Please try again.