Skip to content

Instantly share code, notes, and snippets.

Avatar

Aristotle Pagaltzis ap

View GitHub Profile
@ap
ap / cpan-spam.eml
Created Jan 2, 2021
CPAN phishing spam
View cpan-spam.eml
Return-Path: <SRS0=+pr+=GF=eptriaq.com=friptions@bounce2.pobox.com>
Received: from pb-mx23.pobox.com ([173.228.157.42]) by mx-ha.gmx.net (mxgmx017
[212.227.15.9]) with ESMTPS (Nemesis) id 1MpVEM-1kCdyU35qe-00pwhP for
<pagaltzis@gmx.de>; Sat, 02 Jan 2021 08:17:51 +0100
Received: from pb-mx23.sea.icgroup.com (localhost.local [127.0.0.1])
by pb-mx23.pobox.com (Postfix) with ESMTP id 7FE732E648
for <pagaltzis@gmx.de>; Sat, 2 Jan 2021 02:17:49 -0500 (EST)
(envelope-from SRS0=+pr+=GF=eptriaq.com=friptions@bounce2.pobox.com)
X-Pobox-Loop-ID: 75ef6d1b24aacd20abd1e489568d5a882249faab
Delivered-To: aristotle@cpan.org
@ap
ap / Horrible.pm
Last active Nov 1, 2020
Wantarray::Horrible
View Horrible.pm
package Wantarray::Horrible;
sub new {
my ( $class, $wantarray, $sub ) = ( shift, shift, shift );
; $wantarray ? bless [ &$sub ], __PACKAGE__.'::List'
: defined $wantarray ? bless \( scalar &$sub ), __PACKAGE__.'::Sclr'
: bless \do { &$sub; my $o }, __PACKAGE__.'::Void';
}
sub Wantarray::Horrible::List::value { @{ $_[0] } }
sub Wantarray::Horrible::Sclr::value { ${ $_[0] } }
sub Wantarray::Horrible::Void::value { () }
@ap
ap / foo.pl
Last active May 11, 2017 — forked from anonymous/foo.pl
View foo.pl
use v5.10;
use re 'eval';
my @a = (
[ 'aaa', sub { say 'Apple' } ],
[ 'bbb', sub { say 'Banana' } ],
[ 'ccc', sub { say 'Carrot' } ],
);
my @r = map {
@ap
ap / toggle-finder-desktop.sh
Last active Apr 29, 2016
Toggle MacOS Finder desktop icons on/off
View toggle-finder-desktop.sh
#!/bin/sh
( defaults read com.apple.finder CreateDesktop 2>/dev/null || echo 1 ) | egrep -qxi '1|true|yes|on'
defaults write com.apple.finder CreateDesktop $? && killall Finder
@ap
ap / scan-perl-prereqs-cpanfile
Created Dec 28, 2015
Shoddy dzil-free cpanfile generator cloned from the Dist::Zilla::Plugin::AutoPrereqs logic
View scan-perl-prereqs-cpanfile
#!/usr/bin/env perl
use strict;
use warnings;
use lib ();
use File::Find;
use List::Util qw{ max };
use Perl::PrereqScanner;
View jpegtran-v9a.drop.patch
diff -urd --unidirectional-new-file orig/jpegtran.c droppatch/jpegtran.c
--- orig/jpegtran.c 2015-12-27 12:11:58.000000000 +0000
+++ droppatch/jpegtran.c 2014-03-26 11:52:18.000000000 +0000
@@ -37,6 +37,7 @@
static const char * progname; /* program name for error messages */
static char * outfilename; /* for -outfile switch */
+static char * dropfilename; /* for -drop switch */
static char * scaleoption; /* -scale switch */
static JCOPY_OPTION copyoption; /* -copy switch */
@ap
ap / faster-header-utils-bench.pl
Last active Aug 29, 2015
Pull request benchmarks for Plack#495
View faster-header-utils-bench.pl
#!/usr/bin/env perl
use 5.012;
use warnings;
use Benchmark 'cmpthese';
use lib 'lib';
use Plack::Util ();
BEGIN { *header_iter = \&Plack::Util::header_iter }
@ap
ap / DynamicURLMap.pm
Created Jan 23, 2015
Plack::App::DynamicURLMap
View DynamicURLMap.pm
use strict;
use warnings;
package Plack::App::DynamicURLMap;
use parent 'Plack::App::URLMap';
use Carp ();
use Scalar::Util ();
sub unmount { shift->unmap( @_ ) }
@ap
ap / spindown.sh
Created Apr 20, 2014
Spin down unused ATA disks on Linux
View spindown.sh
#!/bin/sh
echo -n 'Spinning down unused ATA drives:'
/usr/bin/lsscsi | /bin/grep -w -F ATA | /bin/cut -c54- \
| while read dev ; do
if /bin/mount | /bin/grep -q -E "^$dev[^/]* " ; then continue ; fi
echo -n " $dev,"
/sbin/hdparm -q -Y "$dev"
done
echo ' done.'
@ap
ap / Smart Maximize.applescript
Last active Dec 29, 2015
Takes the frontmost window, maximises it vertically, and centres it horizontally if it was off-screen
View Smart Maximize.applescript
tell application "Finder"
set {dx1, dy1, dx2, dy2} to bounds of window of desktop
end tell
set cur_app to (path to frontmost application as Unicode text)
tell application cur_app
set {x1, y1, x2, y2} to bounds of front window
if x1 < dx1 or x2 > dx2 then
set displayWidth to dx2 - dx1