This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open($fh, "<", $path1.$file ) | |
# if path1 fails, try path2 and set missing boolean to 1 | |
or $missing = 1 and open($fh, "<", $path2.$file ) | |
or warn "can't open $file in $path1, $path2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use Mojo::Base -base; | |
use Mojo::Util qw(getopt); | |
use Mojo::File; | |
use Mojo::DOM; | |
getopt 'p|path=s' => \my $path; | |
sub main { | |
# look in xml elements for laserscans that have hashes for names, then rename. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use Mojolicious::Lite; | |
# it turns out a race condition was being caused, that accidentally 'won' every time before - | |
# but the updated Mojolicious made the broken code apparent. This no longer works: | |
get '/' => sub { | |
my $self = shift; | |
$self->render_later; | |
Mojo::IOLoop->subprocess( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
perl C:\Users\yournamehere\myapp\myapp.pl daemon -m production |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# streams $zipfile created in memory (not saved anywhere) | |
# should work similar with Excel::Writer::XLSX | |
# (I generate and return the zip file in a Mojo::IOLoop Subprocess) | |
$self->res->headers->content_disposition( | |
'attachment; filename=' . $filename . '.zip;'); | |
$self->res->headers->content_type('application/zip'); | |
$self->reply->asset(Mojo::Asset::Memory->new->add_chunk($zipfile)); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use Mojolicious::Lite; | |
use Archive::Zip::SimpleZip qw($SimpleZipError); | |
get '/#file' => sub { | |
my $c = shift; | |
# read a file from disk | |
my $file1 = | |
Mojo::Asset::File->new( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Mojolicious::Lite; | |
use Mojo::IOLoop; | |
get '/' => sub { | |
my $c = shift; | |
$c->delay( | |
sub { say 'test1'; Mojo::IOLoop->timer(1 => shift->begin); }, | |
sub { say 'test2'; my $test = 'test'; }, | |
sub { say 'test3'; $c->render(text => 'Hi'); }, | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package MyApp::Model::DBAdmin; | |
use Mojo::Base -base; | |
has 'database'; | |
sub new { bless {}, shift } | |
sub create_table { | |
my ($self, $tablename) = @_; | |
$tablename = "test"; |