Skip to content

Instantly share code, notes, and snippets.

@niczero
niczero / gist:27e20e5de01f00d9ebfb
Last active August 29, 2015 14:01
Comparative installation times: Catalyst, Dancer2, Mojolicious

Comparative Installations

Installation on core perl 5.18.2 via

cpanm -l /tmp/test Package

with all sources cached in .cpanm (to eliminate download times). Parallel times are done using

HARNESS_OPTIONS=j9

@niczero
niczero / FR_Mojo_ExtendsPlusLayout.md
Last active August 29, 2015 14:02
Feature Request: Assignable layouts with extending templates

Summary

Template reuse is awesome, either via extending templates or via layouts. But what about together? A tiny change to rendering allows them to be combined, which makes it even easier to design, manage, and maximise reuse of templates.

Use Case 1: Default layout

The Rendering Guide clearly shows the value of setting a default layout and also the value of template inheritance (using 'extends'), but currently these can't be used together: the default layout is ignored and therefore missing from the rendered output.

Use Case 2: Dynamic layout

@niczero
niczero / term_encoding.sh
Created November 27, 2014 12:55
Test terminal character encoding in a perl one-liner
perl -MMojo::Base=strict -MEncode -E'say qq{$_: }. encode($_, q{Ue: }. chr(220) .q{; Euro: }. chr(8364)) for qw(utf-8 latin1 iso-8859-15 utf-16)'
@niczero
niczero / using character encodings
Created November 27, 2014 14:46
How to handle encodings on input/output
open my $handle, '<:encoding(UTF-8)', $file;
open my $handle, '<:encoding(iso-8859-1)', $file;
open my $handle, '<', $file;
binmode $handle, ':encoding(UTF-8)';
use open ':encoding(UTF-8)';
use open ':encoding(iso-8859-1)';
use open ':locale';
@niczero
niczero / clientside_markdown.md
Last active August 29, 2015 14:21
Brief overview of opensource tools for client-side markdown
@niczero
niczero / basic.t
Created July 5, 2015 13:47
Making a fall-thru for a route condition
use Mojo::Base -strict;
use Test::More;
use Test::Mojo;
use FindBin;
require "$FindBin::Bin/../x";
my $t = Test::Mojo->new;
@niczero
niczero / git-migrate.sh
Created November 11, 2015 14:28
Extract a subtree of git repo to make a new repo
# Want to remove all reference to lib/* except lib/Minion/Backend/*
git filter-branch --tag-name-filter cat \
--index-filter 'git rm --cached -qr -- lib && git reset -q $GIT_COMMIT -- lib/Minion/Backend t' \
--prune-empty \
-- --all
@niczero
niczero / build_percona.md
Last active November 19, 2015 13:25
How to build and patch Percona's MySQL on Debian

Download

wget https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-5.6.27-75.0/source/debian/percona-server-5.6_5.6.27-75.0-1.debian.tar.gz
wget https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-5.6.27-75.0/source/debian/percona-server-5.6_5.6.27-75.0-1.dsc
wget https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-5.6.27-75.0/source/debian/percona-server-5.6_5.6.27-75.0-1_source.changes
wget https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-5.6.27-75.0/source/debian/percona-server-5.6_5.6.27-75.0.orig.tar.gz
apt-get --only-source build-dep percona-server-5.6
dpkg-source -x percona-server-5.6_5.6.27-75.0-1.dsc
cd percona-server-5.6-5.6.27-75.0
@niczero
niczero / word-parse.pl
Created November 23, 2015 10:17 — forked from ingydotnet/word-parse.pl
Parse words from a string of smushed together words with a single regexp
#!/usr/bin/env perl
use strict;
# Get all the letters from stdin:
my $input = do {local $/; <>};
$input =~ s/[^a-zA-Z]//g;
# All 3+ letter English words, longest to shortest:
my @long = grep {length > 2}
sort {length $b <=> length $a}
@niczero
niczero / testing_templates.sh
Created November 25, 2015 10:55
Testing Mojo::Template
MOJO_TEMPLATE_DEBUG=1 perl -Mojo -E'my $c = app->build_controller; $c->render_to_string(inline => "")'