Skip to content

Instantly share code, notes, and snippets.

@preaction
preaction / Intro-XS-CXX.html
Created March 22, 2012 07:41
Intro to XS/C++
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Intro to XS/C++</title>
<!-- metadata -->
<meta name="generator" content="S5" />
<meta name="version" content="S5 1.2a2" />
<meta name="author" content="Doug Bell" />
<meta name="company" content="Double Cluepon Software Corp." />
In <http://boston.conman.org/2009/11/05.1>, “The dinosaur that I am”,
Sean Conner (spc476) suggests a sort of silly bare-metal problem...
> to most programmers, even a simple text editor is a crutch.
>
> Imagine being given a 1982 era IBM PC with a floppy drive and a
> single disk that contains a bootable MS-DOS system with IO.SYS,
> MSDOS.SYS and COMMAND.COM (the minimum required to boot to a usable
> (for various values of “usable”) system at the time) and a stack of
@preaction
preaction / broker.pl
Last active November 20, 2021 08:10
A simple message broker using Mojolicious WebSockets
#!/usr/bin/env perl
# ABSTRACT: A simple message broker using Mojolicious WebSockets
# USAGE: ./socket.pl daemon
#
# Try the demo and read the explanation on the page before reading the code.
#
# Copyright 2015 Doug Bell (<preaction@cpan.org>)
#
# This is free software; you can redistribute it and/or modify it under
# the same terms as the Perl 5 programming language system itself.
@preaction
preaction / blog-post-1.markdown
Last active July 7, 2021 12:28
Static Site Generator with Yancy
title published
A Blog Post
2021-03-21

This will appear in the blog because it has a published field in the frontmatter.

@preaction
preaction / query.sql
Created June 4, 2021 18:30
Minion Backend queries by function
-- stats()
EXPLAIN SELECT SUM(job.id IS NOT NULL) AS is_active
FROM minion_workers worker
LEFT JOIN minion_jobs job ON worker.id = job.worker AND job.state = 'active'
GROUP BY worker.id;
EXPLAIN SELECT state, COUNT(state) AS jobs, SUM(`delayed` > NOW()) AS `delayed`
FROM minion_jobs
GROUP BY state;
@preaction
preaction / Any.pm
Last active February 17, 2021 19:49
Log::Any v2
package Log::Any;
=head1 SYNOPSIS
### Basic use
# Get a logger that logs to STDERR
use Log::Any;
my $log = Log::Any->new;
# Shortcut
sub register( $self, $site ) {
$site->on( build => sub( $event ) {
for my $page ( $event->pages->@* ) {
$page->dom->find( 'img[src$=.mp3]' )->each( sub( $el ) {
$el->replace( '<audio controls><source type="audio/mp3" src="%s"></audio>', $el->attr( 'src' ) );
} );
}
} );
}
package Yancy::Backend::DBI;
use Mojo::Base -base, -signatures;
use Yancy::Util qw( fill_brackets );
use SQL::Abstract;
my %MAP = (
# schema_name => mapping
# Mapping can be...
# { table => $table_name } # Standard SQL from SQL::Abstract
@preaction
preaction / nginx.conf
Created July 19, 2020 02:31
nginx docker config
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
my $schema = $app->yancy->schema;
for my $key ( keys %$schema ) {
my $props = $schema->{ $key }{ properties };
$schema->{ $key }{ 'x-list-columns' } = [ grep { $props->{$_}{format} ne 'textarea' } keys %$props ];
}