Skip to content

Instantly share code, notes, and snippets.

package Rewriter;
# ABSTRACT: Track and retry batches of writes in database transactions
=head1 SYNOPSIS
my $rewriter = Rewriter->new(
dsn => 'dbi:SQLite:test.db',
user => 'user',
pass => 'password',
query => {
Viewport argument value "device-width;" for key "width" is invalid, and has been ignored. Note that ';' is not a separator in viewport values. The list should be comma-separated.
Viewport argument value "1.0;" for key "initial-scale" was truncated to its numeric prefix. Note that ';' is not a separator in viewport values. The list should be comma-separated.
Viewport argument value "1.0;" for key "maximum-scale" was truncated to its numeric prefix. Note that ';' is not a separator in viewport values. The list should be comma-separated.
Viewport argument value "1.0;" for key "minimum-scale" was truncated to its numeric prefix. Note that ';' is not a separator in viewport values. The list should be comma-separated.
Viewport argument value "no;" for key "user-scalable" is invalid, and has been ignored. Note that ';' is not a separator in viewport values. The list should be comma-separated.
Viewport argument key "target-densitydpi" not recognized and ignored.
@preaction
preaction / gist:a7589a1e64f43f2a9ed05947c7ea787d
Created September 13, 2016 05:29
Percentages of percentages
Given:
X > 0
Y > 0
(X/100) * Y = (X/100) * (X/100) * Y
Solve for X
use Mojolicious::Lite;
sub named_begin {
my ( $name, $delay, $filter ) = @_;
my $begin = $delay->begin( 0 );
return sub { $begin->( $name => $filter->( @_ ) ) };
}
get '/' => sub {
@preaction
preaction / cascade.markdown
Created August 16, 2016 18:25
WIP blog post about CSS specificity

CSS Cascade and Specificity (or: My CSS isn't being applied to my markup!)

CSS is a declarative language: You declare that any elements which match a given CSS selector (the part before the curly braces) should apply the property values inside the rule (the part inside curly braces). But what happens when multiple selectors (and therefore multiple rules) apply to the same element? Or, how do you override styles for a particular element that you do not want? Why not just use !important to make sure that what we want is being set?

The steps that CSS takes in deciding which properties are chosen are well-defined, if you want to read the CSS specification on cascading, which is how the rules from different stylesheet types get layered and applied, and its companion CSS specification on specificity, which is how a CSS selector is ranked in importance. Since you're not a browser vendor, it might be a bit easier to read on.

When we're developing a web page, which CSS rules override which other CSS rul

use v5.24;
use warnings;
use Log::Any;
use Log::Any::Adapter qw( Stdout );
sub add_tags {
my ( $cat, $lvl, $msg ) = @_;
return "$msg foo=bar;baz=fuzz";
use feature qw( say );
use Beam::Wire;
my $wire = Beam::Wire->new( file => 'config.yml' );
say for @{ $wire->get( 'email' ) };
#!/usr/bin/perl
# PODNAME: weave.pl
=head1 SYNOPSIS
weave.pl [--license <license>] [--version <version>] [--author <author>] <file>
weave.pl -h|--help
=head1 DESCRIPTION
use strict;
use warnings;
use Test::More;
use Mojo::EventEmitter;
use Beam::Emitter;
use Test::LeakTrace;
no_leaks_ok {
my $m = Mojo::EventEmitter->new;
Mojo::IOLoop::Delay->new->steps(
sub {
my ( $delay ) = @_;
$db->query( '...', cb => $delay->begin );
$db->query( '...', cb => $delay->begin );
},
sub {
my ( $delay, @results ) = @_;
$c->render( ... );
},