Skip to content

Instantly share code, notes, and snippets.

View jrobinsonc's full-sized avatar
😁
coding for fun

Jose Robinson jrobinsonc

😁
coding for fun
View GitHub Profile
@jrobinsonc
jrobinsonc / isDefined.ts
Last active July 10, 2025 16:57
Type Guard Functions for Various Data Types
export function isDefined<T>(arg: T | undefined | null): arg is T {
return arg !== undefined && arg !== null;
}
@jrobinsonc
jrobinsonc / package.json
Last active August 31, 2023 17:27
Parse CLI arguments
{
"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",
@jrobinsonc
jrobinsonc / wp-clean.sh
Last active October 29, 2021 20:21
Clean installation of WordPress using WP CLI
# 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)
@jrobinsonc
jrobinsonc / vscode-phpstan-task.md
Last active September 18, 2021 18:39
VSCode task problemMatcher for PHPStan

Use PHPStan to check your PHP files in VSCode

First, install the composer package: composer require --dev phpstan/phpstan.

Then, add this code to your .vscode/tasks.json:

{
  "label": "PhpStan",
 "detail": "Run PhpStan",
@jrobinsonc
jrobinsonc / regex-patterns.md
Last active September 18, 2021 14:53
Regex patterns
@jrobinsonc
jrobinsonc / vscode-psalm-task.md
Last active September 18, 2021 18:39
VSCode task problemMatcher for Psalm

Use Psalm to check your PHP files in VSCode

First, install the composer package: composer require --dev vimeo/psalm.

Then, add this code to your .vscode/tasks.json:

{
      "label": "Psalm",
 "detail": "Run Psalm",
@jrobinsonc
jrobinsonc / README.md
Last active October 22, 2021 21:40
Use React Context effectively
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;
;
(function ($, undefined) {
$.fn.handleScroll = (upHandler, downHandler, userOptions) => {
const options = $.extend({}, {
debug: false
}, userOptions);
/**
* Window object.
*/