Goodbye Zefram
in Meditations
2 direct replies — Read more / Contribute
|
by Anonymous Monk
on Mar 12, 2025 at 04:58
|
|
In perl.perl5.porters, Philippe Bruhat wrote:
I'm very sorry to be the bearer of sad news, which I just learned
from a co-worker who was in regularl contact with Zefram.
He forwarded me this:
We are sad to announce that Zefram (Andrew Main) died yesterday
(2025-03-10) after being hit by a train. Further details are not yet
available. Everyone close to him is very shocked by this and contact
details and further arrangements will be announced in future. He was a long-time and prolific contributor to Perl core and CPAN,
and he will be missed.
I will forward further details (memorial or place to send condolences)
as I receive them.
Christian Walde then followed up with:
Thanks for bearing the news BooK, even if it is sad news.
As an additional bit of info, his personal website's section on this
matter is relevant: https://www.fysh.org/~zefram/personal/death
|
Imager support for PNG, JPEG and GIF on macOS Sonoma
in Meditations
1 direct reply — Read more / Contribute
|
by Anonymous Monk
on Apr 20, 2024 at 22:51
|
|
Installing our beloved Imager on macOS Sonoma with support for PNG, JPEG and GIF involves some pain. Here are the results of my struggle so others won't have to. Do this after installing Imager (requires Homebrew):
brew install pkg-config
brew install libpng
pkg-config --cflags libpng
cpan Imager::File::PNG
brew install jpeg
pkg-config --cflags libjpeg
cpan Imager::File::JPEG
brew install giflib
cpan Imager::File::GIF
GIF: Test code failed: Can't link/include 'gif_lib.h', 'stdio.h', 'errno.h', 'string.h', 'gif'...
! Configure failed for Imager-File-GIF-0.98. See /Users/you/.cpanm/work/1713652269.80239/build.log for details.
cd /Users/you/.cpanm/work/1713652269.80239/Imager-File-GIF-0.98
perl Makefile.PL -v --incpath=/opt/homebrew/include --libpath=/opt/homebrew/var/homebrew/linked/giflib/lib
make
make test
make install
For some reason the following didn't work with the cpan client:
o conf makepl_arg "LIBS=-L/opt/homebrew/var/homebrew/linked/giflib/lib INC=-I/opt/homebrew/include"
PS - pkg-config can't find giflib so the paths were found like this:
sudo /usr/libexec/locate.updatedb
locate giflib
/opt/homebrew/var/homebrew/linked/giflib
locate gif_lib.h
/opt/homebrew/Cellar/giflib/5.2.1/include/gif_lib.h
/opt/homebrew/include/gif_lib.h
|
CPAN autobundle fail
in Meditations
2 direct replies — Read more / Contribute
|
by Anonymous Monk
on Apr 10, 2024 at 13:50
|
|
I was trying to autobundle an old perl setup but
cpan was just sitting there failing to contact mirrors (cpanm user so that mirror list was probably ancient). This inspired me to visit https://www.cpan.org/SITES.html
where it says www.cpan.org don't do mirrors anymore. Created the autobundle like so:
cpan -M https://www.cpan.org -a
|
Fast sliding submatrix sums with PDL (inspired by PWC 248 task 2)
in Meditations
5 direct replies — Read more / Contribute
|
by Anonymous Monk
on Dec 25, 2023 at 19:51
|
|
Task 2: Submatrix Sum
Submitted by: Jorg Sommrey
You are given a NxM matrix A of integers.
Write a script to construct a (N-1)x(M-1) matrix B
having elements that are the sum over the 2x2 submatrices of A,
b[i,k] = a[i,k] + a[i,k+1] + a[i+1,k] + a[i+1,k+1]
Example 1
Input: $a = [
[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12]
]
Output: $b = [
[14, 18, 22],
[30, 34, 38]
]
I tried to crank it up for entertainment -- to solve not "2x2", but arbitrary "WxH" sub-matrices of (relatively) large matrices. Sadly, it was too late into many stupid plots and tables, when I realized, that excessive summation isn't required at all. Sliding (moving) sum (or average, min/max, etc.) is a well known concept -- duh! not to un-educated me, alas. And so maybe "2x2", not "WxH", in the task, was selected not only because PWC tries to accommodate new learners. Anyway, I implemented "sliding submatrix sums" algorithm only at a later stage, in PDL, and didn't "backport" it to pure Perl (nor Pdlpp) because had already been somewhat fed-up with this 248-2, but decided to present sanitized results as a meditation.
|
PWC 244 task 2 in linear time
in Meditations
3 direct replies — Read more / Contribute
|
by Anonymous Monk
on Nov 27, 2023 at 13:22
|
|
Disclaimer: it's clickbait. The plot is curved, solution isn't linear, despite lack of nested loops, -- but fast.
Task 2: Group Hero
Submitted by: Mohammad S Anwar
You are given an array of integers representing the strength.
Write a script to return the sum of the powers of all possible
combinations; power is defined as the square of the largest number
in a sequence, multiplied by the smallest.
Example 1
Input: @nums = (2, 1, 4)
Output: 141
Group 1: (2) => square(max(2)) * min(2) => 4 * 2 => 8
Group 2: (1) => square(max(1)) * min(1) => 1 * 1 => 1
Group 3: (4) => square(max(4)) * min(4) => 16 * 4 => 64
Group 4: (2,1) => square(max(2,1)) * min(2,1) => 4 * 1 => 4
Group 5: (2,4) => square(max(2,4)) * min(2,4) => 16 * 2 => 32
Group 6: (1,4) => square(max(1,4)) * min(1,4) => 16 * 1 => 16
Group 7: (2,1,4) => square(max(2,1,4)) * min(2,1,4) => 16 * 1 => 16
Sum: 8 + 1 + 64 + 4 + 32 + 16 + 16 => 141
|
TPF PERL Swag
in Meditations
1 direct reply — Read more / Contribute
|
by Anonymous Monk
on Jan 09, 2023 at 02:42
|
|
I want some swag from The Perl Foundation but the graphics...
1. They spelled it: PERL
2. Raptors are extinct.
3. Raw onions? C'mon!
I want cool cryptic, like Perl itself:
$Perl->{5.36}
Front | Back
#!/usr/bin/perl | exit;
|
BEGIN{} | END{}
|
<DATA> | __DATA__
|
use Perl; | $?
|
$@% | ...
|
$_ | @_
| |
Obviously: camel code
|
Perl::Dist::APPerl - Actually Portable Perl
in Perl News
4 direct replies — Read more / Contribute
|
by Anonymous Monk
on Jan 06, 2023 at 07:34
|
|
"Actually Portable Perl (APPerl) is a distribution of Perl that runs on several x86_64 operating systems (most Unix-like and Windows) via the same binary. It builds to a single binary with perl modules packed inside of it. Cross-platform, single binary, standalone Perl applications can be made by building custom versions of APPerl, with and without compiling Perl from scratch"
- Perl::Dist::APPerl
- computoid.com/APPerl/
|
Double the speed of Imager->setpixel
in Meditations
4 direct replies — Read more / Contribute
|
by Anonymous Monk
on Dec 11, 2022 at 16:49
|
|
My app was taking 5 seconds to generate an image involving about a million calls to Imager->setpixel and this felt way too slow. NYTProf revealed the cause to be expensive sanity checking in Imager.pm at lines 3456 and 3465. Commenting those lines gets me down to 3 seconds and this now feels much less slow:
sub setpixel {
my ($self, %opts) = @_;
# $self->_valid_image("setpixel") or return;
my $color = $opts{color};
unless (defined $color) {
$color = $self->{fg};
defined $color or $color = NC(255, 255, 255);
}
# unless (ref $color && UNIVERSAL::isa($color, "Imager::Color")) {
# unless ($color = _color($color, 'setpixel')) {
# $self->_set_error("setpixel: " . Imager->errstr);
# return;
# }
# }
unless (exists $opts{'x'} && exists $opts{'y'}) {
$self->_set_error('setpixel: missing x or y parameter');
return;
}
...
}
sub _valid_image {
my ($self, $method) = @_;
ref $self
or return Imager->_set_error("$method needs an image object");
$self->{IMG} && Scalar::Util::blessed($self->{IMG}) and return 1;
my $msg = $self->{IMG} ? "images do not cross threads" : "empty inpu
+t image";
$msg = "$method: $msg" if $method;
$self->_set_error($msg);
return;
}
Should the next version of Imager have an option to disable global sanity so it can operate almost twice the usual speed?
|
The new black metacpan (meta::cpan throws away brand)
in Meditations
1 direct reply — Read more / Contribute
|
by Anonymous Monk
on Sep 30, 2022 at 06:15
|
|
|
the distribution is barmy
in Meditations
1 direct reply — Read more / Contribute
|
by Anonymous Monk
on May 21, 2021 at 09:36
|
|
put back the commented away 63 71 and 75 and it looks as we expect(?) - a file of random numbers from the physics wizards is referenced too - put in 27 remove 28
use strict;
use warnings;
use List::Util qw(max sample);
#use lib '/usr/local/share/perl/5.30.0';
#use Statistics::Basic::Stddev; #installs somewhere??
#use Statistics::Basic::StdDev;
use Statistics::Basic qw(:all);
use File::Slurp; #for large list of real randoms
my @rands = read_file('../stats/bytes37Mb.txt');
my ($fertilewomen) = @ARGV;
my @maxxes;
my $cyclelength = 32;
#my $duration = int(rand(1) + 0.5) == 1 ? 4 : 5;
#my $duration = sample 1, (4, 5);
$fertilewomen ||= 48;
#print "duration is $duration\n";
#my @women;
#for (1..100) {
my @women;
# for (1..48) {
for (1..$fertilewomen) {
# my $start = int(rand(31) + 0.5);
# my $start = int(rand($cyclelength-1) + 0.5);
# my $start = int(rand($cyclelength));
my $start = getrandom($_);
# print "$start\n";
# my $range;
# my $turnover = $cyclelength - $duration;
# if ($start > 28) {
# if ($start > $turnover) {
# if ($start == 29) {
# if ($start == $turnover+1) {
# $range = [$start, $start+1, $start+2, 0];
# } elsif ($start == 30) {
# } elsif ($start == $turnover+2) {
# $range = [$start, $start+1, 0, 1];
# } else {
# $range = [$start, 0, 1, 2];
# }
# } else {
# $range = [$start..$start+3];
# }
# push @women, $range;
# my $duration = sample 1, (4, 5);
my $duration = 4;
push @women, $start..($start+$duration-1);
}
my %count;
my %mcount;
for my $woman (@women) {
# my @range = @{$woman};
# for (@range) {
# my $moduluscyclelength = $_ % $cyclelength;
my $moduluscyclelength = ($woman % $cyclelength);
#print $moduluscyclelength, ' ', $woman, ' ', $cyclelength, "\n";
# $count{$_}++;
$mcount{$moduluscyclelength}++;
# $count{$woman}++;
# }
}
my %occupancy;
# for (0..31) {
for (0..$cyclelength-1) {
# my $value = exists $count{$_} ? $count{$_} : 0;
my $mvalue = exists $mcount{$_} ? $mcount{$_} : 0;
# $occupancy{$_} = $value;
print "$_ $mvalue\n";
# print "$_ $value $mvalue\n";
}
# print 'mean is ', mean(values %count), "\n";
# print 'sd is ', stddev(values %count), "\n";
# my %ostats;
# for (values %occupancy) {
# $ostats{$_}++;
# }
# for (sort { $a <=> $b } keys %ostats) {
## print $_, ' ', $ostats{$_}, "\n";
# }
# push @maxxes, max(keys %ostats);
#}
#print join ' ', sort { $a <=> $b } @maxxes;
sub getrandom {
my $index = shift;
my $byte = $rands[$index];
chomp $byte;
return int($byte/8);
}
|
|