Skip to content

Instantly share code, notes, and snippets.

View joshuaebowling's full-sized avatar

Josh Bowling joshuaebowling

View GitHub Profile
@joshuaebowling
joshuaebowling / CreateRandomPrefixedCustomLengthString.ts
Last active February 9, 2021 13:59
TS create random string custom length custom prefix
const alphanum = "aAbBcCdDeEfFgGHhIIJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789".split("");
export const random: (size: number, prefix: string | null) => string = (size, prefix = null) => {
if(prefix && prefix.length > size) return throw("size must be greater than prefix length")
const result = [];
for (let i = 0; i < size; i++) {
result.push(alphanum[Math.floor(Math.random() * alphanum.length)]);
}
const base = result.join("");
if (!prefix) return base;
@joshuaebowling
joshuaebowling / IResponse.ts
Created August 13, 2021 14:47
Typescript Response Model for normalizing responses from functions/methods
export interface IResponse<T> {
Message: string
IsError: boolean
Data: T
}
@joshuaebowling
joshuaebowling / set-title.sh
Created January 16, 2023 18:18
set the title of a terminal in linux (add to .bashrc)
function set-title() {
if [[ -z "$ORIG" ]]; then
ORIG=$PS1
fi
TITLE="\[\e]2;$*\a\]"
PS1=${ORIG}${TITLE}
}