Skip to content

Instantly share code, notes, and snippets.

View TristinDavis's full-sized avatar

Tristin Davis TristinDavis

  • Thrivent Financial
  • Arkansas, USA
  • 04:36 (UTC -05:00)
View GitHub Profile
package WWW::FGen;
use WWW::Mechanize;
# constructor
sub new {
my $class = shift;
return bless {
_mechanize => WWW::Mechanize->new( agent => 'Perl of Love' ),
_url => 'http://mendel.cs.rhul.ac.uk/mendel.php?topic=fgen-file',
#!/usr/bin/env perl
use Mojolicious::Lite;
use Test::Mojo;
use Test::More tests => 2;
get '/first' => sub {
shift->redirect_to('second');
};
@sharifulin
sharifulin / lj_export.pl
Created August 8, 2011 09:51
Export LJ posts to MongoDB using Mojolicious
#!/usr/bin/env perl
use common::sense;
use Mojo::IOLoop;
use Mojo::UserAgent;
use MongoDB;
use Data::Dumper;
my $ua = Mojo::UserAgent->new;
#!perl
package TestApp;
use Mojolicious::Lite;
get '/one/:foo' => [ foo => [qw/bar barfly/] ] => sub { shift->render_text('hi') };
get '/two/:foo' => [ foo => qr[bar|barfly] ] => sub { shift->render_text('hi') };
package main;
use Test::More tests => 8;
package App::Index;
use App::Base -controller, with => ['App::News', 'App::Book', 'App::Audio'];
sub main {
my $self = shift;
my $limit = $self->conf('limit')->{index};
$self->render('index',
news => $self->news->_last(limit => $limit->{news}),
book => $self->book->_list,
@sharifulin
sharifulin / gist:636577
Created October 20, 2010 14:56
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;
@sharifulin
sharifulin / gist:613760
Created October 6, 2010 17:44
Mojo::IOLoop and Mojo::Client
#!/usr/bin/env perl
use lib 'lib';
use Mojo::IOLoop;
use Mojo::Client;
my $loop = Mojo::IOLoop->new;
my $client = Mojo::Client->new; $client->ioloop( $loop );
foo();
#!/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;
@xantus
xantus / JSON.pm
Created August 2, 2010 19:39
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;