Skip to content

Instantly share code, notes, and snippets.

@nklatt
nklatt / 0 Laravel Backpack CRUD entry list filtering based on related rows
Last active June 16, 2023 21:50
Laravel Backpack CRUD entry list filtering based on related rows
Site allows members (people) to register for programs. People belong to one or
more Accounts. Programs are divided up into Seasons.
When viewing the entity list page for Accounts, we want to be able to filter the
list based on the seasons the people within each account are registered for.
E.g., we often want to show only Accounts which have People registered for
Programs within the current Season.
Pertinent database tables and columns:
accounts: id
@nklatt
nklatt / 0 intro.txt
Last active July 1, 2023 15:13
Import Google Maps polygons into MySQL
We have a client that ships from multiple warehouses using zones to determine
pricing. They maintain the zones in a Goole Maps document. We are creating a
front end that clients can enter their address and we'll show them what their
shipping options are. We will have the client export their zones as a KML
file and we'll import it into a MySQL database and use ST_Contains to find
the shipping zone(s) customers are in. (They can only be in one zone for any
given warehouse but may be within range of multiple warehouses.)
One thing to point out is there is confusion about the order of latitude and
longitude. Mathematically, it is naturally ordered "longitude, latitude" but
@nklatt
nklatt / dimension-input.html
Last active February 6, 2024 16:22
HTML/JS regex pattern to match one of: whole number, float, fraction or whole number <space> fraction
<input pattern="/^(?:(\d+\/[1-9]\d*)|(\d*(?:(\s\d+\/[1-9]\d*)|\.\d+)?))$/">
<!--
(?: => non-capturing group, EITHER
(\d+\/[1-9]\d*) => any number of digits followed by a slash then any number of digits not beginning with 0 (fraction)
| => OR
(\d*(?: => zero or more digits followed by non-capturing group, EITHER
(
\s => a space
\d+ => any number of digits
\/ => a slash