Skip to content

Instantly share code, notes, and snippets.

@r-i-c-h
r-i-c-h / tsconfig.json
Created January 30, 2020 20:07
Rich's tsconfig.json
{
"compilerOptions": {
"noImplicitAny": true,
"target": "es5",
"sourceMap": true,
"declaration": true,
"module": "es2015",
"moduleResolution": "node"
},
"exclude": [
@r-i-c-h
r-i-c-h / .bash_profile-stuff-1
Created June 22, 2020 04:38
Some of the aliases from my .bash_profile
# My Aliases
alias ..="cd .."
alias rmrf="rm -rf"
# ls on steroids:
alias see="ls -laShF | more"
# Some Apple MacOS specifics for showing/hiding hidden files in the Finder
alias showfiles="defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app"
alias hidefiles="defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app"
alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder"
@r-i-c-h
r-i-c-h / .bash_profile-Colorful-Git-Status-Prompt
Created June 22, 2020 04:43
My Colorful git-Status-aware prompt setup in my .bash_profile
# CRAZY COLORED NEW PROMPT w/repo Branch and Status:
# get current branch in git repo
function parse_git_branch() {
BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
if [ ! "${BRANCH}" == "" ]
then
STAT=`parse_git_dirty`
echo "[${BRANCH}${STAT}]"
else
echo ""
@r-i-c-h
r-i-c-h / canvas-drawing-functions.js
Last active August 18, 2023 23:42
HTML Canvas Shape Drawing Functions
/*** Canvas Shape Drawing Functions ***/
// 1. drawStar() - Draw an n-pointed Star w/controls for outer and inner radii - [can make sorta-polygons too]
// 2. drawCircle() - Draw a circle (ctx.arc() wrapper)
// 3A. drawPoly1() - Draw an n-sided Polygon
// 3B. drawPoly2() - Draw an n-sided Polygon
// 3C. drawPoly3() - Draw an n-sided Polygon (controls for initial Rotation in Radians)
/* Assume the following setup: */
const canvas = document.getElementById('canvas1');
const ctx = canvas.getContext('2d');
@r-i-c-h
r-i-c-h / calcCanvasPointDistance.js
Created August 19, 2023 05:09
HTML Canvas Calculate Distance Between 2 Points
function calcDistBetweenPoints(pt1, pt2) {
const dx = pt1.x - pt2.x;
const dy = pt1.y - pt2.y;
// Distance = Pythagorean Theorem to get Hypoteneuse of triangle represented by the two points
// doing it with Math.sqrt() is apparently faster than going directly to Math.hypot() 🤷👌
return Math.sqrt((dx * dx) + (dy * dy));
}