Skip to content

Instantly share code, notes, and snippets.

@niczero
niczero / what_we_need_from_a_job_queue.txt
Last active October 12, 2022 14:56
Introduction to Resque
From https://github.com/blog/542-introducing-resque
We are constantly overloaded and rely very, very heavily on our queue. If it’s
backed up, we need to know why. We need to know if we can fix it. We need
workers to not get stuck and we need to know when they are stuck.
We need to see what the queue is doing. We need to see what jobs have failed.
We need stats: how long are workers living, how many jobs are they processing,
how many jobs have been processed total, how many errors have there been, are
errors being repeated, did a deploy introduce a new one?
@niczero
niczero / gist:7355035
Created November 7, 2013 14:04
Show defined objects in package 'main'
perl -M... -E'say $_, q{ : }, ${main::}{$_} for keys %{main::}'
@niczero
niczero / database one-liners
Last active December 27, 2015 16:29
Select database values from the commandline
perl -MMojar::Mysql::Connector=cnfdir,data,cnf,tester_localhost,-dbh,1
-E'say join q{, }, main->dbh->selectrow_array(q{SELECT 1,2,3})'
@niczero
niczero / Ideas for monitoring
Last active December 29, 2015 15:19
Ramblings on monitoring
# Mnm
## Cache locally
Want to buffer all stats locally on the source (ie client) box. This could be via rrdtools or collectd or bespoke files (eg series of tsv). Collectd would be an obvious choice if this resource was shared, but want to continue collecting even when net is down. Undecided whether to collect all stats in one global 'file' or have one 'file' per stat. It would be nice if this was a priority queue but that's probably an overcomplication at this stage.
## Connect minimally
Would rather have a single connection to the db and pipe a sequence of queries through that. Perhaps this runs from a daemon and so the connection only closes when (a) the server kicks it off, (b) the server is completely twisted, or (c) the daemon restarts (or all three).
@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;