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
| #!/opt/perl | |
| use Mojolicious::Lite; | |
| get '/' => sub { | |
| my $self = shift; | |
| $self->render('index'); | |
| }; |
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
| #!/opt/perl | |
| use Mojolicious::Lite; | |
| use JSON; | |
| get '/' => sub { | |
| my $self = shift; | |
| $self->render("index"); | |
| }; |
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
| #!/opt/perl | |
| use Mojolicious::Lite; | |
| helper setup_valid => sub { | |
| my $self = shift; | |
| my $topics = shift; | |
| my $v = $self->validation; |
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
| #!/bin/tcsh | |
| if ( ${?VARIABLE} ) then | |
| echo "Joy:${VARIABLE}" | |
| else | |
| echo "Joy" | |
| endif |
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
| sub hash_password { | |
| my $self = shift; | |
| my ($plain_text, $settings_str) = @_; | |
| unless ($settings_str) { | |
| my $salt = join('', map { chr(int(rand(256))) } 1 .. 16); | |
| $salt = Crypt::Eksblowfish::Bcrypt::en_base64( $salt ); | |
| return(Crypt::Eksblowfish::Bcrypt::bcrypt_hash({ | |
| key_nul => 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 Mojo::UserAgent; | |
| my $ua = Mojo::UserAgent->new; | |
| $ua->cert(...); | |
| $ua->transactor->http_proxy(...); | |
| $ua->max_redirects(3); | |
| # Say hello to the Unicode snowman with "Do Not Track" header | |
| say $ua->get('www.☃.net?hello=there' => {DNT => 1})->res->body; |
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::UserAgent::Proxy; | |
| use Mojo::Base -base; | |
| has [qw(http https no)]; | |
| sub detect { | |
| my $self = shift; | |
| $self->http($ENV{HTTP_PROXY} || $ENV{http_proxy}); | |
| $self->https($ENV{HTTPS_PROXY} || $ENV{https_proxy}); | |
| return $self->no([split /,/, $ENV{NO_PROXY} || $ENV{no_proxy} || '']); |
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 IO::String; | |
| $io = IO::String->new("one\ntwo\nthree\nfour\nfive\n"); | |
| $line = (<$io>)[int(rand(5))]; | |
| print($line); |
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
| var iceServers = { | |
| iceServers: [{ | |
| url: 'stun:23.21.150.121' | |
| }] | |
| }; | |
| var optionalRtpDataChannels = { | |
| optional: [{DtlsSrtpKeyAgreement: true}, {RtpDataChannels: true }] | |
| }; |
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
| [bpm@Orfgum] c:.../playground/sparky/lib>find . | grep Mojo | grep '\.pm$' | /opt/perl go.pl | |
| [bpm@Orfgum] c:.../playground/sparky/lib>cat go.pl | |
| BEGIN { print(qq(<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">)) }; | |
| while (<>) { | |
| s#.*#<url><loc>http://mojo.us/$&</loc></url>#; | |
| print; | |
| } | |
| END { print("</urlset>") }; |