use HTTP::ProxyPAC;
use LWP::UserAgent;

my $ua = LWP::UserAgent->new;
my $uri = URI->new(quot;http://portal.titech.ac.jp/...
use JavaScript::Runtime;

sub init {
    my($class, $code) = @_;

    my $runtime = JavaScript::Runtime->new;
    my $cont...
package HTTP::ProxyPAC::Functions;
# stolen from HTTP::ProxyAutoConfig

sub isPlainHostName {
  my ($host) = @_;

    retu...
use pQuery::DOM;

my $v = pQuery::DOM->fromHTML('<div id=quot;fooquot;>bar</div>')
    ->getElementById('foo')->innerHTML;
use pQuery::DOM;
no capitalization ‘pQuery::DOM’;

my $v = pQuery::DOM->fromHTML('<div id=quot;fooquot;>bar</div>')
    ->...
use PHP::Session;

my $session = PHP::Session->new($id);

# session id
my $id = $session->id;

# get/set session data
my $...
when = 60.days.ago
datasize = 200.megabytes
use autobox;
use autobox::DateTime::Duration;

# equivalent to DateTime::Duration->new(months => 1, days => 2);
$duration ...
my $ttl = 608400; # 7 days
my $ttl = 608400; # 7 days
          604800
my $ttl = 24 * 60 * 60 * 7; # 7 days
use Time::Duration::Parse;

my $ttl = parse_duration “7 days”;
$x = “x{5bae}”;     # Unicode
$y = “xe5xaexae”; # UTF-8

$z = $x . $y;
$x = “x{5bae}”;     # Unicode
$y = “xe5xaexae”; # UTF-8

$z = $x . $y;
     x{5bae}x{e5}x{ae}x{ae}
use Encode;

$x = “x{5bae}”;     # Unicode
$y = “xe5xaexae”; # UTF-8

$z = $x . decode_utf8($y);
use Encode::DoubleEncodedUTF8;

$x = “x{5bae}”;     # Unicode
$y = “xe5xaexae”; # UTF-8

$z = $x . $y;
$z = decode(“utf-8-...
my $latin1_as_utf8 = quot;[xC2xC3][x80-xBF]quot;;

my $valid_utf8_regexp = <<'.' ;
        [x{00}-x{7f}]
      | [x{c2}-x{...
use utf8;
use URI::Find;

my $text = <<TEXT;
Japanese Wikipedia home page URL is
http://ja.wikipedia.org/wiki/
TEXT

my $f...
use utf8;
use URI::Find::UTF8;

my $text = <<TEXT;
Japanese Wikipedia home page URL is
http://ja.wikipedia.org/wiki/
TEXT
...
use Lingua::JA::Hepburn::Passport;

my $hepburn = Lingua::JA::Hepburn::Passport->new;
$hepburn->romanize(quot;            ...
my $user = “miyagawa”;
my $pass = “blahblah”;

$api->login($user, $pass);
use LWP::UserAgent::Keychain;

my $ua = LWP::UserAgent::Keychain->new;
$ua->get(quot;http://proteceted.example.com/quot;);
<?xml version=”1.0”?>
<heroes>Larry & Schwern</heroes>
<?xml version=”1.0”?>
<heroes>Larry &amp; Schwern</heroes>
<?xml version=”1.0”?>
<shout>I &hearts; Perl</shout>
<?xml version=”1.0”?>
<shout>I ♥ Perl</shout>
<?xml version=”1.0”?>
<div>
<a href=”/search?q=YAPC&Asia”>link</a>
</div>
<?xml version=”1.0”?>
<div>
<a href=”/search?q=YAPC&amp;Asia”>link</a>
</div>
<?xml version=”1.0”?>
<rss>
<channel>
<item>
<summary>YAPC rocks</summary>
<xhtml:body>
YAPC <xhtml:strong>really</xhtml:s...
<?xml version=”1.0”?>
<rss xmlns:xhtml=”http://www.w3.org/1999/xhtml”>
<channel>
<item>
<summary>YAPC rocks</summary>
<xht...
use XML::LibXML;
my $parser = XML::LibXML->new;
my $doc = $parse->parse_string($xml);
use XML::Liberal;
my $parser = XML::Liberal->new(‘LibXML’);
my $doc = $parse->parse_string($xml);
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
20 modules i haven't yet talked about
Upcoming SlideShare
Loading in...5
×

20 modules i haven't yet talked about

9,142

Published on

Published in: Technology
5 Comments
2 Likes
Statistics
Notes
No Downloads
Views
Total Views
9,142
On Slideshare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
42
Comments
5
Likes
2
Embeds 0
No embeds

No notes for slide

20 modules i haven't yet talked about

  1. 1. use HTTP::ProxyPAC; use LWP::UserAgent; my $ua = LWP::UserAgent->new; my $uri = URI->new(quot;http://portal.titech.ac.jp/proxy.pacquot;); my $pac = HTTP::ProxyPAC->new($uri); my $res = $pac->find_proxy(quot;http://www.google.com/quot;); if ($res->direct) { # ... } elsif ($res->proxy) { $ua->proxy('http' => $res->proxy); }
  2. 2. use JavaScript::Runtime; sub init { my($class, $code) = @_; my $runtime = JavaScript::Runtime->new; my $context = $runtime->create_context(); for my $func (@HTTP::ProxyPAC::Functions::PACFunctions) { no strict 'refs'; $context->bind_function( name => $func, func => sub { &{quot;HTTP::ProxyPAC::Functions::$funcquot;}(@_) }); } $context->eval($code); bless { context => $context }, $class; }
  3. 3. package HTTP::ProxyPAC::Functions; # stolen from HTTP::ProxyAutoConfig sub isPlainHostName { my ($host) = @_; return (($host =~ /./) ? 0 : 1); } sub dnsResolve { my ($host) = @_; return unless isResolvable($host); return inet_ntoa(inet_aton($host)); } sub myIpAddress { return inet_ntoa(inet_aton(hostname())); }
  4. 4. use pQuery::DOM; my $v = pQuery::DOM->fromHTML('<div id=quot;fooquot;>bar</div>') ->getElementById('foo')->innerHTML;
  5. 5. use pQuery::DOM; no capitalization ‘pQuery::DOM’; my $v = pQuery::DOM->fromHTML('<div id=quot;fooquot;>bar</div>') ->get_element_by_id('foo')->innerHTML;
  6. 6. use PHP::Session; my $session = PHP::Session->new($id); # session id my $id = $session->id; # get/set session data my $foo = $session->get('foo'); $session->set(bar => $bar);
  7. 7. when = 60.days.ago datasize = 200.megabytes
  8. 8. use autobox; use autobox::DateTime::Duration; # equivalent to DateTime::Duration->new(months => 1, days => 2); $duration = 1->month + 2->days; # equivalent to DateTime->now->add(years => 2); $datetime = 2->years->from_now; # equivalent to DateTime->now->add(months => 4, years => 5); $datetime = (4->months + 5->years)->from_now; # equivalent to DateTime->now->subtract(days => 3); $datetime = 3->days->ago;
  9. 9. my $ttl = 608400; # 7 days
  10. 10. my $ttl = 608400; # 7 days 604800
  11. 11. my $ttl = 24 * 60 * 60 * 7; # 7 days
  12. 12. use Time::Duration::Parse; my $ttl = parse_duration “7 days”;
  13. 13. $x = “x{5bae}”; # Unicode $y = “xe5xaexae”; # UTF-8 $z = $x . $y;
  14. 14. $x = “x{5bae}”; # Unicode $y = “xe5xaexae”; # UTF-8 $z = $x . $y; x{5bae}x{e5}x{ae}x{ae}
  15. 15. use Encode; $x = “x{5bae}”; # Unicode $y = “xe5xaexae”; # UTF-8 $z = $x . decode_utf8($y);
  16. 16. use Encode::DoubleEncodedUTF8; $x = “x{5bae}”; # Unicode $y = “xe5xaexae”; # UTF-8 $z = $x . $y; $z = decode(“utf-8-de”, $z);
  17. 17. my $latin1_as_utf8 = quot;[xC2xC3][x80-xBF]quot;; my $valid_utf8_regexp = <<'.' ; [x{00}-x{7f}] | [x{c2}-x{df}][x{80}-x{bf}] | x{e0} [x{a0}-x{bf}][x{80}-x{bf}] | [x{e1}-x{ec}][x{80}-x{bf}][x{80}-x{bf}] | x{ed} [x{80}-x{9f}][x{80}-x{bf}] | [x{ee}-x{ef}][x{80}-x{bf}][x{80}-x{bf}] | x{f0} [x{90}-x{bf}][x{80}-x{bf}] | [x{f1}-x{f3}][x{80}-x{bf}][x{80}-x{bf}][x{80}-x{bf}] | x{f4} [x{80}-x{8f}][x{80}-x{bf}][x{80}-x{bf}] . sub decode { my($obj, $buf, $chk) = @_; $buf =~ s{((?:$latin1_as_utf8){2,3})}{ _check_utf8_bytes($1) }ego; $_[1] = '' if $chk; # this is what in-place edit means Encode::decode_utf8($buf); } sub _check_utf8_bytes { my $bytes = shift; my $copy = $bytes; my $possible_utf8 = ''; while ($copy =~ s/^(.)(.)//) { $possible_utf8 .= chr( (ord($1) << 6 & 0xff) | ord($2) ) } $possible_utf8 =~ /$valid_utf8_regexp/xo ? $possible_utf8 : $bytes; }
  18. 18. use utf8; use URI::Find; my $text = <<TEXT; Japanese Wikipedia home page URL is http://ja.wikipedia.org/wiki/ TEXT my $finder = URI::Find->new(&cb); $finder->find($text); sub cb { warn shift } # http://ja.wikipedia.org/wiki/
  19. 19. use utf8; use URI::Find::UTF8; my $text = <<TEXT; Japanese Wikipedia home page URL is http://ja.wikipedia.org/wiki/ TEXT my $finder = URI::Find::UTF8->new(&cb); $finder->find($text); sub cb { my($uri, $orig) = @_; } # http://ja.wikipedia.org/wiki/
  20. 20. use Lingua::JA::Hepburn::Passport; my $hepburn = Lingua::JA::Hepburn::Passport->new; $hepburn->romanize(quot; quot;); # KATO SHUHEI
  21. 21. my $user = “miyagawa”; my $pass = “blahblah”; $api->login($user, $pass);
  22. 22. use LWP::UserAgent::Keychain; my $ua = LWP::UserAgent::Keychain->new; $ua->get(quot;http://proteceted.example.com/quot;);
  23. 23. <?xml version=”1.0”?> <heroes>Larry & Schwern</heroes>
  24. 24. <?xml version=”1.0”?> <heroes>Larry &amp; Schwern</heroes>
  25. 25. <?xml version=”1.0”?> <shout>I &hearts; Perl</shout>
  26. 26. <?xml version=”1.0”?> <shout>I ♥ Perl</shout>
  27. 27. <?xml version=”1.0”?> <div> <a href=”/search?q=YAPC&Asia”>link</a> </div>
  28. 28. <?xml version=”1.0”?> <div> <a href=”/search?q=YAPC&amp;Asia”>link</a> </div>
  29. 29. <?xml version=”1.0”?> <rss> <channel> <item> <summary>YAPC rocks</summary> <xhtml:body> YAPC <xhtml:strong>really</xhtml:strong> rocks. </xhtml:body> </item> </channel> </rss>
  30. 30. <?xml version=”1.0”?> <rss xmlns:xhtml=”http://www.w3.org/1999/xhtml”> <channel> <item> <summary>YAPC rocks</summary> <xhtml:body> YAPC <xhtml:strong>really</xhtml:strong> rocks. </xhtml:body> </item> </channel> </rss>
  31. 31. use XML::LibXML; my $parser = XML::LibXML->new; my $doc = $parse->parse_string($xml);
  32. 32. use XML::Liberal; my $parser = XML::Liberal->new(‘LibXML’); my $doc = $parse->parse_string($xml);
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×