Skip to content

Instantly share code, notes, and snippets.

View mfontani's full-sized avatar

Marco Fontani mfontani

View GitHub Profile
@mfontani
mfontani / git-rr
Created June 28, 2011 16:46
git-rr: show which files were changed in commits, when rebasing
#!/bin/sh
# Usage:
# Once you started git rebase --interactive master, and you are presented
# with the list of commit SHAs and commit messages, from Vim:
# - visually select all SHAs via "V}k"
# - launch git-rr: !git-rr
# - ...
# - profit! you now have the same info as before, just with the list of
# filenames which changed with each commit, and can now move around
#!/usr/bin/env perl
use 5.020_000;
use warnings;
# Based on Damian Conway's bin/file_template
my %TEMPLATE_FOR = (
'.sh' => \&gen_sh_file,
'.pm' => \&gen_pm_file,
'.pl' => \&gen_pl_file,
@mfontani
mfontani / raptor.sh
Created June 23, 2011 13:10
raptor -- type less to do more with a Perl one-liner
# Based on http://blogs.perl.org/users/randy_stauner/2011/06/exploratory-one-liners-with-less-typing.html
# and a couple more things which are *really* handy
function raptor {
case "$1" in
-*) break ;;
'')
echo "Syntax: raptor [-lneEp etc] 'code'
The code can make use of:
DD() to Data::Dumper::Dumper() a thing, D() to say() it
YY() to YAML::Dump() a thing, Y() to say() it
@mfontani
mfontani / log-deployment.txt
Created April 29, 2011 23:06
Deploying a dancer webapp to DotCloud.com
Dancing on the cloud
okram@BLUEDESK ~> sudo aptitude install python-setuptools
[...]
okram@BLUEDESK ~> sudo easy_install dotcloud
[...]
okram@BLUEDESK ~> dotcloud
Warning: /home/okram/.dotcloud/dotcloud.conf does not exist.
@mfontani
mfontani / perl_miner.pl
Created June 27, 2011 08:16
A (test,simplistic) Perl bitcoin miner
#!/usr/bin/env perl
use 5.010_001;
use strict;
use warnings;
use Digest::SHA;
use JSON::XS;
use WWW::Mechanize;
use Time::HiRes qw<time gettimeofday tv_interval>;
use Getopt::Long;
#!/bin/sh
# 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
# contains the commit log message. The second is the source of the commit
@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:
#!/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

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 809D 2E19 BAAB 34F0 F06B A9FE 0082 DA0D 3C87 9073

To claim this, I am signing this object:

@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(@_)" );