Skip to content

Instantly share code, notes, and snippets.

View TristinDavis's full-sized avatar

Tristin Davis TristinDavis

  • Thrivent Financial
  • Arkansas, USA
  • 09:06 (UTC -05:00)
View GitHub Profile
@TristinDavis
TristinDavis / gist:4082910
Created November 16, 2012 00:56
Mojolicious DBIx-Class Plugin
package Mojolicious::Plugin::Dbic;
use Mojo::Base 'Mojolicious::Plugin';
use DBIx::Class;
use DBIx::Class::Schema::Loader;
DBIx::Class::Schema::Loader->naming('v7');
use constant DEBUG => $ENV{MOJO_CONFIG_DEBUG} || 0;
my $schemas = {};
@TristinDavis
TristinDavis / index.pl
Created November 16, 2012 00:59 — forked from dvinciguerra/index.pl
Mojolicious::Lite and Ajax Example
#!/usr/bin/env perl
use DateTime;
use Mojolicious::Lite;
get '/' => 'index';
get '/service/datetime' => sub {
my $self = shift;
my $dt = DateTime->now;
@TristinDavis
TristinDavis / gist:4082944
Created November 16, 2012 01:00 — forked from sharifulin/gist:292838
Mojo uploads
#!/usr/bin/env perl
use lib '../mojo/lib';
BEGIN { $ENV{MOJO_TMPDIR} = 'tmp/upload' };
use Mojolicious::Lite;
use Data::Dumper;
get '/' => 'form';
post '/' => sub {
@TristinDavis
TristinDavis / JSON.pm
Created November 16, 2012 01:01 — forked from xantus/JSON.pm
MojoX::JSON
package MojoX::JSON;
use Mojo::JSON;
our $SINGLETON;
BEGIN {
# install JSON::XS if you can!
eval 'use JSON();';
eval ( $@ ? 'sub HAS_JSON(){ 0 }' : 'sub HAS_JSON(){ 1 }' );
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
use Data::UUID;
use DBI;
use Time::Piece;
use Mojolicious::Lite;
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
use Data::UUID;
use DBI;
use Time::Piece;
use Mojolicious::Lite;
#!/usr/bin/env perl
use Mojolicious::Lite;
my $use_auth = 1; # with auth enabled..
my ( $user, $pass ) = qw/user password/;
if ($use_auth) { plugin 'basic_auth'; }
get '/' => sub { my $self = shift; $self->redirect_to('/upload'); };
get '/upload' => sub {
my $self = shift;
@TristinDavis
TristinDavis / gist:4083031
Created November 16, 2012 01:17 — forked from sharifulin/gist:335531
Nested layouts for the Mojolicious
#!/usr/bin/env perl
use Mojolicious::Lite;
get '/' => 'index';
get '/ok' => 'index_ok';
use Test::More;
plan tests => 6;
@TristinDavis
TristinDavis / gist:4083039
Created November 16, 2012 01:19 — forked from sharifulin/gist:335531
Nested layouts for the Mojolicious
#!/usr/bin/env perl
use Mojolicious::Lite;
get '/' => 'index';
get '/ok' => 'index_ok';
use Test::More;
plan tests => 6;
@TristinDavis
TristinDavis / gist:4083119
Created November 16, 2012 01:32 — forked from sharifulin/gist:636577
Include and process for Mojolicious app
#!/usr/bin/env perl
use lib 'lib';
package Mojolicious::Plugin::IncludeHelpers;
use strict;
use warnings;
use base 'Mojolicious::Plugin';
use Data::Dumper;