This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
package FooMoo; | |
use Moo; | |
has foo => ( | |
is => 'rw', | |
default => sub { 'foo' }, | |
clearer => 1, | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use Mojo::IOLoop::Stream; | |
my $stream = Mojo::IOLoop::Stream->new(IO::File->new("</dev/urandom")); | |
$stream->on(read => sub { | |
my ($stream, $bytes) = @_; | |
print STDERR "Read from stream\n"; | |
}); | |
$stream->on(error=>sub { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Test::Mojo; | |
{ | |
package Statocles::Command::_MOJOAPP; | |
# Currently, as of Mojolicious 5.12, loading the Mojolicious module here | |
# will load the Mojolicious::Commands module, which calls GetOptions, which | |
# will remove -h, --help, -m, and -s from @ARGV. We fix this by copying | |
# @ARGV in bin/statocles before we call Statocles::Command. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Test::More; | |
use Mojo::Base; | |
use Mojo::IOLoop; | |
use Mojo::IOLoop::Delay; | |
use Mojo::UserAgent; | |
use Mojo::IOLoop; | |
{ | |
package Statocles::Command::_MOJOAPP; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
» perl -e'use strict "vars"; BEGIN { printf "\%8d -> %60s", $^H, unpack( "b*", $^H ) }' | |
1408 -> 10001100001011000000110000011100 | |
» perl -e'use strict "subs"; BEGIN { printf "\%8d -> %60s", $^H, unpack( "b*", $^H ) }' | |
832 -> 000111001100110001001100 | |
» perl -e'use strict "refs"; BEGIN { printf "\%8d -> %60s", $^H, unpack( "b*", $^H ) }' | |
290 -> 010011001001110000001100 | |
» perl -e'use strict; BEGIN { printf "\%8d -> %60s", $^H, unpack( "b*", $^H ) }' | |
2018 -> 01001100000011001000110000011100 | |
» perl -e'use strict "refs", "vars", "subs"; BEGIN { printf "\%8d -> %60s", $^H, unpack( "b*", $^H ) }' | |
2018 -> 01001100000011001000110000011100 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use feature qw( :5.16 ); | |
use DateTime; | |
my $now = DateTime->now( time_zone => 'America/Chicago' ); | |
my $lon = DateTime->today( time_zone => 'Europe/London' ); | |
$lon->set_hour( 6 ); | |
$lon->set_minute( 22 ); | |
while ( $lon < $now ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Test::MockTime qw( set_absolute_time ); | |
# Use the Pure-Perl loop so we can do janky things with time | |
use AnyEvent::Loop; | |
# set_absolute_time will update what time AnyEvent thinks it is | |
# Then you can run AnyEvent::Loop::one_event to run the event loop | |
# until something happens. | |
# | |
# AnyEvent::Loop::one_event will call _update_clock to get the current time. If |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: A Test Post | |
author: preaction | |
content: | | |
# Markdown content goes here. | |
This is a new post using the brand-new command system. | |
Don't forget to maintain the indentation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package MyApp; | |
use Mojo::Base 'Mojolicious'; | |
=attr rest_url | |
The URL to the REST API | |
=cut |