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 Evil; | |
use Mojo::Base 'Mojolicious::Plugin'; | |
# Singleton controller | |
our $CONTROLLER; | |
sub register { | |
my ($self, $app) = @_; | |
# Localize singleton controller |
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 Mojolicious::Lite; | |
get '/' => sub { | |
render text => 'Hello World!'; | |
}; | |
app->start; |
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
set background=dark | |
hi clear | |
if exists("syntax_on") | |
syntax reset | |
endif | |
let colors_name = "kraihlight" |
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
#!/usr/bin/env perl | |
use Mojolicious::Lite; | |
use EV; | |
use AnyEvent; | |
# Simple delayed rendering | |
get '/' => sub { | |
my $self = shift; | |
my $w; | |
$w = AE::timer 3, 0, 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 Mojolicious::Lite; | |
use EV; | |
use AnyEvent::IRC::Client; | |
my $c = AnyEvent::IRC::Client->new; | |
$c->connect('irc.perl.org', 6667, {nick => 'marcus2'}); | |
$c->send_srv(JOIN => '#mojo'); | |
get '/' => sub { | |
my $self = shift; |
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
#!/usr/bin/env perl | |
use Mojolicious::Lite; | |
get '/' => 'index'; | |
get '/events' => sub { | |
my $self = shift; | |
# Emit "dice" event every second | |
$self->res->headers->content_type('text/event-stream'); |
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 Mojo::DOM; | |
# Parse HTML5 snippet | |
my $dom = Mojo::DOM->new(<<EOF); | |
<div> | |
<a href="http://search.cpan.org"> | |
<img src="/images/search.png"> | |
</a> | |
<a href="http://mojolicio.us"> | |
<p>Mojolicious</p> |
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
#!/usr/bin/env perl | |
use Mojo::Base -strict; | |
use utf8; | |
use Test::More tests => 4; | |
use Mojolicious::Lite; | |
use Test::Mojo; | |
# Tiny echo web service |
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 Mojo::IOWatcher::AnyEvent; | |
use Mojo::Base 'Mojo::IOWatcher'; | |
use AE; | |
use Scalar::Util 'weaken'; | |
$ENV{MOJO_IOWATCHER} ||= 'Mojo::IOWatcher::AnyEvent'; | |
my $SINGLETON; |
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
#!/usr/bin/env perl | |
use Mojolicious::Lite; | |
use EV; | |
use AnyEvent::IRC::Client; | |
# Join #mojo on irc.perl.org | |
my $irc = AnyEvent::IRC::Client->new; | |
$irc->connect('irc.perl.org', 6667, {nick => "mojobot$$"}); | |
$irc->send_srv(JOIN => '#mojo'); |