Skip to content

Instantly share code, notes, and snippets.

View vti's full-sized avatar

Viacheslav Tykhanovskyi vti

  • UPTOSMTH OÜ
  • Mars
View GitHub Profile
content - контент
escaping - экранирование
footer - подвал
header - шапка
helper
layout - общий шаблон
plain text - текст без форматирования
plugin - расширение
raw bytes
render
#!/usr/bin/env perl
use strict;
use warnings;
use Mojo::DOM;
use Data::Dumper;
my $file;
maestro% ~/dev/mojo/script/mojo get --header http://ya.ru
Connection: Keep-Alive
Date: Fri, 16 Jul 2010 11:15:33 GMT
Server: Mojolicious (Perl)
Content-Length: 38
Content-Type: text/plain
Congratulations, your Mojo is working!Couldn't open page "--header".
#!/usr/bin/env perl
use strict;
use warnings;
my $query = join ' ' => @ARGV;
my $url = 'http://www.google.com/search';
use Mojo::Client;
use Mojo::URL;
#!/usr/bin/env perl
use strict;
use warnings;
use Mojo::Client;
my $client = Mojo::Client->new;
my $news = 'http://digg.com';
#!/usr/bin/env perl
use strict;
use warnings;
use FindBin;
BEGIN {
use lib "/Users/vti/dev/protocol-websocket/lib";
}
@vti
vti / app.psgi
Created August 30, 2011 15:37
jsonp for metacpan
$app = Plack::Middleware::ReverseProxy->wrap($app);
$app = Plack::Middleware::RestrictedJSONP->wrap($app, path => qr{^/(?:author|release|pod)(?:$|/)});
@vti
vti / gist:1186895
Created September 1, 2011 18:37
metacpan jsonp
diff --git a/lib/MetaCPAN/Server.pm b/lib/MetaCPAN/Server.pm
index 75f687d..2f0d103 100755
--- a/lib/MetaCPAN/Server.pm
+++ b/lib/MetaCPAN/Server.pm
@@ -1,9 +1,10 @@
package MetaCPAN::Server;
+use lib 'lib';
use Moose;
extends 'Catalyst';
@vti
vti / gist:1187191
Created September 1, 2011 20:31
metacpan jsonp via roles
diff --git a/lib/MetaCPAN/Role/JSONP.pm b/lib/MetaCPAN/Role/JSONP.pm
new file mode 100644
index 0000000..61b1ab6
--- /dev/null
+++ b/lib/MetaCPAN/Role/JSONP.pm
@@ -0,0 +1,37 @@
+package MetaCPAN::Role::JSONP;
+use Moose::Role;
+use Encode;
+
% prove -l t/
t/fakecpan.t .. 2/? Can't call method "rmtree" on an undefined value at t/fakecpan.t line 33.
# Tests were run but no plan was declared and done_testing() was not seen.
t/fakecpan.t .. Dubious, test returned 255 (wstat 65280, 0xff00)
All 2 subtests passed
t/types.t ..... ok
t/util.t ...... ok