Skip to content

Instantly share code, notes, and snippets.

@jrockway
jrockway / server.pl
Created April 3, 2009 11:22
stress test concurrent connections
#!/usr/bin/env perl
use strict;
use warnings;
use feature ':5.10';
use POE;
use HTTP::Engine;
my $body = "0"x1_000_000;
@jrockway
jrockway / evil.html
Created April 5, 2009 05:50
can a parent page remove "langauge features" from iframes?
<html>
<head>
<title>Test page</title>
</head>
<body>
<h1>Test page</h1>
Hello, world.
<script language="javascript">
document.write("Before: " + top);
top = null;
# Carp::Heavy uses some variables in common with Carp.
package Carp;
=head1 NAME
Carp::Heavy - heavy machinery, no user serviceable parts inside
=cut
# On one line so MakeMaker will see it.
@jrockway
jrockway / event.pl
Created June 9, 2009 13:40
event vs. non-event approach for writing to a child
#!/usr/bin/env perl
use strict;
use warnings;
use feature ':5.10';
use AnyEvent;
use AnyEvent::Handle;
open my $fd, '|-', 'perl -ne "sleep 1; print"' or die $!;
#!/usr/bin/env perl
use strict;
use warnings;
use feature ':5.10';
open my $fh, '>', 'test.txt' or die $!;
my $reopen = sub() {
open $_[0], $_[1]. '&='. fileno($_[2]) or die "failed to reopen: $!";
perl -MEncode=encode -e 'my $str = "\x{eeffff}"; my $enc = encode("utf-16be", $str); print join q{,}, length $str, do { use bytes; length $enc }'
my $hash = { keys => 'go here',
and => 'here',
};
my $hash = {
keys => 'go here',
and => 'here',
blocks => sub {
'nest like this';
},
};
[~] 0 (jon@bar)
$ perl slave.pl
Got 'f'
Got 'o'
Got 'o'
Got ''
Got ''
Got ''
Got 'b'
Got 'z'