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
# to run simple execute: morbo 1.pl | |
# go to link htpp://127.0.0.1:3000/ | |
use Mojolicious::Lite; | |
use Mojo::IOLoop; | |
use Mojo::IOLoop::ReadWriteFork; | |
get '/' => 'index'; | |
websocket '/find' => 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
Generate 2 certficate: | |
openssl req -nodes -new -x509 -keyout client.key -out client.cert | |
openssl req -nodes -new -x509 -keyout server.key -out server.cert | |
run server: | |
morbo server.pl -l 'https://*:3000?cert=./server.cert&key=./server.key&ca=client.cert' | |
run client: | |
openssl s_client -connect 127.0.0.1:3000 -cert client.cert -key client.key | |
GET / HTTP/1.0 |
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 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'); |
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
create table test (id int primary key, a int, b int, unique (a, b)); | |
\d+ test | |
begin; | |
insert into test values (1, 1, 1); | |
do $$ | |
declare | |
_cn text; | |
begin | |
insert into test values (1, 2, 2); |
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/perl | |
package Reactor::Select; | |
use Mojo::Base -base; | |
use IO::Select; | |
sub new { | |
my $self = shift->SUPER::new; | |
$self->{select}{read} = IO::Select->new; |
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/perl | |
use Mojo::Base -strict; | |
use Mojo::JSON::MaybeXS; | |
use Mojo::JSON 'decode_json'; | |
use Mojolicious::Lite; | |
use IPC::Open3; | |
use Mojo::IOLoop; | |
my $mystem_path = '/usr/local/bin/mystem'; |
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/perl | |
use Mojo::Base -strict; | |
use Socket; | |
use Mojo::IOLoop; | |
use IO::Socket::Socks qw/:constants $SOCKS_ERROR/; | |
my @configs = ({ | |
proxy_addr => '127.0.0.1', | |
proxy_port => 12345, |
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/perl | |
use Mojo::Base; | |
use Mojo::IOLoop; | |
use Mojo::IOLoop::Client; | |
use Mojo::IOLoop::TLS; | |
use IO::Socket::IP; | |
my $s; |
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/perl | |
use Mojo::Base -strict; | |
use Mojo::IOLoop; | |
use Mojo::UserAgent; | |
use Mojo::URL; | |
my $ua = Mojo::UserAgent->new(max_redirects => 3); | |
sub find_new_url { |
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/perl | |
use Mojo::Base -strict; | |
use SOAP::Lite +trace => 'all'; | |
use DDP; | |
my $soap = new SOAP::Lite->new; | |
$soap->autotype(0); | |
$soap->readable(1); | |
$soap->service('http://ws.dpd.ru/services/geography2?wsdl'); |