Skip to content

Instantly share code, notes, and snippets.

View esobchenko's full-sized avatar

Eugen Sobchenko esobchenko

  • Odessa, Ukraine
View GitHub Profile
@esobchenko
esobchenko / gist:149501
Created July 18, 2009 10:45
simple persistent class template
package Foo;
# by Eugen Sobchenko, [email protected]
use base qw( Class::Accessor );
Foo->follow_best_practice;
Foo->mk_accessors( qw( id foo bar ) );
sub search_by {
@esobchenko
esobchenko / gist:183677
Created September 9, 2009 12:22
single linked list reverse function
#!/usr/bin/perl
# by Eugen Sobchenko, [email protected]
use strict;
use warnings;
use Data::Dumper;
sub reverse_list {
@esobchenko
esobchenko / gist:184564
Created September 10, 2009 13:55
project euler: problem solutions
-module(euler).
-compile(export_all).
%% problem 1
%% If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
%% Find the sum of all the multiples of 3 or 5 below 1000.
%% Answer: 233168
@esobchenko
esobchenko / gist:189029
Created September 18, 2009 12:27
create_table inside mnesia transaction
-module(test).
-compile(export_all).
-record(test, {foo, bar}).
%% fails with "{atomic,{aborted,nested_transaction}}"
add_table1() ->
F = fun() ->
% ...
mnesia:create_table( test1,
my ( $error, $failed );
{
local $@;
$failed = not eval {
# ...;
return 1;
#!/usr/bin/env perl
use strict;
use warnings;
use MojoX::Redis;
my $redis1 = MojoX::Redis->new();
$redis1
->sadd ( "set1" => "foo" )
#!/usr/bin/env perl
use strict;
use warnings;
use MojoX::Redis;
my $redis1 = MojoX::Redis->new();
$redis1
->sadd ( "set1" => "foo" )
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
sub foo {
wantarray ? () : undef;
}
#!/usr/bin/env perl
use strict;
use warnings;
use Mojolicious::Lite;
post '/' => sub {
my $self = shift;
$self->render_data($self->req->body, format => 'bin');
#!/usr/local/bin/bash
# install perlbrew
curl -L http://xrl.us/perlbrewinstall | bash
$HOME/perl5/perlbrew/bin/perlbrew init
echo source $HOME/perl5/perlbrew/etc/bashrc >> ~/.bash_profile
source $HOME/perl5/perlbrew/etc/bashrc
# install cpanm
cd $HOME/perl5/perlbrew/bin