Skip to content

Instantly share code, notes, and snippets.

View marcoarthur's full-sized avatar
💭
Research topics about GIS and Data Science

Marco Arthur marcoarthur

💭
Research topics about GIS and Data Science
View GitHub Profile
package T;
use Moose::Role;
sub a { 'x' }
sub b { 'y' }
sub c { shift->i }
package U;
use Moose::Role;
@marcoarthur
marcoarthur / A simple test to find a solution to a storage problem
Created October 11, 2018 23:21
MooseX::Storage to ommit private members of a class
#############################################################################
# The problem:
# We need to separate in a class two type of attributes by name:
# 1) Private: names begin with ``_'' (underscore)
# 2) Public: All other
#
# In order to apply (or try) serialization Role given by MooseX::Storage
# MooseX::Storage let us apply a role two attribute that won't be touched
# by serialized methods it is call ``MooseX::Storage::Meta::DoNotSerialize
#
@marcoarthur
marcoarthur / proof.pl
Created November 13, 2019 20:52
IO Loop experimentations
###############################################################################
# Example of use for IOLoop. The problem is to recurring ping a set of hosts
# and save each experiment.
#
###############################################################################
use Mojo::Base -signatures;
use Mojo::IOLoop;
use Net::Ping;
use DDP;
#!/usr/bin/env perl
use strict;
use warnings;
use Mojolicious::Lite -signatures;
use Data::Fake qw/Core Names Text Dates/;
use DDP;
my $url = "http://localhost:4000/";
itaipu@ubatuba:~/src/mojo$ git branch
* future_async_await
master
itaipu@ubatuba:~/src/mojo$ TEST_ASYNC_AWAIT=1 prove -vl t/mojo/promise_async_await.t
t/mojo/promise_async_await.t .. Unrecognised import symbols Mojo::Promise future_class at t/mojo/promise_async_await.t line 12.
BEGIN failed--compilation aborted at t/mojo/promise_async_await.t line 12.
Dubious, test returned 255 (wstat 65280, 0xff00)
No subtests run
Test Summary Report
@marcoarthur
marcoarthur / osm.query
Created April 2, 2020 14:07
Simple osm query
[out:json];
node
[amenity=school]
(-19.9944824139763,-43.8771629333496,-19.9765754775178,-43.8751029968262);
out;
@marcoarthur
marcoarthur / two_mojo_lite_app_single_test.t
Last active May 31, 2020 16:45
how to make a test file with two mojo applications (or how to subprocess one of it ?)
## no critic
package MyApp;
use Mojolicious::Lite;
get '/' => sub { shift->render( text => "MyApp running" ) };
package YetApp;
use Mojolicious::Lite;
get '/' => sub { shift->render( text => "Yet App running" ) };
@marcoarthur
marcoarthur / file-named-as-dates.pl
Last active August 1, 2020 02:02
How we use perl to parse all files that was named as date format
#!/usr/bin/env perl
# An example in perl for a particular problem I found using R.
#
# How we use perl to parse all files that was named as date format
# So we can parse as date and find the most recent file.
use Mojo::Base -strict, -signatures;
use DateTime;
use Mojo::File;
use DateTime::Format::Strptime;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@marcoarthur
marcoarthur / pipe.pl
Created January 12, 2021 20:10
fork basics
#!/usr/bin/env perl
## no critic
package ForkMe {
use strict;
use warnings;
use Mojo::Base -base, -signatures;
use utf8;
has pid => sub { $$ };