Skip to content

Instantly share code, notes, and snippets.

View TristinDavis's full-sized avatar

Tristin Davis TristinDavis

  • Thrivent Financial
  • Arkansas, USA
  • 23:34 (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 = {};
package Mojolicious::Plugin::MicroPipeline::CSSCompressor;
use Mojo::Base 'Mojolicious::Plugin';
use CSS::Compressor 'css_compress';
sub register {
my ($self, $app) = @_;
# Register "css_compressor" filter
$app->filter(css_compressor => sub { css_compress shift });
package Mojolicious::Plugin::Pipeline::CSSCompressor;
use Mojo::Base 'Mojolicious::Plugin';
use CSS::Compressor 'css_compress';
sub register {
my ($self, $app) = @_;
# Register "css_compressor" filter
$app->filter(css_compressor => sub { css_compress shift });
Event Driven Programming
- no blocking
- no polling
- no sleeping
- events and callbacks
- inotify vs stat
- sleep vs timers
- web services
#!/usr/bin/perl
use Mojolicious::Lite;
get '/' => { message => '' } => 'index';
post '/' => sub {
my $self = shift;
# getting params
my $email = $self->param('email') || '';
@dvinciguerra
dvinciguerra / index.pl
Created August 24, 2012 17:09
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;
@larrybotha
larrybotha / A.markdown
Last active December 28, 2022 19:00
Monokai Sidebar Theme | Sublime Text

Sublime Text Monokai Sidebar Theme

A theme for the sidebar in Sublime Text to match the workspace of the Monokai theme.

This theme only modifies the sidebar to better match the Monokai theme, without modifying any of the styling elsewhere defined by Monokai.

File location: Packages/User

For a theme that extends beyond just the sidebar, visit https://gist.github.com/umpirsky/5842174

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;
#!/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->() };
#!/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