Skip to content

Instantly share code, notes, and snippets.

@ghidinelli
ghidinelli / docker-entrypoint-oncontainerend.bash
Last active April 19, 2023 23:41
Docker entrypoint wrapper runs shutdown tasks before a container exits
#!/bin/bash
# exit if any pipeline exits non-zero
set -e
# capture stdout and stderr
exec 2>&1
if [[ "$CONTAINER_SHUTDOWN_CLEANUP_ENABLE" = true || "$CONTAINER_SHUTDOWN_CLEANUP_ENABLE" = 1 ]]; then
echo "Feature: Enabling shutdown cleanup against ${CONTAINER_SHUTDOWN_CLEANUP_URL:=http://localhost:3000/your/route/to/check/ok_to_shutdown}"
@ryanguill
ryanguill / postgres-pivot.md
Last active June 29, 2022 14:08
Example of postgres pivot using jsonb_object_agg for variable columns in output. To play with this yourself in an online repl, click here: https://dbfiddle.uk/?rdbms=postgres_14&fiddle=39e115cb8afd6e62c0101286ecd08a3f
/*
================================================================================
Pivot example with variable number of columns in the output.
================================================================================

example data is straight forward, imagine a table with a customer identifier, 
an invoice date and an amount.
*/
<!DOCTYPE html>
<html>
<head><title>SOUND</title></head>
<body>
<div>Frequence: <span id="frequency"></span></div>
<script type="text/javascript">
var audioCtx = new (window.AudioContext || window.webkitAudioContext)();
var oscillatorNode = audioCtx.createOscillator();
var gainNode = audioCtx.createGain();
SELECT
	  pri.lorem
	, pri.ipsum
	, pri.dolar orci
	, pri.sit
	, pri.amet
	, CASE
		WHEN erat = 'vitae'
 THEN 'suscipit'
// Lazy (=on-demand) zip()
for (const [i, x] of zip(naturalNumbers(), naturalNumbers())) {
console.log(i, x);
if (i >= 2) break;
}
// Output:
// 0 0
// 1 1
// 2 2
@cvan
cvan / qs.js
Last active February 21, 2024 13:44
get query-string parameters (alternative to `URLSearchParams`)
var queryParams = window.location.search.substr(1).split('&').reduce(function (qs, query) {
var chunks = query.split('=');
var key = chunks[0];
var value = decodeURIComponent(chunks[1] || '');
var valueLower = value.trim().toLowerCase();
if (valueLower === 'true' || value === 'false') {
value = Boolean(value);
} else if (!isNaN(Number(value))) {
value = Number(value);
}
@ryanguill
ryanguill / postgres-merge-arrays.sql
Created December 21, 2016 16:41
in postgres, there currently isnt a function to combine two arrays and remove duplicates - this will do that.
CREATE OR REPLACE FUNCTION mergeArrays (a1 ANYARRAY, a2 ANYARRAY) RETURNS ANYARRAY AS $$
SELECT ARRAY_AGG(x ORDER BY x)
FROM (
SELECT DISTINCT UNNEST($1 || $2) AS x
) s;
$$ LANGUAGE SQL STRICT;
@ryanguill
ryanguill / es6-sql-poc.js
Last active May 22, 2016 18:50
with node v4 this becomes possible without any external library to do the es6 stuff.
function param (name, type) {
return {name: name, type: type};
}
function sql (template) {
//this line goes away entirely with the ...spread operator, the function becomes `sql (template, ...values)`
var values = Array.prototype.slice.call(arguments, 1);
//console.log("template", template);
@zekesonxx
zekesonxx / nato.json
Created September 16, 2015 00:13
NATO Phonetic Alphabet in JSON. Just in case someone needs it.
{
"A": "Alfa",
"B": "Bravo",
"C": "Charlie",
"D": "Delta",
"E": "Echo",
"F": "Foxtrot",
"G": "Golf",
"H": "Hotel",
"I": "India",

Mark Ryan Guill

388 Dove Valley Road, Collierville, TN 38017
(901) 257-9264 / ryanguill@gmail.com

Summary of Qualifications

I have close to 20 years of professional software development experience designing, developing and maintaining applications across a wide range of systems for both small businesses and international corporations. Programming is my passion and my hobby and I am grateful to be able to do it full time. I specialize in developing complete system solutions, working with business experts and peers to deliver quality, maintainable software. I have a never-ending desire to grow, both learning new technologies and skills and expanding my business experience.