Skip to content

Instantly share code, notes, and snippets.

View dolmen's full-sized avatar
😁
Happy!

Olivier Mengué dolmen

😁
Happy!
View GitHub Profile
@dolmen
dolmen / AA.pm
Created February 14, 2014 11:26
Exemple de méthode vraiment privée en Perl.
use strict;
use warnings;
no warnings 'experimental';
use feature 'lexical_subs'; # my sub, experimental in perl 5.18
use feature 'say';
use utf8;
package AA;
sub new
@dolmen
dolmen / post-checkout.pl
Created April 8, 2014 10:32
My git post-checkout hook
#!/usr/bin/perl
# mkdir -p ~/.gittemplate/hooks
# git config --global init.templatedir ~/.gittemplate
#
# Save this script as ~/.gittemplate/hooks/post-checkout
use 5.010;
use strict;
use warnings;
@dolmen
dolmen / corelist-filter.pl
Last active August 29, 2015 14:03
A filter for a list of Perl 5 modules, that will remove pure core modules such as 'integer'
#!perl
use 5.010;
use strict;
use warnings;
use Module::CoreList 2.99;
use Getopt::Long;
my $verbose; # --verbose
@dolmen
dolmen / core-only-list.pl
Last active August 29, 2015 14:03
List of core-only modules
#!perl
# List of core-only modules: modules that are bundled with perl, and not on CPAN
# Unfortunately this list includes modules that are distributed on CPAN but have
# been hidden from PAUSE indexing.
# Example: Locale::Codes::Country_Codes
use 5.010;
use strict;
use warnings;
@dolmen
dolmen / dzil-toolchain-upgrade.sh
Last active August 29, 2015 14:05
Dist::Zilla toolchain upgrade
# Just once
test -f ~/bin/traceuse-modules.sed || echo 's/^ *[1-9][0-9]*\. *\([A-Za-z][^ ,/]*\) .*$/\1/p' > ~/bin/traceuse-modules.sed
# Use Devel::TraceUse to find modules used in the Dist::Zilla build
perl -d:TraceUse=output:x.txt -S dzil listdeps > /dev/null
# Extract modules list from Devel::TraceUse output and upgrade them
sed -n -f ~/bin/traceuse-modules.sed x.txt | sort | xargs cpan
@dolmen
dolmen / codingame-onboarding-start.pl
Created September 3, 2014 13:50
Basic code for the Codingame tuto
use strict; use warnings; use 5.014;
select(STDOUT); $| = 1; # DO NOT REMOVE
# The code below will read all the game information for you.
# On each game turn, information will be available on the standard input, you will be sent:
# -> the total number of visible enemies
# -> for each enemy, its name and distance from you
# The system will wait for you to write an enemy name on the standard output.
# Once you have designated a target:
# -> the cannon will shoot
@dolmen
dolmen / alien-SVN-Debian.pl
Last active August 29, 2015 14:13
An installer that will link the system SVN::* modules to the current perl dirs
#!/usr/bin/env perl
# System perl on Debian is threaded.
# Here is how to try to build a compatible one with plenv:
# plenv install 5.20.1 --as=5.20.1-thr -Dusethread
use Config;
use File::Path 'make_path';
my $errors = 0;
@dolmen
dolmen / Point10.java
Last active August 29, 2015 14:13
An immutable Point class to limits bounds to [-10, 10]
// A point class must be immutable
class Point
{
public final double x;
public final double y;
public Point(double x, double y)
{
this.x = x;
@dolmen
dolmen / Test-Builder-compatibility-break.pl
Last active August 29, 2015 14:13
Test::Builder compatibility breakage
use strict;
use warnings;
use Test::More tests => 1;
use B;
my $x = \(my $y);
# In newer TB, the reference to note's argument is kept and breaks the following test
note $x;
is(B::svref_2object($x)->REFCNT, 2, "refcnt=2");
@dolmen
dolmen / cpanm-dynamic-patch.pl
Last active August 29, 2015 14:14 — forked from kentfredric/winrar.pl
Monkey patching a fatpacked script (cpanm)
#!/usr/bin/env perl
# Dynamically patch cpanm
# Alternative implementation to:
# https://gist.github.com/kentfredric/ce1df3e7e509e071b63d
use strict;
use 5.010001;
use warnings;
use Scalar::Util qw(blessed);