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
$tables = $wpdb->get_results(" | |
SELECT table_name FROM information_schema.tables WHERE table_name LIKE 'i9JAv_%'; | |
"); | |
$tables = array_map(function($tbl) { | |
return $tbl->table_name; | |
}, $tables); | |
$tables = implode(', ', $tables); | |
$wpdb->query(" | |
DROP TABLE IF EXISTS $tables; | |
"); |
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 path_relative($dir, $dest) { | |
$ds = DIRECTORY_SEPARATOR; | |
$dir = explode($ds, rtrim($dir, $ds)); | |
$dest = explode($ds, $dest); | |
while ($dir && $dest && ($dir[0] == $dest[0])) { | |
array_shift($dir); | |
array_shift($dest); | |
} | |
return str_repeat('..'.$ds, count($dir)) . implode($ds, $dest); | |
} |
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
declare module 'dlv' { | |
function dlv<T, K extends keyof T>( | |
obj: T | undefined, | |
key: K, | |
def?: T[K] | |
): T[K] | undefined | |
function dlv(obj: object | undefined, key: string | string[], def?: any): any | |
export default dlv | |
} |
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
/** Eliminate intersections */ | |
type Id<T> = { [K in keyof T]: T[K] } | |
/** Get the value type of the given key (if defined) */ | |
type Get<T extends object, P> = P extends keyof T ? UnPartial<T>[P] : never | |
/** Make all properties non-partial */ | |
type UnPartial<T extends object> = { [K in keyof T]-?: T[K] } |
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 { toString } = Object.prototype | |
/** Any object type */ | |
type AnyObj = { [key: string]: any } | |
export function deepCompare(a: any, b: any): boolean { | |
// Strict equality | |
if (a === b) return true | |
// Some types get special treatment |
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 async function asyncReduce<U, T = any>( | |
arr: ReadonlyArray<T>, | |
iter: ( | |
memo: U, | |
value: T, | |
index: number, | |
arr: ReadonlyArray<T> | |
) => U | Promise<U>, | |
startValue: U | Promise<U> | |
) { |
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 PATH="$HOME/dev/bin:$PATH" | |
mkdir ~/dev && cd $_ | |
mkdir ./bin | |
# oh-my-zsh | |
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" | |
# zsh port of rupa/z | |
git clone https://github.com/agkozak/zsh-z $ZSH_CUSTOM/plugins/zsh-z --depth 1 |
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
{ | |
"separateMinorPatch": true, | |
"patch": { | |
"automerge": true, | |
"automergeType": "branch" | |
} | |
} |
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
# Create a directory and switch to it. | |
mkdir foo && ./$_ |
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
/** Trigger a compiler error when a value is _not_ an exact type. */ | |
declare const exactType: <T, U extends T>( | |
draft?: U, | |
expected?: T | |
) => T extends U ? T : 1 & 0 |