Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/perl
use strict;
use warnings;
use HTTP::Response;
my $response = HTTP::Response->new(
200, 'OK', [ 'Content-Type' => 'multipart/form-data' ]
);
@chansen
chansen / json.pl
Created February 3, 2011 21:55
PP json parser
#!/usr/bin/perl
use strict;
use warnings;
use Carp qw[];
my $WS = '[\x20\x09\x0A\x0D]*';
sub err {
@chansen
chansen / NoticeableChanges.md
Created May 7, 2018 13:52
Noticeable changes in Property Aliases and Property Value Aliases

Noticeable changes in Property Aliases and Property Value Aliases

PropertyAliases.txt

3.2:
 + NBrk;Non_Break
 + WSpace;White_Space
 + scc;Special_Case_Condition
 + sfc;Simple_Case_Folding

4.0:

@chansen
chansen / extract.pl
Created October 26, 2013 00:47
Extracts name and filename values from Content-Disposition header in multipart/form-data
#!/usr/bin/perl
use strict;
use warnings;
# <https://bugzilla.mozilla.org/show_bug.cgi?id=136676>
# <https://bugs.webkit.org/show_bug.cgi?id=62107>
# <https://www.w3.org/Bugs/Public/show_bug.cgi?id=16909>
# extracts name and filename values from Content-Disposition header.
# returns the escaped value, due to different behaviour across browsers. (see below)
@chansen
chansen / eigen.pl
Created September 6, 2013 12:30
Transparent singleton methods in Perl
#!/usr/bin/perl
use strict;
use warnings;
# Transparent singleton methods in Perl
# First a new anonymous class is created to hold the object's singleton
# methods, this anonymous class assumes the role of the object's class
# and the original class is designated as the super class of that anonymous
# class. This is completely transparent and the anonymous class can't be
# referenced by name.
package unicode;
use strict;
use warnings;
use warnings::register;
use Carp qw[croak cluck];
use Encode qw[];
# from perl.h verified in 5.6.2, 5.8.9, 5.10.1 and blead (2010-02-27)
sub HINT_BLOCK_SCOPE () { 0x00000100 }
@chansen
chansen / results.txt
Created November 16, 2015 19:47
Faster UTF-X validation (~ 50% - 300% faster)
perl: 5.022000 (darwin 14.5.0)
ar.txt: code points: 14308 (U+0000..U+007F: 2698 U+0080..U+07FF: 11610)
Rate core this
core 26873/s -- -33%
this 39928/s 49% --
el.txt: code points: 58748 (U+0000..U+007F: 13560 U+0080..U+07FF: 45150 U+0800..U+FFFF: 38)
Rate core this
@chansen
chansen / id_rsa.pub
Created October 15, 2015 16:32
id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAvkbSjboxgPOsq6rbKxww8taPipuM17Fj9xURQjIkEiunb+6mBumR+ct1d//O5Va6/t/srAg14KeQWEY6Ody+EC8DVI02TtX4buBc1rAL7BCRarLrTJCNYpJ9VLhu+h/u2x/3SgdMfHsBKbs65jqDIsSooXjyuJz3GDWrMDculQqwCiGGhkNPkzjdB1cXIOt8PEMRYV8/A/yqZtfIgd9lumT069m3xc1uKSScSpTSI4BeLMRTfydh5JlLATrBEPqHT/Iudb8xy37YdO0v0Et03eL5j8BID7RAZlnNq6ECV22doqBZ2UrfYnaqY/HeiekqaY52vNnATZ0pXlRItKvkuw== chansen@cpan.org
@chansen
chansen / perlio-scalar-eof.patch
Created March 25, 2012 23:36
PerlIO::scalar patch
diff --git a/ext/PerlIO-scalar/scalar.xs b/ext/PerlIO-scalar/scalar.xs
index eac682b..d324bdd 100644
--- a/ext/PerlIO-scalar/scalar.xs
+++ b/ext/PerlIO-scalar/scalar.xs
@@ -125,6 +125,18 @@ PerlIOScalar_tell(pTHX_ PerlIO * f)
return s->posn;
}
+IV
+PerlIOScalar_eof(pTHX_ PerlIO * f)
@chansen
chansen / test.pl
Created February 16, 2012 23:58
US § 6103. HOLIDAYS (Federal)
#!/usr/bin/perl
use strict;
use warnings;
do 'us_federal_holidays.pl';
# Test cases extracted from <http://www.opm.gov/Operating_Status_Schedules/fedhol/Index.asp>
my @tests = (
[ 1997, '1997-01-01', '1997-01-20', '1997-02-17', '1997-05-26', '1997-07-04',
'1997-09-01', '1997-10-13', '1997-11-11', '1997-11-27', '1997-12-25' ],