Skip to content

Instantly share code, notes, and snippets.

View TristinDavis's full-sized avatar

Tristin Davis TristinDavis

  • Thrivent Financial
  • Arkansas, USA
  • 09:49 (UTC -05:00)
View GitHub Profile
@TristinDavis
TristinDavis / TestMojoCookies
Created December 2, 2012 21:07 — forked from spiros/TestMojoCookies
Test::Mojo methods for cookie checking
=head2 has_cookie
Returns 1 if cookie is found irrespective of value.
$rv = $t->has_cookie( $name, $url );
=cut
sub has_cookie{
my $self = shift;
#!/usr/bin/env perl
# put.pl
# This works :
# ./put.pl daemon
# mojo get --method PUT --content 'foo' --header 'X-Disk: /tmp' http://localhost:3000/here
# This does not :
# ./put.pl get --method PUT --content 'foo' --header 'X-Disk: /tmp' /here
#!/usr/bin/env perl
# put.pl
# This works :
# ./put.pl daemon
# mojo get --method PUT --content 'foo' --header 'X-Disk: /tmp' http://localhost:3000/here
# This does not :
# ./put.pl get --method PUT --content 'foo' --header 'X-Disk: /tmp' /here
@TristinDavis
TristinDavis / MojoLite-hook_and_test.pl
Created November 19, 2012 00:35 — forked from bduggan/gist:1355071
A nice short example of using Test::Mojo and how to grab events.
#!/usr/bin/env perl
# put.t
use Test::More tests => 3;
use Mojolicious::Lite;
use Test::Mojo;
$ENV{MOJO_MAX_MEMORY_SIZE} = 2; # Force temp files.
$ENV{MOJO_TMPDIR} = "/nosuchdir"; # test setting tempdir dynamically
@TristinDavis
TristinDavis / Mojo::IOLoop-coro-bench.pl
Created November 18, 2012 05:07 — forked from kraih/coro-bench.pl
An example showing how to use a Mojo::IOLoop.
#!/usr/bin/env perl
use Mojolicious::Lite;
use Coro;
use Mojo::IOLoop;
Mojo::IOLoop->recurring(0 => sub {cede});
hook around_dispatch => sub {
my $next = shift;
async { $next->() };
@TristinDavis
TristinDavis / perl: Mojolicious
Created November 17, 2012 18:56
RPM spec file for Mojolicious
Name: perl-Mojolicious
Version: 3.56
Release: 1%{?dist}
Summary: A next generation web framework for Perl
License: Artistic 2.0
Group: Development/Libraries
URL: http://mojolicious.org/
Source0: http://search.cpan.org/CPAN/modules/by-module/Mojolicous/Mojolicious-%{version}.tar.gz
BuildArch: noarch
BuildRequires: perl >= 0:5.010, perl(ExtUtils::MakeMaker)
@TristinDavis
TristinDavis / Perl: Mojolicious
Created November 17, 2012 18:52
Flash/Stash example
use Mojo::ByteStream;
app->helper(alerts => sub {
my $c = shift;
my $html = '';
for my $message (qw|success info error|) {
my $css = "alert alert-$message";
if($c->flash($message)) {
$html .= $c->tag('div', class => $css, $c->flash($message));
@TristinDavis
TristinDavis / Perl: Mojolicious
Created November 17, 2012 18:50
Example of Test::Mojo used to unit test.
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More tests => 6;
use Test::Mojo;
my $url = 'http://localhost/~rhaen/index.html';
my $t = Test::Mojo->new;
@TristinDavis
TristinDavis / mojo_lite_ioasync.pl
Created November 17, 2012 16:41 — forked from kraih/ioasync.pl
Mojo::Lite Ex. using IO::Async
use Mojolicious::Lite;
use EV;
use IO::Async::Process;
use IO::Async::Loop::EV;
my $loop = IO::Async::Loop::EV->new;
get '/' => sub {
my $self = shift;
@TristinDavis
TristinDavis / ioasync.pl
Created November 17, 2012 16:40 — forked from kraih/ioasync.pl
use Mojolicious::Lite;
use EV;
use IO::Async::Process;
use IO::Async::Loop::EV;
my $loop = IO::Async::Loop::EV->new;
get '/' => sub {
my $self = shift;