Form Utils
Moved to its own repo:
https://github.com/jrobinsonc/form-utils
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export function isDefined<T>(arg: T | undefined | null): arg is T { | |
| return arg !== undefined && arg !== null; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "@jrobinsonc/parse-cli-arguments", | |
| "description": "Parse CLI arguments.", | |
| "version": "1.0.0", | |
| "main": "parse-cli-arguments.js", | |
| "license": "ISC", | |
| "author": "Jose Robinson <me@joserobinson.com> (https://joserobinson.com/)", | |
| "homepage": "https://gist.github.com/jrobinsonc/d90262c5fad0ad2a253ba46d33cf13b9", | |
| "repository": { | |
| "type": "git", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Delete all comments | |
| wp comment delete $(wp comment list --format=ids) | |
| # Delete posts revisions | |
| wp post delete --force $(wp post list --post_type='revision' --format=ids) |
| Pattern for | Link |
|---|---|
| Phone numbers | https://regex101.com/r/AyWVis/3 |
Running example:
https://codesandbox.io/s/testing-react-context-46hbn
Original idea taken from:
https://kentcdodds.com/blog/how-to-use-react-context-effectively
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const parseArgs = (slice = 0) => { | |
| return process.argv.slice(slice).reduce((map, item, index) => { | |
| let match = null; | |
| switch (true) { | |
| case (match = item.match(/^(?:\-\-([a-z]+)|\-([a-z]))(?:=(.+))?$/)) !== null: | |
| const [, longName, shortName, value] = match; | |
| const parsedValue = typeof value === 'undefined' ? true : value; | |
| const parsedName = typeof longName === 'undefined' ? shortName : longName; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; | |
| (function ($, undefined) { | |
| $.fn.handleScroll = (upHandler, downHandler, userOptions) => { | |
| const options = $.extend({}, { | |
| debug: false | |
| }, userOptions); | |
| /** | |
| * Window object. | |
| */ |