Skip to content

Instantly share code, notes, and snippets.

View NorthDecoder's full-sized avatar

Joe Devlin NorthDecoder

View GitHub Profile
@NorthDecoder
NorthDecoder / cpp_modulo_example.cpp
Created December 19, 2022 20:28
An example c++ modulo calculator with results in a table
// example tested at https://tio.run/#cpp-gcc
// make a table with modulo calculations
#include<iostream>
using std::cout;
int main() {
int dmax = 7;
int nmax = 5;
cout << "D->";
for (int denominator = 1; denominator < dmax; denominator ++) {
@NorthDecoder
NorthDecoder / openSession
Last active February 5, 2022 09:19
A bash script for opening a Tmux session with multiple predefined autopopulated panes
openSession () {
# start-tmux-with-several-panes-open-at-the-same-time
# input from the command line
# usage:
# openSession /my_project_directory/name_here my_tmux_session_name
# Reference:
# https://askubuntu.com/questions/830484/how-to-start-tmux-with-several-panes-open-at-the-same-time#answer-1351351
@NorthDecoder
NorthDecoder / resurrect-chapter.sh
Last active April 29, 2021 22:32
A helper script for manual testing Chapter
#!/usr/bin/bash
clear
me=$( basename "$0" )
echo "~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ "
echo "Running script $me"
echo "~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ "
# Reference:
# https://github.com/freeCodeCamp/chapter
@NorthDecoder
NorthDecoder / my-versions.sh
Created October 16, 2020 20:44
Quick echo versions to display for nvm, node, npm, docker, tmux, vim, nano, ansible, and python
#!/usr/bin/bash
# file: my-versions.sh
# quick display the versions
# to avoid retyping
# setup:
# chmod 744 my-versions.sh
# command prompt usage:
@NorthDecoder
NorthDecoder / luhn.py
Created September 22, 2020 16:44
Luhn algorithm for validating credit card numbers
def luhn(card_number):
def digits_of(n):
return [int(d) for d in str(n)]
digits = digits_of(card_number)
odd_digits = digits[-1::-2]
even_digits = digits[-2::-2]
checksum = 0
checksum += sum(odd_digits)
for d in even_digits:
checksum += sum(digits_of(d*2))
@NorthDecoder
NorthDecoder / is_cc_valid_01.py
Last active September 22, 2020 16:29
Validate credit card number with Luhn algorithm
# file: is_cc_valid.py
# LUHN Algorithm
# Validate credit card number with Luhn algorithm
def is_cc_valid(cc_number, given_checksum):
# ref: https://en.wikipedia.org/wiki/Luhn_algorithm
double_every_other = []
sum_digits = []
minus_nine = []
@NorthDecoder
NorthDecoder / list-installed-python-modules.py
Last active May 25, 2021 19:38
Print a list of installed python modules
# list installed python modules
# > sorted alphabetically
import sys
import os
def list_dict_keys(a_dictionary, list_heading_text):
"""
Print a heading and a list of dictionary keys
to the command line.
"""
@NorthDecoder
NorthDecoder / customize-bashrc-command-prompt
Last active March 6, 2020 23:26
bashrc customized command prompt
# add the following to the bottom of the ~/.bashrc file
# User specific aliases and functions
# # # #
altPrompt="$ "
#altPrompt="λ "
# uhdInfo="\u " # user only
#uhdInfo="\w" # working directory only
# uhdInfo="\u:\w " # user and working directory
@NorthDecoder
NorthDecoder / example-class-template.py
Created December 31, 2019 22:12
A Python starter template for pretesting leetcode.com solutions offline, prior to submission.
# file: example-class-template.py
# A Python starter template for pretesting leetcode.com
# solutions offline, prior to submission.
# Reference:
# Class:
# https://docs.python.org/3.7/tutorial/classes.html?highlight=class#classes
# https://docs.python.org/3.7/tutorial/classes.html?highlight=class#class-objects
@NorthDecoder
NorthDecoder / probe.py
Last active November 25, 2019 19:10
Jupyter notebooks-labs investigate configuration
# User: https://gist.github.com/NorthDecoder/
# Filename: probe.py
# set probe_environment to
# `True` to list resources
# `False` to quiet listing, ie no list
probe_environment=True
# List available packages
if probe_environment: