Skip to content

Instantly share code, notes, and snippets.

Tom Worster tom--

Block or report user

Report or block tom--

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tom--
tom-- / 1-expected.txt
Created Sep 10, 2019
Example of Sphinx collation
View 1-expected.txt
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 Nov 22, 2018
FAQ: What happens when Spinitron receives a recognition at 10:01AM and there is no playlist to put it in?
View automatic-playlist-creation.md

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.

View a-tcpdump.md

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 Nov 21, 2018
Lucy 1st bithday weight sweepstakes
View lucy-weight-sweep.md

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
View abc.sls
a:
lorem.ipsum
x:
lorem.dolor
y:
lorem.sit
b:
@tom--
tom-- / orch-update.sls
Last active Nov 17, 2017
Salt orchestration—start a container and wait for its minion
View orch-update.sls
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 Oct 14, 2017
Controling a group of daemons and timer jobs with a systemd target
View README.md

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

View gist:0806dc2878d0d80a5f71ca241972f8db
<?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
Is a STRAIGHT_JOIN like a LEFT JOIN or like an INNER JOIN? (MySQL)
View straight_join.sql
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
@tom--
tom-- / slug.php
Last active Nov 25, 2016
Make a slug for an earl in PHP
View slug.php
<?php
function slug(string $string, int $width = 100) : string
{
$string = Normalizer::normalize($string);
$string = trim(preg_replace('/[^\pL\p{Nd}]+/u', ' ', $string));
$string = strtr($string, ' ', '-');
return mb_strimwidth($string, 0, $width, '', 'UTF-8');
You can’t perform that action at this time.