Skip to content

Instantly share code, notes, and snippets.

@romellem
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 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 / README.md
Last active May 22, 2018 — forked from ralphschindler/README.md
Docker For Mac Host Address Alias To Enable PHP XDebug (10.254.254.254 Trick)
View README.md

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 / 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
romellem / commit-msg
Created Jun 13, 2016
Git hook - Post-commit spell check (using `aspell`)
View commit-msg
#!/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 / disposable_emails.txt
Last active Dec 8, 2016
List of "disposable" email domains (some are regex'd). List taken from github.com/ornicar/lila, /modules/security/src/test/Fixtures.scala
View disposable_emails.txt
"leeching.net"
"ChaCuo.net"
"027168.com"
"0-mail.com"
"mail1a.de"
"0815.ru"
"0815.su"
"0clickemail.com"
"0sg.net"
"0wnd.net"
@romellem
romellem / _SortByOrder.php
Last active Apr 29, 2016
Helper function to Sort an array of objects by multiple keys.
View _SortByOrder.php
<?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 / _multi-border-mixin.scss
Last active Mar 17, 2016
Sass mixin for creating multi-borders on boxes using box-shadows.
View _multi-border-mixin.scss
// 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
You can’t perform that action at this time.