Skip to content

Instantly share code, notes, and snippets.

@earino
earino / gist:3630393
Created September 5, 2012 04:22
simple with slurp
#!/usr/bin/env perl
use warnings;
use strict;
use FindBin;
use File::Slurp;
use XML::Simple;
use Time::HiRes;
@earino
earino / gist:3630374
Created September 5, 2012 04:21
simple XML input
#!/usr/bin/env perl
use warnings;
use strict;
use FindBin;
use File::Slurp;
use XML::Simple;
use Time::HiRes;
@earino
earino / gist:3630337
Created September 5, 2012 04:17
dumper of xml
$VAR1 = {
'people' => {
'person' => {
'homepage' => 'http://www.labs.com/~Tempesti',
'creditcard' => '5048 5813 2703 8253',
'name' => 'Jaak Tempesti',
'id' => 'person0',
'watches' => {
'watch' => {
'open_auction' => 'open_auction0'
@earino
earino / gist:3630278
Created September 5, 2012 04:13
sample_xml
<?xml version="1.0" standalone="yes"?>
<site>
<regions>
<africa>
<item id="item0">
<location>United States</location>
<quantity>1</quantity>
<name>duteous nine eighteen </name>
<payment>Creditcard</payment>
<description>
@earino
earino / gist:3184000
Created July 26, 2012 19:26
Using caching
my $pm = Parallel::ForkManager->new($PROCESSES);
my @list_of_work = qw/ BLAH BLAH BLAH /;
my @list_of_endpoints = qw/ YADDA YADDA YADDA /;
my $cache = CHI->new(
driver => 'FastMmap',
root_dir => $SOME_DIRECTORY,
cache_size => $SIZE,
);
@earino
earino / gist:3183938
Created July 26, 2012 19:19
what your code really looked like
my $pm = Parallel::ForkManager->new($PROCESSES);
my @list_of_work = qw/ BLAH BLAH BLAH /;
my @list_of_endpoints = qw/ YADDA YADDA YADDA /;
for my $unit_of_work (@list_of_work) {
my $pid = $pm->start and next;
for my $endpoint (@list_of_endpoints) {
my $value_retrieved = retrieve_value_from_stuff($unit_of_work, $endpoint);
@earino
earino / gist:3183917
Created July 26, 2012 19:16
Get the value at the top
my $pm = Parallel::ForkManager->new($PROCESSES);
my @list_of_work = qw/ BLAH BLAH BLAH /;
my @list_of_endpoints = qw/ YADDA YADDA YADDA /;
for my $unit_of_work (@list_of_work) {
my $value_retrieved = retrieve_value_from_stuff($unit_of_work);
my $pid = $pm->start and next;
for my $endpoint (@list_of_endpoints) {
@earino
earino / gist:3183895
Created July 26, 2012 19:12
parallelized first stab
my $pm = Parallel::ForkManager->new($PROCESSES);
my @list_of_work = qw/ BLAH BLAH BLAH /;
my @list_of_endpoints = qw/ YADDA YADDA YADDA /;
for my $unit_of_work (@list_of_work) {
my $pid = $pm->start and next;
for my $endpoint (@list_of_endpoints) {
my $value_retrieved = retrieve_value_from_stuff($unit_of_work);
@earino
earino / gist:3183845
Created July 26, 2012 19:06
high level example
my @list_of_work = qw/ BLAH BLAH BLAH /;
my @list_of_endpoints = qw/ YADDA YADDA YADDA /;
for my $unit_of_work (@list_of_work) {
for my $endpoint (@list_of_endpoints) {
my $value_retrieved = retrieve_value_from_stuff($unit_of_work);
do_stuff_to($value_retrieved);
push_value_retrieved_to($endpoint);
}
}
@earino
earino / gist:3068294
Created July 7, 2012 22:13
Output from dancer printing a dump of request
<~/play/bad_upload_handler> $ perl bin/app.pl
[54114] core @0.000011> loading Dancer::Handler::Standalone handler in /Users/earino/perl5/lib/perl5/Dancer/Handler.pm l. 45
[54114] core @0.000185> loading handler 'Dancer::Handler::Standalone' in /Users/earino/perl5/lib/perl5/Dancer.pm l. 464
>> Dancer 1.3095 server 54114 listening on http://0.0.0.0:3000
== Entering the development dance floor ...
[54114] core @0.000133> request: POST / from 127.0.0.1 in /Users/earino/perl5/lib/perl5/Dancer/Handler.pm l. 56
[54114] core @0.000527> [hit #1]Trying to match 'POST /' against /^\/$/ (generated from '/') in /Users/earino/perl5/lib/perl5/Dancer/Route.pm l. 84
[54114] core @0.000678> [hit #1] --> got 1 in /Users/earino/perl5/lib/perl5/Dancer/Route.pm l. 102
[54114] debug @0.001524> [hit #1]request: $VAR1 = bless( {'_body_params' => {'born' => '1978','email' => '[email protected]','filename' => 'file.jpeg','gender' => 'M','name' => 'Eduardo Arino'},'_chunk_size' => 4096,'_http_body' => bless( {'body' => undef,'boun