Skip to content

Instantly share code, notes, and snippets.

View TristinDavis's full-sized avatar

Tristin Davis TristinDavis

  • Thrivent Financial
  • Arkansas, USA
  • 01:49 (UTC -05:00)
View GitHub Profile
#!/usr/bin/perl
use Mojolicious::Lite;
get '/' => { message => '' } => 'index';
post '/' => sub {
my $self = shift;
# getting params
my $email = $self->param('email') || '';
use Mojolicious::Lite;
use EV;
use AnyEvent;
use AnyEvent::Util;
get '/' => sub {
my $self = shift;
# Run Perl oneliner in separate process and capture STDOUT
fork_call {
use strict;
use warnings;
use IO::Async::Channel;
use IO::Async::Loop;
use IO::Async::Routine;
my $loop = IO::Async::Loop->new();
{
package PiffHop;
use strict;
use warnings;
use base 'Mojolicious';
# This method will run once at server start
sub startup {
my $self = shift;
@TristinDavis
TristinDavis / myapp-validationclass-example.pl
Created November 16, 2012 01:40
Validation-Class Basics
package MyApp::Validation;
use Validation::Class;
use base 'Validation::Class';
# a validation rule
field 'login' => {
label => 'user login',
error => 'login invalid',
validation => sub {
@TristinDavis
TristinDavis / myapp-validationclass-example.pl
Created November 16, 2012 01:40
Validation-Class Basics
package MyApp::Validation;
use Validation::Class;
use base 'Validation::Class';
# a validation rule
field 'login' => {
label => 'user login',
error => 'login invalid',
validation => sub {
#!/usr/bin/env perl
use common::sense;
use lib qw(../.. /tk/lib /tk/mojo2/lib);
use ojo;
use Util;
use Unicode::Normalize 'NFD';
use Data::Dumper;
my $conf = {
use Mojolicious::Lite;
get '/tasks' => sub {
my $self = shift;
$self->stash(
tasks => [
map { [ split /\s+/ ] }
split /\n/, qx(ps axh -o comm,stat,\%cpu,nice,pid,rss,user)
]
@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: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 = {};