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
| /* | |
| There is an AST (Abstract syntax tree) in JSON format. | |
| AST represents Excel spreadsheet formula. | |
| Is it possible in JavaScript to make RPN (Reverse Polish Notation) faster than AST? | |
| AST evaluation is recusive and RPN evaluation is iterative. | |
| But in any case, AST evaluation is faster despite recursion. | |
| I guess that the main problem is in using dynamic js arrays to emulate stack. | |
| Would RPN win if it was written in C/C++? | |
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
| { | |
| "modules" : { | |
| "CPAN::Meta" : { | |
| "dist" : "CPAN-Meta-2.130880", | |
| "mymeta" : { | |
| "abstract" : "the distribution metadata for a CPAN dist", | |
| "author" : [ | |
| "David Golden <[email protected]>", | |
| "Ricardo Signes <[email protected]>" | |
| ], |
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 Try::Tiny; | |
| sub load { | |
| my $self = shift; | |
| try { | |
| return $self->SUPER::load(@_); | |
| } | |
| catch { | |
| ... |
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
| # Replace "form_for" helper | |
| my $original_form_for = delete $app->renderer->helpers->{form_for}; | |
| croak qq{Cannot find helper "form_for". Please, load plugin "TagHelpers" before} | |
| unless $original_form_for; | |
| $app->helper( form_for => sub { | |
| my $c = shift; | |
| if ( defined $_[-1] && ref( $_[-1] ) eq 'CODE' ) { | |
| my $cb = $_[-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 List::Util qw/first/; | |
| use List::MoreUtils qw/first_value/; | |
| use v5.10; | |
| use Test::More; | |
| is( test('grep'), 4, 'Grep for finding first value' ); | |
| is( test('list_util'), 4, 'List::Util::first for finding first value' ); | |
| is( test('list_more_utils'), 4, 'List::MoreUtils::first_value for finding first value' ); | |
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
| # ... | |
| test_exception( Exception1->new() ); | |
| test_exception( Exception2->new() ); | |
| test_exception( Exception3->new() ); | |
| test_exception("Special text\n"); | |
| test_exception("Text exception\n"); | |
| use Scalar::Util qw/blessed/; | |
| sub e($) { |
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 Exception::Base; | |
| use overload | |
| '~~' => sub { $_[0]->isa( $_[1] ) }, | |
| fallback => 1; | |
| package Exception1; | |
| use base 'Exception::Base'; | |
| sub new { bless {}, shift } | |
| package Exception2; |
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
| $app->helper('render_file' => sub { | |
| my $c = shift; | |
| my %args = @_; | |
| my $filepath = $args{filepath}; | |
| unless ( -f $filepath && -r $filepath ) { | |
| $c->app->log->error("Cannot read file [$filepath]. error [$!]"); | |
| return; | |
| } |
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 strict; | |
| use warnings; | |
| use ExtUtils::MakeMaker; | |
| WriteMakefile( | |
| NAME => 'MyApp', | |
| VERSION => 0.01, | |
| MIN_PERL_VERSION => 5.010, | |
| PREREQ_PM => { | |
| 'Mojolicious' => 2.41, |
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
| <meta name="csrftoken" content="af58af65a8f65a8dfafa76df8a7afdf"/> | |
| <script type="text/javascript"> | |
| $(document).ajaxSend(function(e, xhr, options) { | |
| var token = $("meta[name='csrftoken']").attr("content"); | |
| xhr.setRequestHeader("X-CSRF-Token", token); | |
| }) | |
| </script> |