Skip to content

Instantly share code, notes, and snippets.

View rodrigolive's full-sized avatar

Rodrigo de Oliveira Gonzalez rodrigolive

View GitHub Profile
# The Computer Language Benchmarks Game
# http://shootout.alioth.debian.org/
# contributed by Rodrigo de Oliveira 29/mar/2010
# based on the Python original by Daniel Nanz
use strict;
use warnings;
use threads;
use threads::shared;
use Thread::Semaphore;
# The Computer Language Benchmarks Game
# http://shootout.alioth.debian.org/
# contributed by Rodrigo de Oliveira 29/mar/2010
# based on the original version by Jesse Millikian
use threads;
use threads::shared;
use Thread::Semaphore;
my @creature_colors = qw/blue red yellow/;
javascript:(function() {
var pre = document.body.children[0];
var code = pre.innerHTML;
code = code.replace( /(([A-Z]\w+::[A-Z]\w+)(::[A-Z]\w+)*)/g,
'<a class="perldoc" href="http://search.cpan.org/perldoc?$1">$1</a>' );
code = code.replace( /^(use|require) (\w+(::\w+)*)/gm,
'$1 <a class="perldoc" href="http://search.cpan.org/perldoc?$2">$2</a>' );
var html = '
@rodrigolive
rodrigolive / gist:820224
Created February 10, 2011 10:01 — forked from kitchen/gist:817748
Find even numbers in a list - cleaner with not
#perl
grep { not $_ % 2 } (1,2,3,4)
#ruby
[1,2,3,4].select{ |x| x.even? }
#python
[x for x in [1,2,3,4] if not x%2]
#or, more norvingly
filter(lambda x: not x%2, [1,2,3,4])
# set
my $corr = { from=>'', to=>'', msg=>'' };
my $ns = 'sqauser/jack' ;
my $data = repo->get( $ns );
$data ||= {}; # inicializa si está vacio
push @{ $data->{correos} }, $corr;
repo->set( ns=>$ns, data=>$data );
@rodrigolive
rodrigolive / imap.pl
Created August 1, 2012 15:40
imap downloader
#!/usr/bin/env perl
=head1 DESCRIPTION
IMAP downloader.
Usage:
perl imap.pl -u 'user' -p 'password' -s 'imap.gmail.com' -d './download-dir' -subdir 'maildir' -q 'search-query' -id 999 -from 999
@rodrigolive
rodrigolive / gitt
Last active December 14, 2015 05:49
gitt, a git status on steroids
#!/usr/bin/env perl
use v5.14;
use Path::Class;
use Class::Date qw(date now);
use Getopt::Mini var => 'opts' ;
my %mods ;
my $k = 0;
#use YAML;
use strict;
use warnings;
use v5.10;
use MongoDB;
use Time::HiRes qw/usleep /;
use Class::Date;
use DateTime;
my $connection = MongoDB::Connection->new();
my $db = $connection->get_database("queue");
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="https://www.facebook.com/2008/fbml" xmlns:og="http://ogp.me/ns#" xml:lang="en" lang="en">
<!-- Svbtle Theme for Tumblr by matteoroversi.com -->
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="imagetoolbar" content="false" />
@rodrigolive
rodrigolive / socket-app1.pl
Last active April 6, 2020 14:44
Mojolicious websocket app that mimicks this one: http://www.html5rocks.com/en/tutorials/frameworks/angular-websockets/?redirect_from_locale=es $ cpanm Mojolicious Class::Date $ perl socket-app1.pl daemon
use Mojolicious::Lite;
use Protocol::SocketIO::Message;
use Protocol::SocketIO::Handshake;
use Class::Date;
any '/' => 'index';
any '/view1' => 'index';
any '/view2' => 'index';
any '/partials/:name' => sub {