Skip to content

Instantly share code, notes, and snippets.

@kga
Created June 13, 2009 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kga/129229 to your computer and use it in GitHub Desktop.
Save kga/129229 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
# original code by id:antipop
# http://subtech.g.hatena.ne.jp/antipop/20071121/1195652375
use strict;
use warnings;
use Config::Pit;
use File::Temp;
use IPC::Run qw/run/;
use WebService::Hatena::Fotolife;
my $config = pit_get('hatena.ne.jp', require => {
'username' => 'your hatena id',
'password' => 'your password on hatena',
});
my $filename = File::Temp->new( UNLINK => 1, SUFFIX => '.png' );
if (run(['screencapture', '-i', scalar $filename])) {
my $hatena = WebService::Hatena::Fotolife->new;
$hatena->username($config->{username});
$hatena->password($config->{password});
my ($date) = $hatena->createEntry(
title => $ARGV[0] || '',
filename => scalar $filename,
folder => $ARGV[1] || 'gyazo',
) =~ /(\d{14})$/;
my $url = sprintf "http://f.hatena.ne.jp/%s/%s", $config->{username}, $date;
run(['echo', $url], '|', [qw(pbcopy)]);
print "Successfully uploaded: $url\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment