Skip to content

Instantly share code, notes, and snippets.

@romellem
romellem / _multi-border-mixin.scss
Last active March 17, 2016 19:28
Sass mixin for creating multi-borders on boxes using box-shadows.
// See `http://codepen.io/romellem/pen/QyXJrZ` for some examples
@mixin multi-border($num, $style: 'all', $width: 1px, $colors: #000, $lock-inner: true, $add-margin: true, $inset: false) {
// define all styles
//$styles: ("top": "top", "right": "right", "bottom": "bottom", "left": "left", "top-left": "top-left", "top-bottom": "top-bottom", "top-right": "top-right", "bottom-left": "bottom-left", "bottom-right": "bottom-right", "top-left-right": "top-left-right", "bottom-left-right": "bottom-left-right", "all": "all");
// Only supports top, right, bottom, left, and all, for now.
$styles: ("top": true, "right": true, "bottom": true, "left": true, "all": true);
// If we try to use an un-named style, send a warning message and use 'all' instead
@romellem
romellem / _SortByOrder.php
Last active April 29, 2016 13:46
Helper function to Sort an array of objects by multiple keys.
<?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.
@romellem
romellem / disposable_emails.txt
Last active December 8, 2016 20:22
List of "disposable" email domains (some are regex'd). List taken from github.com/ornicar/lila, /modules/security/src/test/Fixtures.scala
"leeching.net"
"ChaCuo.net"
"027168.com"
"0-mail.com"
"mail1a.de"
"0815.ru"
"0815.su"
"0clickemail.com"
"0sg.net"
"0wnd.net"
@romellem
romellem / commit-msg
Created June 13, 2016 16:11
Git hook - Post-commit spell check (using `aspell`)
#!/bin/bash
ASPELL=$(which aspell)
if [ $? -ne 0 ]; then
echo "Aspell not installed - unable to check spelling" >&2
exit
else
WORDS=$($ASPELL --mode=email --add-email-quote='#' list < "$1" | sort -u)
fi
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
romellem / combinations.js
Created February 10, 2017 16:16 — forked from axelpale/combinations.js
JavaScript functions to calculate combinations of elements in Array.
/**
* 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
romellem / README.md
Last active May 22, 2018 23:59 — forked from ralphschindler/README.md
Docker For Mac Host Address Alias To Enable PHP XDebug (10.254.254.254 Trick)

Docker (Mac) De-facto Standard Host Address Alias

See also - https://forums.docker.com/t/ip-address-for-xdebug/10460

For the record, I actually ran sudo ifconfig en0 alias 10.254.254.254 255.255.255.0

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

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
romellem / hbs-expand-attributes-helper.js
Created November 26, 2019 17:10
expandAttributes Handlebars (HBS) Helper
/**
* 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 https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes#Attribute_list
*/
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
romellem / poly.scss
Created October 30, 2020 19:14
Sass poly sizing mixin / functions
/// Poly-sizing mixin
///
/// @see https://www.smashingmagazine.com/2017/05/fluid-responsive-typography-css-poly-fluid-sizing/
///
/// @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
romellem / css-colors.json
Created February 18, 2021 15:38
CSS Named Colors
{
"aliceblue": "#f0f8ff",
"antiquewhite": "#faebd7",
"aqua": "#00ffff",
"aquamarine": "#7fffd4",
"azure": "#f0ffff",
"beige": "#f5f5dc",
"bisque": "#ffe4c4",
"black": "#000000",
"blanchedalmond": "#ffebcd",
@romellem
romellem / cli.js
Last active March 1, 2021 16:36
Async Node.JS CLI Prompt / Question Using Built-in Modules
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) => {