Skip to content

Instantly share code, notes, and snippets.

romellem / gist:26e529387757a4fd1424c59993b3cb99
Created Mar 14, 2021
Simple Node.js Color Formatting in console.log()
View gist:26e529387757a4fd1424c59993b3cb99
const util = require('util');
const black = (s) => util.format('\x1b[30m%s\x1b[0m', s);
const red = (s) => util.format('\x1b[31m%s\x1b[0m', s);
const green = (s) => util.format('\x1b[32m%s\x1b[0m', s);
const yellow = (s) => util.format('\x1b[33m%s\x1b[0m', s);
const blue = (s) => util.format('\x1b[34m%s\x1b[0m', s);
const magenta = (s) => util.format('\x1b[35m%s\x1b[0m', s);
const cyan = (s) => util.format('\x1b[36m%s\x1b[0m', s);
const white = (s) => util.format('\x1b[37m%s\x1b[0m', s);
romellem / cli.js
Last active Mar 1, 2021
Async Node.JS CLI Prompt / Question Using Built-in Modules
View cli.js
const { promisify } = require('util');
const rl = require('readline');
const readline = rl.createInterface({
input: process.stdin,
output: process.stdout,
// Prepare readline.question for promisification
readline.question[promisify.custom] = (question) => {
return new Promise((resolve) => {
View css-colors.json
"aliceblue": "#f0f8ff",
"antiquewhite": "#faebd7",
"aqua": "#00ffff",
"aquamarine": "#7fffd4",
"azure": "#f0ffff",
"beige": "#f5f5dc",
"bisque": "#ffe4c4",
"black": "#000000",
"blanchedalmond": "#ffebcd",
romellem / poly.scss
Created Oct 30, 2020
Sass poly sizing mixin / functions
View poly.scss
/// Poly-sizing mixin
/// @see
/// @param {String|List} $properties - Can be a single CSS property (e.g. `"font-size"`) or a list of properties (e.g `("margin-right", "margin-left")`).
/// @param {Map<(List<Length>|Length)>} $map - Can be a map of single values, or a map of lists of values.
/// @example @include poly("font-size", (375px: 15px, 767px: 30px));
/// @example @include poly("padding", (375px: (0 10px), 767px: (0 20px)));
/// @example @include poly(("margin-top", "margin-bottom"), (375px: 10px, 767px: 20px));
@mixin poly($properties, $map) {
romellem / hbs-expand-attributes-helper.js
Created Nov 26, 2019
expandAttributes Handlebars (HBS) Helper
View hbs-expand-attributes-helper.js
* List of valid attributes that can live on HTML elements. This can be trimmed down however you like.
* @note I've remove `class` and `data-*` since class is usually defined elsewhere, and `data-*` uses different logic to filter them in.
* @see
const attribute_white_list = ['accept', 'accept-charset', 'accesskey', 'action', 'align', 'allow', 'alt', 'async', 'autocapitalize', 'autocomplete', 'autofocus', 'autoplay', 'background', 'bgcolor', 'border', 'buffered', 'challenge', 'charset', 'checked', 'cite', /* 'class', */ 'code', 'codebase', 'color', 'cols', 'colspan', 'content', 'contenteditable', 'contextmenu', 'controls', 'coords', 'crossorigin', 'csp', 'data', /* 'data-*', */ 'datetime', 'decoding', 'default', 'defer', 'dir', 'dirname', 'disabled', 'download', 'draggable', 'dropzone', 'enctype', 'enterkeyhint', 'for', 'form', 'formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget', 'headers', 'height',
romellem /
Last active May 22, 2018 — forked from ralphschindler/
Docker For Mac Host Address Alias To Enable PHP XDebug ( Trick)

Docker (Mac) De-facto Standard Host Address Alias

See also -

For the record, I actually ran sudo ifconfig en0 alias

This launchd script will ensure that your Docker environment on your Mac will have as an alias on your loopback device ( The command being run is ifconfig lo0 alias

Once your machine has a well known IP address, your PHP container will then be able to connect to it, specifically XDebug can connect to it at the configured xdebug.remote_host.

romellem / combinations.js
Created Feb 10, 2017 — forked from axelpale/combinations.js
JavaScript functions to calculate combinations of elements in Array.
View combinations.js
* Copyright 2012 Akseli Palén.
* Created 2012-07-15.
* Licensed under the MIT license.
* <license>
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
romellem / commit-msg
Created Jun 13, 2016
Git hook - Post-commit spell check (using `aspell`)
View commit-msg
ASPELL=$(which aspell)
if [ $? -ne 0 ]; then
echo "Aspell not installed - unable to check spelling" >&2
WORDS=$($ASPELL --mode=email --add-email-quote='#' list < "$1" | sort -u)
if [ -n "$WORDS" ]; then
printf "\e[1;33m Possible spelling errors found in commit message:\n\e[0m\e[0;31m%s\n\e[0m\e[1;33m Use git commit --amend to change the message.\e[0m\n\n" "$WORDS" >&2
romellem / disposable_emails.txt
Last active Dec 8, 2016
List of "disposable" email domains (some are regex'd). List taken from, /modules/security/src/test/Fixtures.scala
View disposable_emails.txt
romellem / _SortByOrder.php
Last active Apr 29, 2016
Helper function to Sort an array of objects by multiple keys.
View _SortByOrder.php
* Takes an array of objects, and sorts them by one or more keys.
* @param array &$list A one-dimensional array of objects
* @param array $keys Array of strings corresponding to the keys which we want to sort on.
* @param array $keys_order Optional array of strings for the sort order. Valid values are 'asc' or 'desc'.
* Placement corresponds to our $keys array (So $keys = ['a', 'b'] and $keys_order - ['desc', 'asc']
* Will sort $list by key 'a' first in descending order, then by key 'b' in ascdening order).
* Default sort order will be SORT_ASC.