Skip to content

Instantly share code, notes, and snippets.

@dctabuyz
dctabuyz / extra.pl
Last active November 12, 2019 22:25
extra number
use strict;
use warnings;
use Data::Dumper;
use List::Util qw(shuffle);
my $max = int rand(18) + 2;
my @array = shuffle 1 .. $max;
push @array, $array[int rand $max];
@dctabuyz
dctabuyz / bench.pl
Last active January 10, 2019 18:08 — forked from cynovg/bench.pl
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use v5.26.0;
use List::Util qw/first any/;
use Benchmark qw(:all);
#!/usr/bin/env perl
use strict;
use warnings;
use Module::Load 'load';
use Module::Load::Conditional 'can_load';
die 'Image::ExifTool not installed' unless can_load('modules' => {'Image::ExifTool' => 0});
@dctabuyz
dctabuyz / pre-receive-hook-protect-windows.sh
Last active January 19, 2018 14:52
pre-receive hook: protect windows git users
#!/bin/sh
# https://msdn.microsoft.com/ru-ru/library/windows/desktop/aa365247(v=vs.85).aspx
# the following reserved characters:
# < (less than)
# > (greater than)
# : (colon)
# " (double quote)
# / (forward slash)
@dctabuyz
dctabuyz / pagenum.pl
Last active December 13, 2017 15:44
prints comma separated page numbers
use strict;
use warnings;
use Getopt::Long;
use Pod::Usage qw(pod2usage);
use vars qw($from $to $odd $even $rev $two_sided $spread);
GetOptions(
@dctabuyz
dctabuyz / bust-static-cache-on-git-checkout.md
Last active February 22, 2017 16:28
bust static cache on git checkout: insert git revision id (HEAD) into a link
  • add filter
$ git config filter.nocache.smudge "perl -pe 'BEGIN {\$h = \`git log --pretty=format:\"%H\" -1\`; } s{\\?[A-z0-9]*#cache-bust}{?\$h#cache-bust}g'"
$ git config filter.nocache.clean "perl -pe 's{\\?[A-z0-9]*#cache-bust}{?nocache#cache-bust}g'"
  • edit .gitattributes
*.html filter=nocache
@dctabuyz
dctabuyz / empty.gif.pl
Created February 18, 2016 10:57
empty gif, 35 bytes
use constant EMPTY_GIF => "\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\xFF\x00\xFF\xFF\xFF" .
"\x00\x00\x00\x2C\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x44" .
"\x01\x00\x3B";
#!/bin/sh
### BEGIN INIT INFO
# Provides: mongodb-mms-monitoring-agent
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: MongoDB MMS Monitoring Agent
# Description: MongoDB MMS Monitoring Agent
### END INIT INFO