Skip to content

Instantly share code, notes, and snippets.

Aristotle Pagaltzis ap

View GitHub Profile
@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
@ap
ap / gitize.pl
Last active Dec 28, 2015
ribasushi’s gitize
View gitize.pl
#!/usr/bin/env perl
use warnings;
use strict;
use Git::Raw ();
use Archive::Peek::Libarchive ();
use Getopt::Std 'getopts';
getopts 'd:', \my %opt;
my $git = Git::Raw::Repository->open( $opt{'d'} // die 'need git directory, specify using -d' );
@ap
ap / 13230445-rejection.pdf
Last active Dec 20, 2015
US 20130063492 A1 — non-final rejection — 4-11-2013
View 13230445-rejection.pdf
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
You can’t perform that action at this time.