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
@marcoarthur
marcoarthur / grouped_files.pl
Created June 27, 2024 16:45
continue rx_perl experiments in a while
==> own_operator.pl <==
use strict;
use warnings;
use feature qw(signatures say);
use RxPerl::IOAsync ':all';
use Mojo::Util qw(trim);
use IO::Async::Loop;
use DDP;
my $loop = IO::Async::Loop->new;
@marcoarthur
marcoarthur / database_observable.pl
Created June 27, 2024 14:55
continue embracing of rxperl
# DbConnection
package DbConnection {
use Mojo::Base -base, -strict, -signatures;
use RxPerl::Mojo ':all';
use Mojo::Pg;
use DDP;
has is_closed => 0;
has connection => undef;
has pg => sub { die 'need pg url' };
@marcoarthur
marcoarthur / experiments_rxperl.pl
Created June 27, 2024 14:54
experiments with perl rxperl
use feature qw(signatures);
my $fact = sub ($n) {
return 1 if $n == 0;
return $n * __SUB__->($n - 1);
};
my $paths = sub ($h) {
return '' unless ref $h;
@marcoarthur
marcoarthur / product.pl
Last active June 14, 2024 16:22
Mojolicious::Lite example with HTMX
use warnings;
use strict;
package App::Model::Product {
use Mojo::Base 'Mojo::EventEmitter', -strict, -signatures;
use Data::Fake qw/Core Names Text Dates/;
our %generated;
has [qw(name image description price id)];
has _fake_data => sub ($self) {
@marcoarthur
marcoarthur / references.txt
Created May 6, 2024 21:35
referencias para o plano de negócios
1. Brugnara T. tbrugz/ribge. 2024.
2. Editorial E. O que determina o consumo de frutas, verduras e legumes dos brasileiros? Determinantes Sociais da Saúde. 2012. https://dssbr.ensp.fiocruz.br/o-que-determina-o-consumo-de-frutas-verduras-e-legumes-dos-brasileiros/. Accessed 6 May 2024.
3. Acessar Dados do IBGE no R: Um pacote incrível. 2020.
4. Riederer YX Christophe Dervieux, Emily. 4.5 Bibliographies and citations | R Markdown Cookbook.
5. Rocha L. Consumo de verduras e legumes permanece baixo no Brasil, alerta pesquisa. CNN Brasil. https://www.cnnbrasil.com.br/saude/consumo-de-verduras-e-legumes-permanece-baixo-no-brasil-alerta-pesquisa/. Accessed 6 May 2024.
6. Souza BBD, Cembranel F, Hallal ALC, d’Orsi E. Consumo de frutas, legumes e verduras e associação com hábitos de vida e estado nutricional: um estudo prospectivo em uma coorte de idosos. Ciênc saúde coletiva. 2019;24:1463–72.
7. Verly Junior E, Oliveira DCRSD, Sichieri R. Custo de uma alimentação saudável e culturalmente aceitável no Brasil em 2009 e
@marcoarthur
marcoarthur / generator.pl
Last active April 28, 2024 16:49
Generators and iterators
# JavaScript translation of a simple generator example, where pagination
# technique is necessary in order to process a big list of itens, possibly in
# async manner.
#
# The JS code was generated by ChatGPT
# ../../GPT/Questions/generators_and_iterators_js.md
# we translate this js example to a Perl version
use Mojo::Base -strict, -signatures, -async_await;
sub chunkGenerator($data, $chunkSize) {
@marcoarthur
marcoarthur / map_promises.pl
Created January 16, 2024 01:48
Using map to create 3 async timers.
use v5.28;
use Mojo::Base -strict, -async_await, -signatures;
use Mojo::Promise;
=pod
=head2 myTimer($time, sub { ... });
myTimer(3 => sub { say "printed 3 seconds later" });
@marcoarthur
marcoarthur / rx-stream-from-future-event.pl
Last active December 28, 2023 15:55
reactive for event handling
use strictures 2;
package TailEvent {
use Mojo::Base 'Mojo::EventEmitter', -strict, -signatures;
use IO::Async::FileStream;
has ioloop => sub { die "needs io loop" };
has file => sub { die "needs a file" };
has poll_interval => 0.5;
sub new_line($self, $line) {
@marcoarthur
marcoarthur / roles_op.pl
Created July 23, 2023 13:43
Object::Pad role composition
use v5.26;
use Object::Pad;
role GitRole {
use Git::Wrapper;
use Carp qw(carp croak);
use Syntax::Keyword::Try;
field $repo :reader = undef;
@marcoarthur
marcoarthur / grammars_and_promises.pl
Created July 25, 2021 01:48
Regexp::Grammar plus Mojo::Promises
use strictures 2;
use 5.030;
## no critic Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage
package Calculator::Actions {
use Mojo::Base "Mojo::EventEmitter", -async_await, -signatures;
use List::Util qw< reduce >;
async sub Answer( $self, $MATCH_ref ) {