Skip to content

Instantly share code, notes, and snippets.

@cobinrox
cobinrox / utils.js
Last active March 22, 2023 15:26
utils.js Useful (sorta) JavaScript utils
/**
* Return a string that represents an exception.
* @param {*} exc the exception object
* @returns String view of the exception, including stack trace dump
*/
function excAsStr(exc) {
const errString = `${exc.toString()}\n${exc.stack}`;
return errString;
}
@cobinrox
cobinrox / gist:0aafde69dd8636219327a68907943fcb
Last active January 30, 2023 02:28
Install GitLab as Docker
mkdir /srv/gitlab
export GITLAB_HOME=$(pwd)/gitlab
cd gitlab
vi docker-compose.yml
########################
# docker-compose.yml
version: '3.7'
services:
web:
image: 'gitlab/gitlab-ce:latest'
@cobinrox
cobinrox / gitcmds.sh
Last active April 7, 2023 19:40
Handy (sorta) Git Commands
# Handy (sorta) git commands
#
#
# DISCARD ALL LOCAL CHANGES
#
git reset --hard
git clean -fxd
#
@cobinrox
cobinrox / dockercmds.sh
Last active February 24, 2022 19:05
Docker commands
#
# Image, Export/save docker image for eventual loading onto another system that does not have access to a docker hub
#
docker image ls # to get actual image_name and tag_name
# option 1:
docker save image_name:tag_name > myimage.tar
# option 2 (to compress):
docker save image_name:tag_name | gzip > myimage.tar.gz
@cobinrox
cobinrox / rmdocks.sh
Created February 8, 2022 18:01
Remove all docker artifacts (for real)
#!/bin/bash
# remove docker containers and images
read -p "This script will remove all docker containers and images, continue (y/n)? " -n 1 -r
echo # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
@cobinrox
cobinrox / common_err_trap.txt
Created February 8, 2022 15:01
Bash Source File Script to Trap and Report Uncaught Errors
# uncomment these for debugging
# set -e
# set -x
# save current dir
myOldPwd=$(pwd)
# Provides a common script exit point handler
# The function "finis" is called when the script containing this
# text files exits
@cobinrox
cobinrox / markdownexamples.md
Last active December 25, 2024 19:28
markdown examples

To creae a header like this:

A header

Use hashtags:

#### A header

To display mono font in-line like this:
Here is a sample of mono font: hello

@cobinrox
cobinrox / usefulLinuxCmds.sh
Last active September 29, 2023 12:20
Useful Linux Commands
#
# ALIAS, create
#
vi ~/.bash_profile
alias cdg='cd mygitprojects'
# close vi, then
source ~/.bash_profile
#
@cobinrox
cobinrox / getAbsFileName.py
Created January 26, 2022 15:38
Python get absolute file name
# Get absolute file name from a relative file name (RFN), where the RFN is
# relative to the caller of this function.
# @param relTargetPathFromCallersFile Relative path to the file you are interested
# in, relative to where you are calling this function from
# @returns Absolute file name of
# Example
# src/
# dir1
# textfile.txt
# dir2
@cobinrox
cobinrox / importfileutil.py
Created January 26, 2022 15:34
Python- import a module via relative path
# use this function snippet of code to allow importing of relative, local modules
import os
import importlib.util
def get_as_module_from_file(module_name, relFile):
spec = importlib.util.spec_from_file_location(module_name,
os.path.realpath(os.path.join(os.path.dirname(__file__),
relFile)))
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module