Skip to content

Instantly share code, notes, and snippets.

View mattdanielbrown's full-sized avatar

Matt Daniel Brown mattdanielbrown

View GitHub Profile
@mattdanielbrown
mattdanielbrown / is_integer
Created March 10, 2021 15:10 — forked from earthgecko/is_integer
is_integer
function is_integer () {
# exit code 0 - the string is an integer
# exit code 1 - the string is not an integer
local string=$1
[[ $string == ${string//[^0-9]/} ]]
}
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
@mattdanielbrown
mattdanielbrown / every
Created February 21, 2021 18:22 — forked from sorbits/every
Run «command» only every «number» time invoked
#!/usr/bin/env bash
progname=$(basename $0)
version="1.0 (2014-08-17)"
step=2
function create_hash {
openssl dgst -sha1 -binary <<< "$1" | xxd -p
}
@mattdanielbrown
mattdanielbrown / Liberal Regex Pattern for Web URLs
Created February 13, 2021 16:27 — forked from gruber/Liberal Regex Pattern for Web URLs
Liberal, Accurate Regex Pattern for Matching Web URLs
The regex patterns in this gist are intended only to match web URLs -- http,
https, and naked domains like "example.com". For a pattern that attempts to
match all URLs, regardless of protocol, see: https://gist.github.com/gruber/249502
# Single-line version:
(?i)\b((?:https?:(?:/{1,3}|[a-z0-9%])|[a-z0-9.\-]+[.](?:com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|s
@mattdanielbrown
mattdanielbrown / datasources.json
Created December 3, 2020 10:03 — forked from Edudjr/datasources.json
A script for loopback that automatically creates the folders and models from a database in postgresql. It also exposes the models to the Explorer API.
{
"dbname": {
"host": "localhost",
"port": 5432,
"database": "mydatabase",
"password": "user123",
"name": "dbname",
"user": "user",
"connector": "postgresql"
}
@mattdanielbrown
mattdanielbrown / sql-to-json.sh
Created December 3, 2020 10:03 — forked from temp3l/sql-to-json.sh
sql2json for mysql/oracle/mariadb .sql files (just parsing tables + columns)
#!/bin/bash
# Parses Mysql/Oracle/Mariadb sql files (Data and Schema-Dumps)
DICTIONARY_FILE=translationTable.json
# SQL_FILE=SQL_FULL_EXPORT.sql
# SQL_FILE=SQL_STAGING_SCHEMA.sql
# SQL_FILE=SQL_SMALL_EXPORT.sql
SQL_FILE=SQL_SCHEMA_EXPORT_CB.sql
SQLOUTFILE=.trash/translated.sql
JSONOUTFILE=.trash/propMap.json
{
"definitions": {},
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://example.com/root.json",
"type": "object",
"title": "The Root Schema",
"required": [
"foo",
"nums",
"strings"
*https://medium.com/@hintology/sdd-schema-driven-development-f1d232d73ea6
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://:::1/partner.schema.json#",
"title": "Partner",
"description": "business partner specification",
"type": "object",
"definitions": {
{
"accountOwner": {
"$id": "#/definitions/accountOwner",
"type": "string",
"title": "accountOwner",
"description": "accountOwner description",
"maxLength": 300,
"default": "MIPO-Testk 29",
"examples": [
"Maier Can DE",