Skip to content

Instantly share code, notes, and snippets.

Dan Book Grinnz

  • Connecticut, US
Block or report user

Report or block Grinnz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Grinnz
Grinnz / parameter_test.pl
Created Apr 21, 2015
Mojo parameter test
View parameter_test.pl
use Mojolicious::Lite;
helper get_contents => sub {
my $c = shift;
if ($c->req->method eq 'GET' or $c->req->method eq 'HEAD') {
return $c->req->url->query;
} else {
return $c->req->body;
}
};
@Grinnz
Grinnz / dbd-sqlite-multiple-queries.perl
Created Jul 28, 2015
DBD::SQLite multiple query issue
View dbd-sqlite-multiple-queries.perl
use strict;
use warnings;
use DBI;
use Test::More;
sub run {
my ($sql, $query) = @_;
my $sth;
while ($query) {
View no-uutf8.pm
package MojoUtil;
use constant ('UUTF8', $ENV{'MOJO_NO_UUTF8'} ? 0 : eval 'use Unicode::UTF8 0.58 (); 1');
sub decode {
my($encoding, $bytes) = @_;
my $fallback = sub {
die;
}
;
return undef unless eval {
do {
View foo.md

THIS... IS... MARKDOWN

foo bar
1 2
3 4
View use_rel_lib.pl
use File::Basename ();
use File::Spec;
use lib File::Spec->catdir(File::Spec->rel2abs(File::Basename::dirname(__FILE__)), 'path', 'to', 'lib');
View .nanorc
set autoindent
set const
set historylog
set morespace
set nowrap
set smarthome
set smooth
set tabsize 4
include "/usr/share/nano/*.nanorc"
@Grinnz
Grinnz / Iterator.pm
Created Dec 6, 2017
Syntax::Keyword::WhileEach
View Iterator.pm
package Syntax::Keyword::WhileEach::Iterator;
use strict;
use warnings;
use Carp 'croak';
use Scalar::Util 'reftype';
sub new {
my ($class, $structure) = @_;
my $reftype = reftype $structure;
View perlbug_each.txt
The 'each' function documentation is missing some information.
1. When called in scalar context in a while loop, the condition is wrapped
implicitly in a 'defined' check, much like with 'readline'.
e.g. `while (my $key = each %hash) { ... }` becomes
`while (defined(my $key = each %hash)) { ... }`, and
`while (each %hash) { ... }` becomes `while (defined($_ = each %hash)) { ... }`
(on 5.18+)
View output
> mojo get 'http://localhost:3000//fred/fish'
[Tue Feb 20 16:28:38 2018] [debug] GET "/fish"
[Tue Feb 20 16:28:38 2018] [debug] Routing to a callback
[Tue Feb 20 16:28:38 2018] [debug] 200 OK (0.000438s, 2283.105/s)
fred⏎
View gist:bb31cdff63006c856aead3e3311d0c13
use strict;
use warnings;
use Mojo::UserAgent;
use Mojo::Asset::File;
# Build a normal transaction
my $ua = Mojo::UserAgent->new;
my $tx = $ua->build_tx(POST => 'http://example.com');
# Prepare body
You can’t perform that action at this time.