This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use v5.16; | |
use warnings; | |
use autodie qw( :all ); | |
use utf8::all; | |
use LWP::UserAgent; | |
my $ua = LWP::UserAgent->new; | |
my $can_accept = HTTP::Message::decodable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use v5.16; | |
use warnings; | |
use autodie qw( :all ); | |
use utf8::all; | |
use List::MoreUtils qw( uniq any ); | |
use Benchmark qw( cmpthese :hireswallclock ); | |
my %file_names = (); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use v5.14; | |
use warnings; | |
use utf8::all; | |
use File::Slurp qw( read_file ); | |
my $pattern_list = do 'fw.pl'; | |
my @patterns = keys $pattern_list; | |
my $content = read_file( 'dracula.txt' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use v5.14; | |
use warnings; | |
use utf8::all; | |
use File::Slurp qw( read_file ); | |
my $pattern_list = do 'fw.pl'; | |
my @patterns = keys $pattern_list; | |
my $content = read_file( 'dracula.txt' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use v5.14; | |
use warnings; | |
use utf8::all; | |
use File::Slurp qw( read_file ); | |
... | |
my @patterns = map {qr/\b$_\b/ixms} keys $pattern_list; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use v5.14; | |
use warnings; | |
use utf8::all; | |
use List::Util qw( reduce ); | |
use List::MoreUtils qw( uniq any ); | |
use Path::Class::Rule; | |
use File::Slurp qw( read_file ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use v5.14; | |
use warnings; | |
use utf8::all; | |
use Encode; | |
use Data::Dumper; | |
use JSON::XS qw( decode_json ); | |
my $wl = '{"creche":"crèche", "¥":"£", "₡":"волн"}'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
import BeautifulSoup as soup | |
import requests | |
... | |
r = requests.get(host + page) | |
doc = soup.BeautifulSoup(r.content) | |
titles = doc.table.findAll(True, {'class': 'title'}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The following regexp will break | |
indentation = '<img src="http:\/\/ycombinator.com\/images\/s.gif" height=1 width=(\d+)><\/td>' | |
score = '<span id=score_([0-9]+)>([0-9]+) point' | |
user_id = '<a href="user\\?id=([^"]+)">' | |
time_ago = '<\/a>([^\|]+)\|' | |
comment_body = '<span class=\\"comment\\"><font color=#000000>(.*?)<\\/font>' | |
regexp_str = "#{indentation}.*?#{score}.*?#{user_id}.*?#{time_ago}.*?#{comment_body}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
next if content =~ />#{username}</ # skip if we posted it | |
next unless post.inner_html =~ /vote/ # skip if it's not a post | |
id = content[/\_(\d+)/,1] | |
comment_text = (post/'.comment').first.inner_text | |
commenter = content[/user\?id=(\w+)/,1] |