Skip to content

Instantly share code, notes, and snippets.

@leedo
leedo / gist:2127708
Created March 19, 2012 22:30
truncate-html.pl
#!/usr/bin/env perl
use strict;
use warnings;
use HTML::Parser;
my $len = 0;
my $max = 85;
my @close = ();
my $orig = \&Noembed::Util::http_get;
local *Noembed::Util::http_get = sub {
my $cb = pop;
my $url = shift;
my $hash = sha1_hex $url;
$orig->($url, @_, sub {
my ($body, $headers) = @_;
open my $fh, ">", "t/data/requests/$hash";
import shield;
vcl_recv {
if (shield) {
shield.conn_reset();
}
else {
error 403 "Forbidden";
}
}
var noembed = {
patterns : [],
callbacks : {},
callback_counter: 0,
setup : function(selector) {
if (!selector) selector = "a[href]";
var elems = document.querySelectorAll(selector);
if (elems.length) {
noembed.get_patterns(function() {
def test_weird_formats
tif = Asset::Image.new(@odd_formats[:tif][:input], "rmagick")
assert_equal "jpg", tif.format
assert_equal "rmagick.jpg", tif.filename
bmp = Asset::Image.new(@odd_formats[:bmp][:input], "rmagick");
assert_equal "png", bmp.format
assert_equal "rmagick.png", bmp.filename
end
aseed:alice leedo$ perl -Ilib ./bin/multialice.pl
spawning some alice instances
2011-12-28 11:11:53.779200 -0500 info Alice::Standalone: Location: http://127.0.0.1:9000/
2011-12-28 11:11:53.789192 -0500 info Alice::Standalone: Location: http://127.0.0.1:9001/
2011-12-28 11:11:53.813952 -0500 info Alice::Standalone: Location: http://127.0.0.1:9003/
use v5.14;
use overload;
sub BEGIN {
overload::constant integer => sub {(shift) * rand};
}
say 4;
diff --git a/lib/AnyEvent/IRC/Client.pm b/lib/AnyEvent/IRC/Client.pm
index 4992398..2b2cd98 100644
--- a/lib/AnyEvent/IRC/Client.pm
+++ b/lib/AnyEvent/IRC/Client.pm
@@ -452,7 +452,9 @@ All keys, except C<nick> are optional.
sub connect {
my ($self, $host, $port, $info) = @_;
- if (defined $info) {
+ my $timeout = delete $info->{timeout};
[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\
xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xf
f\n\015()]*)*\)[\040\t]*)*(?:(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\x
ff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n\015
"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[\040\t]*(?:\([^\\\x80-\
xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80
-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*
)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\
\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\
x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x8
#!/usr/bin/perl
use File::Next;
use File::Copy;
use File::Path qw/mkpath/;
my ($source, $dest) = @ARGV;
die "need source and dest" unless -e $source and -e $dest;
my $iter = File::Next::files({ file_filter => sub {/\.(?:png|jpe?g|gif)/i} }, $source);