Skip to content

Instantly share code, notes, and snippets.

#!/usr/local/bin/perl
use strict;
use warnings;
use Net::Twitter;
use Config::Pit;
my $message = do { local $/; <STDIN> };
my $header = parse_header($message);
#!perl
use strict;
use warnings;
use WWW::Mechanize;
use Config::Pit;
use URI;
my $loctouch_id;
while (my $line = <STDIN>) {
--- Mech.pm 2009-07-28 21:07:16.000000000 +0900
+++ Mech.pm 2010-04-21 11:49:12.000000000 +0900
@@ -75,7 +75,7 @@
$self->{mech}->get($uri);
# adapted from Plagger::Plugin::CustomFeed::Mixi
- if ( $self->content =~ /action="\/?login\.pl"/ ) {
+ if ( $self->content =~ /action="\/?login\.pl/ ) {
# shouldn't be path but path_query, obviously
$self->{login}->{next_url} = $uri->path_query;
@nipotan
nipotan / gist:315629
Created February 26, 2010 10:51
it's useful if you don't want someone to touch your script without your approval
use strict;
use Term::ProgressBar;
use Time::HiRes qw(sleep);
$SIG{INT} = sub {};
my $progress = Term::ProgressBar->new({
name => 'deleting all data',
count => 1000,
ETA => 'linear',
use strict;
use Web::Scraper;
use URI;
my $website = scraper {
process 'div#profile > address > ul > li > a', url => '@href';
result 'url';
};
my $res = $website->scrape(URI->new('http://twitter.com/foo_bar_baz'));
warn $res->as_string if $res;
use strict;
use warnings;
use utf8;
use Unicode::RecursiveDowngrade;
use File::Temp qw(:mktemp);
use HTML::Entities;
use WWW::Mechanize;
use Web::Scraper;
use Flickr::Upload;
use Data::Dumper;
@nipotan
nipotan / gist:135048
Created June 24, 2009 06:23
XXE precaution
#!perl
use strict;
use XML::Simple;
use Data::Dumper;
my $xml = do { local $/ = undef; <DATA> };
my @entities = $xml =~ /<!ENTITY\s+(\w+)\s+.+?>/sg;
my $entities_re = '&(?:' . join('|', @entities) . ');';
$xml =~ s/$entities_re//g;
@nipotan
nipotan / gist:135043
Created June 24, 2009 06:11
XXE Test
#!perl
use strict;
use XML::Simple;
use Data::Dumper;
my $ref = XMLin(<<'END');
<?xml version="1.0"?>
<!DOCTYPE str [
<!ENTITY pass SYSTEM "/etc/passwd">
]>
#!perl
use strict;
use utf8;
use Net::IDN::Encode;
print domain_to_ascii('.東京'), "\n";
print domain_to_ascii('.大阪'), "\n";