Skip to content

Instantly share code, notes, and snippets.

View andrewrcollins's full-sized avatar

Andrew Collins andrewrcollins

View GitHub Profile
@andrewrcollins
andrewrcollins / trim.awk
Created January 11, 2012 04:22
ltrim(), rtrim(), and trim() in awk
function ltrim(s) { sub(/^[ \t\r\n]+/, "", s); return s }
function rtrim(s) { sub(/[ \t\r\n]+$/, "", s); return s }
function trim(s) { return rtrim(ltrim(s)); }
BEGIN {
# whatever
}
{
# whatever
}
END {
@andrewrcollins
andrewrcollins / mix_tint_tone_shade.php
Last active February 24, 2024 18:52
Color Mixing, Tint, Tone, and Shade in PHP
<?php
/**
* mix
*
* @param mixed $color_1
* @param mixed $color_2
* @param mixed $weight
*
* @return void
@andrewrcollins
andrewrcollins / warm-up.sh
Created October 29, 2023 16:28
Perform "warm up" on MySQL database tables.
#!/bin/sh
#
# warm-up.sh
#
# Perform "warm up" on database tables.
#
#####
@andrewrcollins
andrewrcollins / ssh-pool.sh
Created October 29, 2023 16:31
Implements connection pool for SSH connections.
#!/bin/sh
#
# ssh-pool.sh
#
# Implements connection pool for SSH connections.
#
##### start script name
@andrewrcollins
andrewrcollins / mysql-pool.sh
Created October 29, 2023 16:36
Implements connection pool for MySQL connections.
#!/bin/sh
#
# mysql-pool.sh
#
# Implements connection pool for MySQL connections.
#
##### start script name
@andrewrcollins
andrewrcollins / loans.sql
Created January 11, 2012 04:15
MySQL Loan Origination and Accurate Payment Stream Calculations
-- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-- stored procedures for loan origination and payment streams
-- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
DROP FUNCTION IF EXISTS fvif$$
CREATE FUNCTION fvif
(
@andrewrcollins
andrewrcollins / soybeans.txt
Created February 15, 2020 00:38
Soybeans: Global Production and Usage
'
' Soybeans: Global Production and Usage
'
' Build a Sankey Diagram
' http://sankeymatic.com/build/
'
' SankeyMATIC Manual
' http://sankeymatic.com/manual/
'
' node colors
@andrewrcollins
andrewrcollins / dates_times.sql
Created January 11, 2012 04:01
MySQL Dates and Times
-- ===================================================================
-- Various MySQL stored procedures for handling dates,
-- as well as populating date and time dimensions.
-- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
--
-- Date Dimension
--
@andrewrcollins
andrewrcollins / eyewitness.io
Created January 2, 2018 18:18
eyewitness.io
https://eyewitness.io/
INSERT INTO `person` (`id`, `name`, `birthday`, `height`, `wears_glasses`) VALUES (NULL, 'Adrian Stubblefield', '2013-09-11', 57, 0);
INSERT INTO `person` (`id`, `name`, `birthday`, `height`, `wears_glasses`) VALUES (NULL, 'Marcus Duck', '1966-08-22', 77, 0);
INSERT INTO `person` (`id`, `name`, `birthday`, `height`, `wears_glasses`) VALUES (NULL, 'Ngan Rome', '1974-11-29', 78, 0);
INSERT INTO `person` (`id`, `name`, `birthday`, `height`, `wears_glasses`) VALUES (NULL, 'Marguerita Poythress', '1966-07-15', 63, 0);
INSERT INTO `person` (`id`, `name`, `birthday`, `height`, `wears_glasses`) VALUES (NULL, 'Millie Pipes', '1975-06-24', 67, 0);
INSERT INTO `person` (`id`, `name`, `birthday`, `height`, `wears_glasses`) VALUES (NULL, 'Merlin Lacoste', '2007-11-05', 77, 1);
INSERT INTO `person` (`id`, `name`, `birthday`, `height`, `wears_glasses`) VALUES (NULL, 'Kam Benware', '2013-07-15', 55, 1);
INSERT INTO `person` (`id`, `name`, `birthday`, `height`, `wears_glasses`) VALUES (NULL, 'Kristal Dement', '1975-09-24', 76