Form Utils
Moved to its own repo:
https://github.com/jrobinsonc/form-utils
This file contains 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
/** | |
* @param time - The time in 24 hours format | |
* @returns The time in 12 hours format | |
*/ | |
export function convertTime24to12(time: string): string { | |
const [hours, minutes]: number[] = time.split(':').map(Number); | |
const meridiem: 'PM' | 'AM' = hours >= 12 ? 'PM' : 'AM'; | |
return `${hours % 12 || 12}:${minutes | |
.toString() | |
.padStart(2, '0')} ${meridiem}`; |
This file contains 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
interface Link { | |
text: string; | |
url: string; | |
} | |
function parseMarkdownLinks(markdownText: string): Link[] { | |
const linkRegex: RegExp = /\[([^\]]+)\]\(([^\)]+)\)/g; | |
const links: Link[] = []; | |
let match: RegExpExecArray | null; | |
This file contains 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 that returns a promise along with resolver and rejector functions | |
* | |
* @template T The type of the resolved value | |
* @returns {{ promise: Promise<T>, resolver: (arg: T) => void, rejector: (error: Error) => void }} | |
*/ | |
const PromiseResolution = <T>() => { | |
let resolver!: (arg: T) => void; | |
let rejector!: (error: Error) => void; |
This file contains 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 isDefined<T>(arg: T | undefined | null): arg is T { | |
return arg !== undefined && arg !== null; | |
} |
This file contains 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 <[email protected]> (https://joserobinson.com/)", | |
"homepage": "https://gist.github.com/jrobinsonc/d90262c5fad0ad2a253ba46d33cf13b9", | |
"repository": { | |
"type": "git", |
This file contains 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 |
NewerOlder