Skip to content

Instantly share code, notes, and snippets.

View bfaist's full-sized avatar

Bob Faist bfaist

View GitHub Profile
@bfaist
bfaist / job_info example
Last active August 5, 2016 18:10
Minion::Command::minion::jobx examples
$./script/app minion jobx 1853
{
"args" => [
"/some/file"
],
"attempts" => 1,
"children" => [],
"created" => "Wed Aug 3 15:05:00 2016",
"delayed" => "Wed Aug 3 15:05:00 2016",
"finished" => "Wed Aug 3 15:05:26 2016",
$ perl test_ordered_hash get /
[Fri Jun 24 11:24:01 2016] [debug] GET "/"
[Fri Jun 24 11:24:01 2016] [debug] Routing to a callback
[Fri Jun 24 11:24:01 2016] [debug] 200 OK (0.000592s, 1689.189/s)
{
"result" : {
"counter" : "123"
},
"number" : {
"num" : "55"
$perl t/pg_list_jobs.t
NOTICE: drop cascades to 6 other objects
DETAIL: drop cascades to table minion_test.mojo_migrations
drop cascades to table minion_test.minion_jobs
drop cascades to table minion_test.minion_workers
drop cascades to type minion_test.minion_state
drop cascades to table minion_test.minion_jobs column state
drop cascades to function minion_test.minion_jobs_notify_workers()
DBI connect('dbname=sam2_dev;host=bmipgsqld1.chmcres.cchmc.org;port=5432','srv_sam_dev',...) failed: FATAL: remaining connection slots are reserved for non-replication superuser connections at /usr/local/share/perl5/Mojo/Pg.pm line 80
@bfaist
bfaist / basic.t
Created May 27, 2016 12:45
Test::Mojo sleep test
use Mojo::Base -strict;
use Test::More;
use Test::Mojo;
my $t = Test::Mojo->new('SleepTest');
$t->ua->inactivity_timeout(0);
for(my $i = 0; $i < 10; $i++) {
@bfaist
bfaist / Audio.pm
Created February 29, 2016 14:32
iOS Audio File and POST to Mojolicious Web Service
package MyApp::Controller::Audio;
use Mojo::Base 'Mojolicious::Controller';
sub save {
my $self = shift;
# get contents of the audio upload in memory
my $upload_audio_asset = $self->tx->req->content->asset;
@bfaist
bfaist / gist:a36dc00f8b7fa8baa870
Created February 22, 2016 20:00
Test POST of Audio File
my $audio_asset = Mojo::Asset::File->new(path => './t/test_audio.wav');
my $audio_content = $audio_asset->slurp;
$t = $t->post_ok('/audio' => $audio_content)->status_is(200);
#!/usr/bin/env perl
use Mojo::UserAgent;
use Mojo::JSON qw/encode_json/;
my $token = 'NOT_A_TOKEN';
my $ws_url = 'wss://stream.watsonplatform.net/speech-to-text/api/v1/recognize?watson-token=' . $token . '&model=en-US_BroadbandModel';
my $ua = Mojo::UserAgent->new();
use Mojolicious::Lite;
# Simple plain text response
get '/' => {text => 'I :hearts: Mojolicious!'};
# Route associating "/time" with template in DATA section
get '/time' => 'clock';
# Scrape information from remote sites
get '/title' => 'title';