Skip to content

Instantly share code, notes, and snippets.

View SysPete's full-sized avatar

Peter Mottram SysPete

View GitHub Profile
# In your app class:
__PACKAGE__->config(
'Plugin::PrometheusTiny' => {
metrics => [
{
name => 'http_request_count_by_route',
help => 'HTTP request count by route',
type => 'counter',
},
validator( $params, $rules, @additional_args? )
Where:
$params is a hash reference of parameters to be validated.
$rules is one of:
* the name of a rule sub if you are using "rules_class"
* the name of a rule file if you are using "rules_dir"
=head3 Config becomes immutable
The plugin's C<config> attribute is loaded lazily on the first call to
C<config>. After this first call C<config> becomes immutable so you cannot
do the following in a test:
use Dancer2;
use Dancer2::Plugin::FooBar;
set plugins => {
@SysPete
SysPete / update.pl
Created February 15, 2016 14:10
coverage update script
#!/bin/bash
exec 2>&1
#set -e
set -x
export PATH="/usr/bin:/usr/sbin..:/bin:/usr/sbin:/usr/local/bin"
COVER_PERL="perl-5.20.3"
source /smoker/.bash_profile
# configuration file for development environment
paypal:
id: <praypalid>
password: <pwd>
signature: <sig>
sandbox: 1
returnurl: https://<yourdomain>/paypal/getrequest
cancelurl: https://<yourdomain>/cart
currencycode: EUR
@SysPete
SysPete / app.psgi
Created May 29, 2015 16:36
app.psgi for dev work
#!/usr/bin/env perl
use Plack::Builder;
use Plack::Middleware::Debug::DBIC::QueryLog;
use Plack::Middleware::DBIC::QueryLog;
use Dancer;
use Dancer::Plugin::DBIC;
use Dancer::Handler;
use lib 'lib';
use DanceShop;
@SysPete
SysPete / a thing of beauty
Last active August 29, 2015 14:14
new interchange6 product listing query
SELECT "product"."sku", "product"."name", "product"."uri", "product"."price",
"product"."short_description", (
SELECT COUNT( * )
FROM "products" "variants_alias"
WHERE "variants_alias"."canonical_sku" = "product"."sku"
), COALESCE( (
SELECT AVG( "message"."rating" )
FROM "products" "canonical_alias"
JOIN "product_reviews" "_product_reviews"
ON "_product_reviews"."sku" = "canonical_alias"."sku"
@SysPete
SysPete / Photo.pm
Created January 21, 2015 11:42
Photo.pm
package MidiPhotoBank::Photo;
use Cache::FileCache;
use Dancer ':syntax';
use Dancer::Plugin::Database;
use File::Type;
use HTTP::Date qw(time2str);
use Imager;
our $VERSION = '0.1';
SELECT "product"."sku", "product"."name", "product"."uri", "product"."price", "product"."short_description",
CASE WHEN COUNT( variants.sku ) > 0 THEN 1 ELSE 0 END,
CASE WHEN COUNT( variants.sku ) > 0
THEN
CASE WHEN COALESCE( MIN( current_price_modifiers_2.price ), MIN( variants.price ) ) < MIN( variants.price )
THEN COALESCE( MIN( current_price_modifiers_2.price ), MIN( variants.price ) )
ELSE MIN( variants.price )
END
ELSE COALESCE( MIN( current_price_modifiers.price ), product.price )
END AS selling_price,
@SysPete
SysPete / dev.pl
Created December 31, 2014 11:43
dev.pl for using querylog middleware
#!/usr/bin/env perl
use Plack::Builder;
use Plack::Middleware::Debug::DBIC::QueryLog;
use Plack::Middleware::DBIC::QueryLog;
use Dancer;
use Dancer::Plugin::DBIC;
use Dancer::Handler;
use lib 'lib';
use DanceShop;