Skip to content

Instantly share code, notes, and snippets.

# this vhost config sends my custom 404 page on not-found errors. but the `return 503` causes nginx
# to send its own built-in error page. why is that? how to change this config so it sends my 503.html?
server {
listen 80;
server_name tarfu.example.com;
root /var/www/v2/doc_root/web;
if ($maintenance = 1) {
return 503;
}
@tom--
tom-- / 1-expected.txt
Created September 10, 2019 01:05
Example of Sphinx collation
MariaDB [(none)]> create schema test collate utf8_general_ci;
Query OK, 1 row affected (0.000 sec)
MariaDB [(none)]> set names utf8;
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]> use test
Database changed
MariaDB [test]> create table test (id int not null primary key, name varchar(99) not null);
Query OK, 0 rows affected (0.002 sec)
@tom--
tom-- / automatic-playlist-creation.md
Created November 22, 2018 16:32
FAQ: What happens when Spinitron receives a recognition at 10:01AM and there is no playlist to put it in?

FAQ: What happens when Spinitron receives a recognition at 10:01AM and there is no playlist to put it in?

Answer: Spinitron automatically creates a playlist.

The playlist needs a title, start and end times, and an owner. Spinitron looks at the schedule: Is there a show in today's calendar spanning 10:01? Zero, one or more shows can satisfy this query.

If zero, Spinitron creates a generic playlist without using a show as template and the playlist is owned by the "automation persona". If more than one, having no better criteria, Spinitron chooses the most recently created show. If only one, there is no fuss.

Assuming a show was found, Spinitron copies over the title, start and end times and DJ. But a playlist can have only one DJ and a show can have one or more. If more than one, having no better criteria, Spinitron chooses the most recently created DJ. If only one, there is no fuss.

@tom--
tom-- / a-tcpdump.md
Last active September 28, 2019 21:14

Hexdump traffic over interface I to and from TCP server on port P of host H

tcpdump -p -i I -lttttX 'tcp and ((dst port P and dst host H) or (src port P and src host H))'

in which

  • I is interface name
  • P is port number
  • H is host name or address
@tom--
tom-- / lucy-weight-sweep.md
Last active November 21, 2018 20:59
Lucy 1st bithday weight sweepstakes

Lucy 1st birthday weight sweepstake

Lucy was born, let's say, Nov 21 2017. How much will she weigh (in pounds) on that day 2018? Whoever guesses closest, drinks are on us.

Weight Contestant
38 Tom
42 Ray
45 Nicole
@tom--
tom-- / abc.sls
Last active November 22, 2017 06:54
a:
lorem.ipsum
x:
lorem.dolor
y:
lorem.sit
b:
@tom--
tom-- / orch-update.sls
Last active November 17, 2017 14:12
Salt orchestration—start a container and wait for its minion
start {{ container }}:
salt.function:
- tgt: {{ host }}
- name: lxc.start
- arg:
- {{ container }}
wait for {{ container }} minion:
salt.wait_for_event:
@tom--
tom-- / README.md
Last active October 14, 2017 19:47
Controling a group of daemons and timer jobs with a systemd target

Controling a group of daemons and timer jobs with a systemd target

Scenario

The custom web application My App, in addition to its web server request-driven work, has three daemons (able, baker and charlie) and three jobs (dog, easy and fox) that run (cron-like) on a pre-defined schedule.

Requirements

<?php
namespace v2\helpers;
use yii\helpers\Console;
/**
* Error code constane names, values, and descriptions are taken from
* OpenBSD's sysexits(3) man page http://man.openbsd.org/sysexits
*/
@tom--
tom-- / straight_join.sql
Last active May 20, 2017 21:11
Is a STRAIGHT_JOIN like a LEFT JOIN or like an INNER JOIN? (MySQL)
create table t (
id int primary key,
r_id int,
c tinyint(1) default 0
);
create table r (
id int primary key,
c tinyint(1) default 0