Skip to content

Instantly share code, notes, and snippets.

View jberger's full-sized avatar

Joel Berger jberger

View GitHub Profile
@jberger
jberger / gist:9db7e7711d46d06dd013fcf4b74ee689
Created December 5, 2019 21:34
Quick discussion about async/await
<jberger>async/await is going to take over the world
its going to be the next "OO is everything, if it isn't OO it is nothing"
"oh your language doesn't have a/a, ok boomer"
suddenly I see the lack of core a/a in perl(5) as as much of an existential threat as the confusion over perl6 was
<mishanti1>The competition we have is not the lack of feature A or B, but simply agility in introducing new features in the language.
<jberger>generally I agree with you, but this one is a big deal
it is changing how students are being taught to code
it is changing how apis are being designed
and younger coders literally aren't going to think in callbacks, nor even in promise chains really, in the near future
the rare actual paradigm shift
#!/usr/bin/env perl
use strict;
use warnings;
use YAML::PP;
my $yaml = YAML::PP->new( schema => ['YAML1_1'] );
# or
#use YAML::PP::LibYAML;
use Mojolicious::Lite -signatures;
sub _generate_id { ... }
{
package Mojo::Log::WithContext;
use Mojo::Base 'Mojo::Log', -signatures;
has context => sub { {} };
has id => sub { _generate_id() };
has format => sub { sub ($id, $first, @lines) { ("[$id] $first", @lines) } };
use Mojo::Base -strict;
use Mojo::URL;
use Mojo::UserAgent;
my $ua = Mojo::UserAgent->new;
my ($id) = @ARGV;
my $url = Mojo::URL->new('http://www.j-archive.com/showgame.php')->query(game_id => $id);
#!perl
use strict;
use warnings;
use Archive::Tar;
use CPAN::Meta;
use ExtUtils::Manifest qw/mkmanifest maniread/;
use Module::CPANfile;
use Module::Metadata;
@jberger
jberger / cli_app.pl
Last active June 1, 2019 17:16
A simple CLI app runner with commands in another namespace
use strict;
use warnings;
use feature 'say';
package CLI;
use Moo;
use Carp ();
has commands => (
<jberger> so as people are assembling for PTS (which I sadly am not able to attend this year) I want to float an idea that I've been thinking a lot about
and it specifically derives from building out the CI/CD system we're using at $work
I'd like there to be some way to delegate the module version to the META file
this is handy because I can build a darkpan dist and not need to modify the code in order to do so (if the version isn't in the code)
but it also gives us some other nice perks
no need to statically parse the version out of the code
and an opportunity to newer/better enforce standards on versions declared in this way
I'd see it as opt in in the module probably
use VersionFromMETA 'Distname'; or some such
we'd have to have tooling that would make the meta available obviously
17:24:25.044 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /opt/venvs/mycroft-core/lib/python3.4/site-packages/mycroft/configuration/mycroft.conf loaded
17:24:25.300 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /opt/venvs/mycroft-core/lib/python3.4/site-packages/mycroft/configuration/mycroft.conf loaded
17:24:25.542 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /etc/mycroft/mycroft.conf loaded
17:24:25.777 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /home/mycroft/.mycroft/mycroft.conf loaded
17:24:26.037 - mycroft.identity:_load:44 - DEBUG - Loading identity
17:24:26.052 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.mycroft.ai:443
17:24:26.438 - urllib3.connectionpool - DEBUG - https://api.mycroft.ai:443 "GET /v1/device/059a2be3-6160-4300-844e-791345f0e74e HTTP/1.1" 200 476
17:24:26.683 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /opt/venvs/mycroft-core/lib/
@jberger
jberger / app.psgi
Last active November 30, 2018 16:31
use Dancer2;
set template => 'simple';
set views => '.';
any '/text' => sub {
my $name = param('name') // 'world';
send_as plain => "hello $name";
};
@jberger
jberger / version.pl
Last active November 27, 2018 15:29
a VERSION method that checks for major version number as well as minimum version
use strict;
use warnings;
{
package MyPackage;
use version;
use Carp ();
our $VERSION = '2.01';