Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

dankogai (3580)

dankogai
  (email not shown publicly)

Journal of dankogai (3580)

Friday November 03, 2006
11:56 AM

If you can patent the script tag hack, what about JAPH?

United States Patent: 6941562

The present invention permits a JavaScript-based Remote Procedure Call (RPC) to be executed from a Web page displayed in a Web browser window, without utilizing browser plug-in, Java Applet, or ActiveX technology. Traditionally, clunky downloads and Web browser plug-ins has been required to enable Web page interactivity, which greatly compromises the performance and reach of the Web page. Based purely on HTML and JavaScript, the present invention utilizes the HTML <script> element to pass data to the server and execute a remote procedure, receiving the resulting output to the same displayed Web page. The present invention can be used to build a lightweight Web page that offers real-time data and interactivity.

The Script Tag Hack is a great hack and my hats are off they found the hack in 2001. But a patent? Now it's my jaw's turn to drop. That's a hack. No more, no less. Neither invension nor innovation that deserves a patent.

If any given creative use of un(known|documented) features can be patented, why not JAPH?

Dan the Just Another Patent Violator(?)

Thursday May 04, 2006
04:10 AM

PerlIO Benchmark

[ #29525 ]

I had a chance to benchmark various PerlIO layers. The result was striking.

Benchmarking code:

use strict;
use warnings;
use Benchmark qw(timethese cmpthese);
our $test_file = 'test.txt';
# 64 chars including LF;
my $test_line = join '', ( '0' .. '9', 'A' .. 'Z', 'a' .. 'z', '_', "\n" );
sub make_test_file {
    my $kb    = shift;              # size in KB
    my $block = $test_line x 16;    # 1024 bytes;
    my $fh;
    open $fh, ">:raw", $test_file or die "$test_file:$!";
    print {$fh} $block for ( 1 .. $kb );
    close $fh;
    # slurp once to make sure the file buffer is in effect;
    open $fh, "<:raw", $test_file or die "$test_file:$!";
    my $content = do { local $/; <$fh> };
    close $fh;
}
sub make_tester {
    my $layer = shift;
    my $openarg = $layer ? "<:$layer" : "<";
    sub {
        open my $fh, $openarg, $test_file or die "$test_file:$!";
        $_ ne $test_line and die while (<$fh>);
        close $fh;
      }
}
my %these = map { $_ => make_tester($_) } qw( raw perlio mmap );
$these{nolayer} = make_tester(q());

for my $filesize ( map { 4**$_ } ( 0 .. 4 ) ) {
    make_test_file($filesize);
    print "#### Testing for $filesize KB Read\n";
    cmpthese( timethese( 0, \%these ) );
}
delete $these{raw};    # because this guy is too slow on large files!
for my $filesize ( map { 4**$_ } ( 5 .. 8 ) ) {
    make_test_file($filesize);
    print "#### Testing for $filesize KB Read\n";
    cmpthese( timethese( 0, \%these ) );
}
__END__

The result on my MacBook Pro:

#### Testing for 1 KB Read
Benchmark: running mmap, nolayer, perlio, raw for at least 3 CPU seconds...
           Rate     raw    mmap  perlio nolayer
raw       213/s      --    -95%    -98%    -98%
mmap     4492/s   2007%      --    -55%    -64%
perlio  10088/s   4632%    125%      --    -19%
nolayer 12488/s   5758%    178%     24%      --
#### Testing for 4 KB Read
Benchmark: running mmap, nolayer, perlio, raw for at least 3 CPU seconds...
          Rate     raw    mmap  perlio nolayer
raw     55.7/s      --    -99%    -99%    -99%
mmap    3722/s   6578%      --    -42%    -49%
perlio  6375/s  11338%     71%      --    -13%
nolayer 7305/s  13008%     96%     15%      --
#### Testing for 16 KB Read
Benchmark: running mmap, nolayer, perlio, raw for at least 3 CPU seconds...
          Rate     raw    mmap  perlio nolayer
raw     13.5/s      --    -99%    -99%    -99%
mmap    1849/s  13550%      --    -25%    -30%
perlio  2469/s  18123%     34%      --     -7%
nolayer 2649/s  19455%     43%      7%      --
#### Testing for 64 KB Read
Benchmark: running mmap, nolayer, perlio, raw for at least 3 CPU seconds...
          Rate     raw    mmap  perlio nolayer
raw     3.53/s      --    -99%   -100%   -100%
mmap     693/s  19567%      --    -10%    -14%
perlio   767/s  21651%     11%      --     -5%
nolayer  810/s  22872%     17%      6%      --
#### Testing for 256 KB Read
Benchmark: running mmap, nolayer, perlio, raw for at least 3 CPU seconds...
           Rate     raw  perlio nolayer    mmap
raw     0.937/s      --    -99%   -100%   -100%
perlio    187/s  19804%      --     -4%     -6%
nolayer   194/s  20582%      4%      --     -2%
mmap      198/s  21062%      6%      2%      --
#### Testing for 1024 KB Read
Benchmark: running mmap, nolayer, perlio for at least 3 CPU seconds...
          Rate  perlio nolayer    mmap
perlio  46.8/s      --     -5%    -11%
nolayer 49.2/s      5%      --     -7%
mmap    52.8/s     13%      7%      --
#### Testing for 4096 KB Read
Benchmark: running mmap, nolayer, perlio for at least 3 CPU seconds...
          Rate  perlio nolayer    mmap
perlio  12.4/s      --     -4%     -4%
nolayer 12.9/s      4%      --     -1%
mmap    13.0/s      4%      1%      --
#### Testing for 16384 KB Read
Benchmark: running mmap, nolayer, perlio for at least 3 CPU seconds...
          Rate  perlio nolayer    mmap
perlio  2.96/s      --     -5%     -6%
nolayer 3.11/s      5%      --     -1%
mmap    3.14/s      6%      1%      --
#### Testing for 65536 KB Read
Benchmark: running mmap, nolayer, perlio for at least 3 CPU seconds...
        s/iter  perlio    mmap nolayer
perlio    1.35      --     -8%     -8%
mmap      1.25      8%      --     -0%
nolayer   1.24      9%      0%      --

no layer being the fastest is no surprise for me. It's synonym for :perlio on most platforms and with no option you have no overhead for setting layer. What's so surprising is that :raw being so slow. I got similar result on my FreeBSD boxes.

Dan the Just Another Perl Benchmarker

Tuesday May 02, 2006
07:53 AM

Thing started moving

Sometimes rant is good. Things started moving at last.

Both Encode and Jcode is now officially registered. And MERCEL finally responded.

This time I fell victim but I know only too well I am the one who victimize my fellows by neglecting them. If that happens to you, plese don't hesitate to yell at me.

After all we are all busy and no one can respond to every single message received. And sometimes thoese messages are not received by network errors, spam filters, and such. As a matter of fact my mail server receives 120-150 thousand SMTP connections, mostly from infected PCs. My mail filters (yes, plural) are pretty good but they are not perfect.

Thank you for your patience and thank you too for your impatience. We definitely need both.

Dan the Responded CPAN Author

Monday May 01, 2006
03:44 AM

CPAN Name Squatting

CPAN Authors and Perl Porters,

I recently came across two cases of namespace squatting.

Case: Attribute::Memoize

That was taken by MARCEL but the module is missing. I guess MARCEL deleted Attribute::Memoize in favor of Attribute::Util which has the same functionality. But I don't like the idea of grab-bagging of multiple Attribute handlers in a single module so I mailed him what he wants to do with it. The mail was sent on April 8th and I got no reponse since then.

Case: Crypt::Camellia

That module does Camellia cipher for Crypt::CBC. The algorithm became open source only recently (April 13th) so it is almost impossible that the name space be registered by someone else. But it is registered by JCDUQUE. It is registered as RcdOg but once again the module itself is missing (naturally). Since JCDUQUE has registered Many Crypt:: modules, he did so assuming it will soon be available.

I now have a very strong doubt of module registration system. Do we really need that? And who and how the registration be processed is in the haze. I have requested to register Encode and Jcode before. Encode is even in core but those requests were simply ignored.

http://search.cpan.org/ seems to be taking more practical approach. Just index whatever does REALLY exist. So Attribute::Memoize and Crypt::Camellia belongs to me from its point of view. But once you fire up CPAN shell, it's registration that has te precedence.

I want some action be taken.

Dan the Foresaken by CPAN

Monday April 24, 2006
01:22 PM

Google Summer of Code 2006

To punish me for my contempt of Google, Fate has made me a Summer of Code Mentor myself.

http://blog.livedoor.jp/dankogai/archives/50469306.html

Saturday April 01, 2006
02:32 AM

Bugs Manifesto

For those who are not subscribed to p6l or p5p.

[April 1st, 2006, 00:00 GMT+9]

Larry Wall and Audrey Tang jointly announced that Parrot, Pugs, and all language-related projects be dysintegrated to Bugs. Bugs have ruled this planet for half a billion years and they shall do so for for years to come. Beats heck out of avians, mammals, reptiles or gems.

Their Manifesto is now available at

    http://blog.livedoor.jp/dankogai/mov/lamdaorz.mov

Stay tuned!

Dan the Deranged, Infested, and Undefined, Reporting Live from Triassic

02:23 AM

Inline::PHP

Not only perl hackers but also the rest of hackers seem to make too much fun of PHP. That was so true that in YAPC::Asia even Matz and Larry was making fun of that (well, Larry made fun of every computer languages including perl but PHP part was the most horrendous).

I felt sorry for PHP folks so I came up with this. Ingy's Module::Compile made it so spiffy.

#!/usr/local/bin/perl
use strict;
use warnings;
use Inline::PHP;
<?php echo "Hello, PHP\n" ?>
no Inline::PHP;
print "Hello, rest of the world!\n";

prints

Hello, PHP!
Hello, rest of the world!

And here is the module.

package Inline::PHP;
use 5.008001;
use strict;
use warnings;
our $VERSION = '0.01';
use Module::Compile -base;
sub pmc_compile {
    my ($class, $html) = @_;
    $html =~ s/no\s+$class\s*.*;\n//o;
    open my $php, "|-" or exec 'php' or die $!;
    print {$php} $html;
    close $html;
    return q();
}
1;
__END__

<?php echo "Enjoy!" ?>

Dan the Lambdaorz

Sunday September 04, 2005
10:38 PM

Lambda Calculus on Perl6

[ #26596 ]
(also posted on p6l)
Folks,

I recently needed to write a series of codes on lambda calculus in perl.  As MJD has shown Perl 5 can handle lambda calculus but I am beginning to get tired of whole bunch of 'my $x = shift' needed.

  our $ZERO =
      sub { my $f = shift;
          sub { my $x = shift; $x }};
  our $SUCC =
      sub { my $n = shift;
            sub { my $f = shift;
                  sub { my $x = shift;
                        $f->($n->($f)($x)) }}};
  our $ADD =
      sub{ my $m = shift;
           sub { my $n = shift;
                 sub { my $f = shift;
                       sub { my $x = shift;
                             $m->($f)($n->($f)($x)) }}}};
  our $MULT =
      sub { my $m = shift;
            sub { my $n = shift;
                  sub { my $f = shift;
                        $m->($n->($f)) }}};
  our $POW =
      sub { my $m = shift;
            sub { my $n = shift;
                  $n->($m) }};

And I found that these can be made much, much simpler and more intuitive with Perl 6, even more so than scheme!

  our $ZERO = sub($f){ sub($x){ $x }};
  our $SUCC = sub($n){ sub($f){ sub($x){ $f.($n.($f)($x)) }}};
  our $ADD  = sub($m){ sub($n){ sub($f){ sub($x){ $m.($f)($n.($f)($x)) }}}};
  our $MULT = sub($m){ sub($n){ sub($f){ $m.($n.($f)) }}};
  our $POW  = sub($m){ sub($n){ $n.($m) }};

You can even make it simpler by removing dots but I leave it that way because it looks more like the original notation that way (i.e.  zero := &#955;f.&#955;x.x).

Runs perfectly fine on Pugs 6.2.8.  Add the code below and see it for yourself.

  my $one     = $SUCC.($ZERO);
  my $two     = $SUCC.($one);
  my $four    = $ADD.($two)($two);
  my $eight   = $MULT.($two)($four);
  my $sixteen = $POW.($four)($two);
  for($one, $two, $four, $eight, $sixteen) -> $n {
      $n.(sub($i){ 1 + $i})(0).say
  };

Maybe we can use this for advocacy.

Dan the Perl 6 User Now

P.S.  I am surprised to find Pugs does not include this kind of sample scripts.
Saturday September 03, 2005
12:48 AM

ppencode vs. rrencode

[ #26582 ]

My friend Takesako-san has come up with a wonderful hack called ppencode at LLDN2005.

In response to that, a ruby hacker came up with rrencode which turns a given data into a ruby script that consists entirely of symbols -- no alphabet whatsoever.

Now I wonder if we could do that in perl. But perl does not have ruby's $><< which does print. Even Acme::EyeDrops makes use of eval. The best approximation I came up with was build the string and feed it to s//$_/e but even that contains an 's' and 'e'. Any idea?

Dan the Code Obfuscunator

Monday August 01, 2005
12:09 AM

Homeland Security without Homepage Access

This is my first entry to the U.S. with fingerprints recorded. Visa Waiver no longer waives that intimidating Homeland Securty Act measures.

That much I understood a priori. What I didn't know was....

Officer:
        You are visiting here for....
Dan:
        A conference. OSCON 2005
Officer:
        Your company is...
Dan:
        I'm self-employed.
Officer:
        What kind of conference?
Dan:
        Open Source.
Officer:
        Open Source? What is that?

How many times have you hosted OSCON, Portland?

Officer:
        Do you have any information about the conference with you?
Dan:
        Well, I have mails. Nice computer you've got. Can you check web pages with that?
Officer:
        Unfortunately, no. Don't you have anything in paper?
Dan:
        No. Do you want to check my powerbook?
Officer:
        That's fine. I believe you. But next time you visit bring more materials about the conference.
Dan:
        Yes, sir.

How fortunate I am not a U.S. Citizen. If I were I couldn't stand the system that checks my fingerprint and portrait without being able to check puny web pages.

Dan the Persona Non Grata