Skip to content

Instantly share code, notes, and snippets.

View Akron's full-sized avatar

Nils Diewald Akron

View GitHub Profile
#!/usr/bin/env perl
BEGIN {
unshift(@INC,
'home/me/cgi-bin/lib' # absolute path
};
use Mojolicious::Lite;
my $count = 0;
@Akron
Akron / gist:2567746
Created May 1, 2012 12:54
Hynotoad Example
#!/usr/bin/env perl
use Mojolicious::Lite;
our $counter = 0;
app->secret('kashkgfsjgnscjzgang');
app->config({
hypnotoad => {
listen => ['http://*:8765'],
@Akron
Akron / gist:2698091
Created May 14, 2012 23:40
Mojo::URL-Behaviour
#!/usr/bin/env perl
use Mojo::URL;
my $url = Mojo::URL->new('http://example.com/?action=test');
my $url2 = Mojo::URL->new('broker.js?foo=bar');
$url->path($url2->path);
$url->query($url2->query);
# http://example.combroker.js?foo=bar
# ^ ???
#!/usr/bin/env perl
use Mojo;
my $ua = Mojo::UserAgent->new;
$ua->max_redirects(5);
my $base_url ='http://api.powerhousemuseum.com/api/v1/category/xml/';
my $api_key = 'xxx';
my $base_rest_url = Mojo::URL->new($base_url)->query({ api_key => $api_key});
#!/usr/bin/env perl
use Mojo;
use Mojo::Base -strict;
my $ua = Mojo::UserAgent->new;
$ua->max_redirects(5);
my $domain = 'http://api.powerhousemuseum.com';
my $base_url ="$domain/api/v1/category/xml/";
my $api_key = '8fbb61ea34d6f5d';
@Akron
Akron / gist:3811025
Created October 1, 2012 11:15
Start App with a script
# test.pl:
#!/usr/bin/env perl
use TestApp;
TestApp->start;
# TestApp.pm:
package TestApp;
use Mojo::Base 'Mojolicious';