Skip to content

Instantly share code, notes, and snippets.

View joshuaebowling's full-sized avatar

Josh Bowling joshuaebowling

View GitHub Profile
@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}
}
@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 / 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;
<script type="text/template" id="tmpl-cell">
<div class="input mb-2">
<input data-bind="value: character, attr: {id: 'clip-'+name(), 'data-clipboard-target':'#clip-'+name(), title: name()}" type="text" class="form-control box1" placeholder="" aria-label="" aria-describedby="basic-addon1">
</div>
</script>
<script type="text/template" id="tmpl-snippet">
<div>
@joshuaebowling
joshuaebowling / bus-book-generator.js
Last active August 21, 2017 19:36
A prototype for building a JSON object what will act as a message bus's (postal.js) phonebook
const _ = require( 'lodash' ),
async = require( 'async' ),
fs = require('fs')
;
var actions, base, result, states, subActions, template, toObject, types;
result = {};
template = `module.exports = ${JSON.stringify(_.omit(result, 'any'), '', 4)}`;
base = [ '*' ];
@joshuaebowling
joshuaebowling / wait-for-it-pattern.js
Last active August 2, 2017 20:01
Wait for it... a time-of-no-change based throttling pattern
var
WAIT_TIMER = 1750, // in MS
waitForItTimer,
waitForIt, whatYoureWaitingToInvoke;
whatYoureWaitingToInvoke = function _whatYoureWaitingToInvoke() {
alert(`what you're waiting for!!`);
};
waitForIt = function _waitForIt() {
@joshuaebowling
joshuaebowling / do-ubuntu-16.04-install-nginx.sh
Created April 24, 2017 02:13
Install Nginx on Digital Ocean Ubuntu 16.04 and configure UFW
# source https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-16-04
sudo apt-get update
sudo apt-get install nginx
# options 'Nginx HTTP', 'Nginx HTTPS', 'Nginx Full'
sudo ufw allow 'Nginx HTTP'
@joshuaebowling
joshuaebowling / do-ubuntu-16.04-install-nvm-part-1.sh
Last active February 2, 2021 03:25
install nvm on digital ocean ubuntu 16.04
# source https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-16-04
# as of 23/4/2017
#part 1
# add build deps
sudo apt-get update
sudo apt-get -y install build-essential libssl-dev
# grab v0.33.1 (most recent)
@joshuaebowling
joshuaebowling / do-install-docker.sh
Created April 23, 2017 03:37
digital ocean installing docker
# instructions from https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04
# Add the GPG key for the official Docker repository to the system
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
# Add the Docker repository to APT sources:
sudo apt-add-repository 'deb https://apt.dockerproject.org/repo ubuntu-xenial main'
# Update the package database with the Docker packages from the newly added repo:
sudo apt-get update
@joshuaebowling
joshuaebowling / elasticsearch-2.3.2-install.sh
Created May 18, 2016 14:18
Install elasticsearch 2.3.2 on Ubuntu 14.04 LTS
# prerequisites
# java 8
# get the package
wget https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-2.3.2.deb
# unpack
sudo dpkg -i elasticsearch-2.3.2.deb