Skip to content

Instantly share code, notes, and snippets.

View Segmentational's full-sized avatar

Jacob B. Sanders Segmentational

View GitHub Profile
@Segmentational
Segmentational / setup-prompt.ts
Last active September 13, 2022 23:16
Very Simple User-Input Prompt
/***
* Prompting Users for Input should be Easy...
*
* The following package is established with zero dependencies, and only
* uses the node.js standard library.
*
* As such, context should be kept to devDependencies, and should never
* be attempted to be used within a browser.
*
* Simply prompt the user for input at a given "key", and after a response,
@Segmentational
Segmentational / index.ts
Created August 2, 2022 04:16
Object Destructuring
import * as Mock from "@faker-js/faker";
function Generation() {
const { git } = Mock.faker;
const { address } = Mock.faker;
const { color } = Mock.faker;
const { company } = Mock.faker;
const { database } = Mock.faker;
const { hacker } = Mock.faker;
const { image } = Mock.faker;
@Segmentational
Segmentational / README.md
Created July 15, 2022 06:46
2020 Commit Message Pattern(s)

These commit practices also allow for some really powerful automation downstream; take for example:

Pattern Description Alias(es)
Revert, U Reverts a previous commit [U]ndo, Reversion, Reverted, Mistake
Fix, B Work towards bug-related code [B]ugfix, Bug-Fix, Hot-Fix, Hotfix
[F]eature, F Creation of a capability: implementation of a dependency, test, functionality Add, Added, Addition, Implementation Implemented
Bump, V Increase version; i.e. updating a dependency [V]ersion, Release
[T]est, T Additions or refactoring of anything test-related Unit, Interoperability, Stage
[B]uild, B Force a pipeline trigger Not Applicable
@Segmentational
Segmentational / System.Bash
Created July 10, 2022 00:19
MacOS, Linux, Windows Installer
#!/bin/bash
CLI_OS="na"
CLI_UNAME="na"
CLI_MAJOR_VER="na"
VERSION="[RELEASE]"
# Order is by destination priority.
DESTINATION_PATHS="/usr/local/bin /usr/bin /opt/bin"
SETUP_COMMAND="jf setup"
@Segmentational
Segmentational / index.ts
Last active July 4, 2022 06:51
Node Standard Library Prompts
import Input from "readline";
/***
* User-Input Handler
* ---
*
* @experimental
* @constructor
*
*/
@Segmentational
Segmentational / Git.Bash
Created July 4, 2022 04:03
Git Large Files Parser
git rev-list --objects --all |
git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' |
sed -n 's/^blob //p' |
sort --numeric-sort --key=2 |
cut -c 1-12,41- |
$(command -v gnumfmt || echo numfmt) --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest
#!/usr/bin/env ts-node
module Abstract {
type Hostname = "localhost" | string;
type Port = string | number;
interface Input {
hostname?: Hostname,
port: Port
}
@Segmentational
Segmentational / command.bash
Last active June 29, 2022 05:36
Search EC2 Bastion via Bastion Key & Development Value
aws ec2 describe-instances --filters Name=tag:Bastion,Values=Development --output json --query 'Reservations[*].Instances[*].[PrivateIpAddress,InstanceId,Tags[?Key==`Name`].Value]' --no-cli-auto-prompt
aws ec2 describe-instances --filters Name=tag:Bastion,Values=Development --output json --query 'Reservations[*].Instances[*].[PrivateIpAddress,InstanceId,PublicDnsName,Tags[?Key==`Name`].Value]' --no-cli-auto-prompt | jq -r '.[0][0][2]'
@Segmentational
Segmentational / index.ts
Created June 24, 2022 04:40
Advanced Subprocess Output Filter + Colors
import Process from "process";
import Subprocess from "child_process";
import Color from "./colors";
export type PWD = string | URL | undefined;
/*** The Working Directory for the Spawn'd Process - Defaults via Invocation's CWD */
export type CWD = string | URL | undefined | PWD;
/*** The Spawn'd Process Environment Variables - Defaults via Runtime's Configuration */
export type Environment = typeof process["env"];
/*** Process Buffer + Stream Type - Defaults to `"pipe"` */
@Segmentational
Segmentational / index.ts
Last active June 24, 2022 00:29
User Database Hydration + Sanitation Example
import FS from "fs";
import crypto from "crypto";
import { faker } from "@faker-js/faker";
import Path from "path";
import "dotenv/config";
import Dot from "dotenv";
import Expansion from "dotenv-expand";