Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!--
This file was generated by Devel::NYTProf version 6.02
--><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Language" content="en-us">
<meta name="robots" content="noindex,nofollow">
<title>Profile of Plack/Middleware/Debug/TraceENV.pm</title>
<link rel="stylesheet" type="text/css" href="delete_files/style.css">
<script type="text/javascript" src="delete_files/jquery-min.js"></script>
@KES777
KES777 / gist:451abd9817449d8230de529a32da0e0c
Created June 10, 2017 14:52
unexpected rendering for /2/0
kes@work ~/work/projects/del4/my_app $ script/my_app get /1/0
[Sat Jun 10 17:50:11 2017] [debug] GET "/1/0"
[Sat Jun 10 17:50:11 2017] [debug] Routing to controller "MyApp::Controller::Render" and action "just_render"
[Sat Jun 10 17:50:11 2017] [debug] Rendering template "content_implicit.html.ep"
[Sat Jun 10 17:50:11 2017] [debug] Rendering template "base.html.ep"
[Sat Jun 10 17:50:11 2017] [debug] 200 OK (0.00265s, 377.358/s)
HI2
# carton snapshot format: version 1.0
DISTRIBUTIONS
Algorithm-C3-0.10
pathname: H/HA/HAARG/Algorithm-C3-0.10.tar.gz
provides:
Algorithm::C3 0.10
requirements:
Carp 0.01
ExtUtils::MakeMaker 0
Test::More 0.47
@KES777
KES777 / captures.t
Last active November 2, 2017 11:20
use Mojolicious::Lite;
use Test::More;
use Test::Mojo;
my $deep = Mojolicious->new;
$deep->routes->any('/deep', sub{ shift->render( 'deep' ) } )->name( 'deep' );
$deep->routes->any('/abs', sub{ shift->render( 'abs' ) } );
my $r = app->routes;
# BEGIN{ $ENV{MOJO_INACTIVITY_TIMEOUT} = 0; }
use Mojolicious::Lite;
package DeepApp;
use Mojolicious::Lite;
get '/test' => sub {
my $c = shift;
$c->render( text => 'OK' );
};
use Mojolicious::Lite;
use Test::More;
use Test::Mojo;
my $r = app->routes;
$r->any('/l1')->detour( 'Lite' );
$r->any('/l2')->detour( 'Lite' );
$r->any('/f1')->detour( 'Full' );
$r->any('/f2')->detour( 'Full' );
@KES777
KES777 / lite_app.t
Last active November 3, 2017 14:21
not workint mojolicious lite app
use Mojolicious::Lite;
package Lite;
use Mojolicious::Lite;
get '/bye' => sub{ shift->render( text => 'OK' ) };
package main;
diff --git a/lib/Mojolicious/Lite.pm b/lib/Mojolicious/Lite.pm
index cf3cd04..21277fb 100644
--- a/lib/Mojolicious/Lite.pm
+++ b/lib/Mojolicious/Lite.pm
@@ -46,9 +46,6 @@ sub import {
plugin => sub { $app->plugin(@_) },
under => sub { $routes = $root->under(@_) };
- # Make sure there's a default application for testing
- Mojo::UserAgent::Server->app($app) unless Mojo::UserAgent::Server->app;
@KES777
KES777 / App.pm
Created March 3, 2018 16:48
Mojolicious Theming
...
sub startup {
...
$app->hook( before_render => sub{
my( $c, $args ) = @_;
my $theme = $c->stash->{ theme } // '';
$args->{template} = "$theme/$args->{template}";
# But here we get two problems:
@KES777
KES777 / gist:8f6a32b9cde4404414aadffa8fb2515b
Created March 23, 2018 07:36
format precedence while content negotiation
>Rails picks up the expected format from the query parameter format, or if not there from the URL path suffix, or it not there from the Accept header
Blog post: https://dzone.com/articles/rest-with-rails-part-2-serving
>format query parameter is useful for rendering JSON output from a web browser without
special tools to modify the Accept header
IBM knowledge base: https://www.ibm.com/support/knowledgecenter/en/SS4GCC_6.1.1/com.ibm.urelease.doc/topics/rest_api_ref_conventions.html
>However, if a request uses multiple methods simultaneously,