Skip to content

Instantly share code, notes, and snippets.

View codeaid's full-sized avatar

codeaid

View GitHub Profile
@codeaid
codeaid / lib.js
Created December 1, 2020 11:56
US region, division and state maps
const getUSRegions = () => ({
ne: { name: "Northeast" },
mw: { name: "Midwest" },
s: { name: "South" },
w: { name: "West" },
ter: { name: "US Territories" },
});
const getUSDivisions = () => ({
ne: { name: "New England", region: "ne" },
@codeaid
codeaid / useTimeout.ts
Created November 10, 2020 20:03
React hook utilising setTimeout and exposing pause, resume and cancel callbacks
import { useCallback, useEffect, useRef } from 'react';
type UseTimeoutCallback = (...args: Array<any>) => void;
/**
* Set a timer, which executes a function once the timer expires. Exposes pause, resume and cancel
* callbacks to the consumers.
*
* @param {UseTimeoutCallback} fn Callback function to execute after the specified timeout
* @param {number} ms Timeout in milliseconds after which to execute the callback
@codeaid
codeaid / okta.d.ts
Last active October 1, 2020 12:27
Base TypeScript type definitions for @okta/okta-auth-js v2.5.0
/* tslint:disable:max-classes-per-file */
declare module '@okta/okta-auth-js' {
// Custom HTTP request handler implementation.
export type OktaHttpRequestClient = (
method: string,
url: string,
args: Array<any>,
) => Promise<string>;
// Authorization response mode.
@codeaid
codeaid / PHP Constructor.vtl
Last active August 3, 2017 13:11
PhpStorm Code Templates
#set ($ARGUMENTS = [])
#set ($ARGUMENTS_STR = "")
#set ($PARAM_DOC_DESC = "")
#set ($NEWLINE = "
")
## only process arguments if any are selected
#if ($PARAM_DOC != "")
## split PhpDoc lines generated by PhpStorm into multiple lines
#set ($DOC_LINES = $PARAM_DOC.split("\n"))
const sleep = ms =>
new Promise(resolve =>
setTimeout(resolve, ms));
@codeaid
codeaid / git-filter-branch.sh
Last active February 12, 2016 19:20
Update git commit names and emails
#
# More information @ http://schacon.github.io/git/git-filter-branch.html
#
# Rewrite using environment filter
git filter-branch --env-filter \
'if [ $GIT_COMMITTER_EMAIL = old@email.com ];
then
GIT_COMMITTER_NAME="New Name";
GIT_COMMITTER_EMAIL=new@email.com;
@codeaid
codeaid / daogen.php
Last active February 18, 2024 11:45
PHP DAO generator
#!/usr/bin/php
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
$host = '127.0.0.1';
$user = 'root';
$pass = '';
$db = 'test';