Skip to content

Instantly share code, notes, and snippets.

View mfontani's full-sized avatar

Marco Fontani mfontani

View GitHub Profile
@mfontani
mfontani / git-changefile
Created November 9, 2011 11:22
Which branches "change" this file, compared to the current branch?
#!/usr/bin/perl
use strict;
use warnings;
use File::Basename qw<basename>;
my $file = shift
or die basename($0), ": need a file\n";
my @branches = map {
chomp;substr($_,2)
@mfontani
mfontani / extract-subs.pl
Created December 29, 2011 12:23
Grab subroutines (and variable parameters!) from a Perl file
#!/usr/bin/env perl
use common::sense;
use PPI;
my $file = shift;
die "Need a file to operate on\n"
if !$file
|| !-f $file;
my $doc = PPI::Document->new($file);
@mfontani
mfontani / gist:4195954
Created December 3, 2012 16:03
Weird mark_raw problem with Xslate + wonky workaround
#!/usr/bin/env perl
use strict;
use warnings;
use Text::Xslate qw<mark_raw>;
use 5.010_000;
my $x = Text::Xslate->new(
function => {
p => sub {
return mark_raw( "L(@_)" );
#!/bin/sh
# TO BE PLACED IN .git/hooks/prepare-commit-msg
# The first comments out the "Conflicts:" part of a merge commit.
# The second creates a template for a commit message
# The third example adds a Signed-off-by line to the message, that can
# still be edited. This is rarely a good idea.
# This hook is invoked by git commit right after preparing the default log
# message, and before the editor is started.
# It takes one to three parameters. The first is the name of the file that
@mfontani
mfontani / sql-beaufity
Created June 14, 2013 15:28
Beautify DBIC_TRACE=1 dumped SQL to a human readable format which doesn't suck
#!/usr/bin/env perl
use strict;
use warnings;
use SQL::Beautify;
use 5.010_001;
# Whether or not to replace "?" in the given SQL with the
# values contained at the end of the SQL, a la:
# SELECT foo FROM bar WHERE baz = ? ORDER BY foo DESC: 'barbaz'
# becomes:
@mfontani
mfontani / keybase.md
Created September 23, 2014 23:11
Keybase authorization

Keybase proof

I hereby claim:

  • I am mfontani on github.
  • I am mfontani (https://keybase.io/mfontani) on keybase.
  • I have a public key whose fingerprint is 7D94 1D1C CF93 1598 A567 01B3 D47F C150 38AE 4D5E

To claim this, I am signing this object:

#!/usr/bin/env perl
use common::sense;
use DateTime;
use Text::Table;
my $now = DateTime->from_epoch(epoch => time, time_zone => 'UTC');
my @where = qw<
UTC
Europe/London
Europe/Rome
#!/usr/bin/env perl
use Mojolicious::Lite;
get '/' => sub {
my $c = shift;
$c->render( template => 'index' );
};
get '/*' => sub {
my $c = shift;
@mfontani
mfontani / -
Created September 22, 2015 11:45
severity = 1
verbose = 8
# Allows us to set use strict;use warnings before package keyword
[-Modules::RequireExplicitPackage]
[Lax::RequireExplicitPackage::ExceptForPragmata]
# make scripts - like t/ - exempt from this policy
exempt_scripts = 1
# this is what we *use* to make this module work...
@mfontani
mfontani / -
Created September 22, 2015 12:42
severity = 1
verbose = 8
# Allows us to set use strict;use warnings before package keyword
[-Modules::RequireExplicitPackage]
[Lax::RequireExplicitPackage::ExceptForPragmata]
# make scripts - like t/ - exempt from this policy
exempt_scripts = 1
# this is what we *use* to make this module work...