Skip to content

Instantly share code, notes, and snippets.

View olegwtf's full-sized avatar

Oleg olegwtf

  • reg.ru
  • Russia, Novosibirsk
View GitHub Profile
@kraih
kraih / Coro.pm
Last active April 19, 2019 13:48
package Mojolicious::Plugin::Coro;
use Mojo::Base 'Mojolicious::Plugin';
use Coro;
use Mojo::IOLoop;
# Wrap application in coroutine and reschedule main coroutine in event loop
sub register {
my ($self, $app) = @_;
my $subscribers = $app->plugins->subscribers('around_dispatch');
use Mojolicious::Lite;
use EV;
use AnyEvent;
use AnyEvent::Util;
get '/' => sub {
my $self = shift;
# Run Perl oneliner in separate process and capture STDOUT
fork_call {
@kraih
kraih / websocket.t
Last active September 27, 2015 06:39
#!/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