Skip to content

Instantly share code, notes, and snippets.

View alexm's full-sized avatar

Alex Muntada alexm

View GitHub Profile
#!/usr/bin/perl
#
# vots-pirates.pl
#
# Requeriments:
# sudo apt-get install libnotify-bin libwww-perl
#
use LWP::Simple;
@alexm
alexm / new-messages.pl
Created February 21, 2011 08:51
find all imap folders and print total and new number of messages
#!/usr/bin/perl
use strict;
use warnings;
my $SERVER = 'imap.example.com';
my $USER = 'user.name@example.com';
my $PASSWD = '***';
my $PORT = 993;
my $SSL = 1;
@alexm
alexm / barcelona.p6
Created May 5, 2011 10:09
Barcelona.pm T-shirt 2011 (with comments)
# Perl 6
use v6;
my @Barcelona = < Barcelona >;
my @PerlMongers = < Perl >;
# Define Camelia binary operator: »ö«
# https://github.com/perl6/mu/raw/master/misc/camelia.txt
# Takes a pair from the operand arrays and puts a heart in the middle
sub infix:<»ö«> {
@alexm
alexm / gist:1646641
Created January 20, 2012 10:38
Markdown as shell script
#!/bin/sh
# markdown as shell script
## setup
set -e
set -x
FOOBAR="foobar"
## step 1
@alexm
alexm / gist:1732411
Created February 3, 2012 20:45
Getopt::Long subs
#!/usr/bin/env perl
use strict;
use warnings;
use 5.010;
use Getopt::Long;
my %opt = ( 'list' => sub { say $_[0] } );
GetOptions( 'list=s' => sub { $opt{ $_[0] }->( $_[1] ) } );
@alexm
alexm / gist:1752738
Created February 6, 2012 15:42
Getopt::Long subs via hash
#!/usr/bin/env perl
use strict;
use warnings;
use 5.010;
use Getopt::Long;
sub list_postinstall {
say "postinstall: <@_>";
sub opt_postinstalls {
print "\nValid Postinstalls\n";
print "------------------\n\n";
list_postinstall();
print "\n";
exit 0
}
sub opt_distros {
print "\nValid Distributions\n";
@alexm
alexm / gist:4020386
Created November 5, 2012 21:16
lab4
my $callback = sub {
my ($line) = @_;
return line_match($line, @words);
};
my @matches;
while (my $line = <STDIN>){
if (my $result = scan_input( $., $line, $callback )) {
push @matches, $result;

puppet camp barcelona

14 mar 2013

state of puppet (chris spence)

Puppet Enterprise provides:

  • GUI
  • orchestration (m-collective): live management thru GUI
@alexm
alexm / local_sub.pl
Created May 10, 2013 10:17
Proof of concept defining a sub with a localized global.
#!/usr/bin/perl
use warnings;
use strict;
local *p = sub {
print "[", ( join ",", @_ ), "]\n";
};
p(qw( foo bar ));