Skip to content

Instantly share code, notes, and snippets.

View drhuffman12's full-sized avatar

Daniel Huffman drhuffman12

View GitHub Profile
@drhuffman12
drhuffman12 / .bashrc
Last active December 3, 2021 04:29
bash prompt with username, host, time, path, git branch info
################################################################
## vvvv COLORS vvvvv ##
COLOR_PREFIX="\e[0;"
COLOR_DISABLED="\e[0m"
COLOR_ID_Black=30
COLOR_ID_Red=31
COLOR_ID_Green=32
@drhuffman12
drhuffman12 / new_unique_incremented_username.rb
Created July 9, 2020 23:42
Ruby/SQL code to generate new unique incremented keys (e.g. usernames)
# example app code should guarantee a unique, sequenced username:
def calc_prefix(user, fmaxi = 7, lmaxi = 0)
# e.g.: extract users's first and last name (or use the email example or etc)
first_name = user.first_name
last_name = user.last_name
# now, force to lowercase and only (ascii? unicode?) letters and numbers
# first_name = first_name.downcase.gsub(/[^0-9a-z ]/i, '') # for ascii only
first_name = first_name.downcase.gsub(/[^\p{Alnum} -]/, '') # for unicode also
@drhuffman12
drhuffman12 / README.md
Last active February 26, 2020 01:14
Jira ticket count jql generator (e.g.: for use in dashboard)
  1. Browse to https://linuxacademy.atlassian.net/issues/ to start entering your jql scripts.
  2. For each of the jql's do the following:
  • Paste the jql into the query box and click "Search"
  • Click "Save As" at the top and name it as per the comment at the beginning of the jql file.
  1. Browse to https://linuxacademy.atlassian.net/secure/Dashboard.jspa
  2. Click "... | Create Dashboard" from the top-right "..." drop down.
  3. Name and save the dashboard.
  4. Click "Add gadget".
  5. Click "Load all gadgets" and enter "pie" in the "Search" box.
  6. Click "Add gadget" as many times as you want and glick "Close" (e.g.: I do one for each of the 13 weeks and a couple for the team quarterly and one for my quarterly)
@drhuffman12
drhuffman12 / array_flattener.rb
Last active May 30, 2019 00:00
Example code to flatten an array of arbitrarily nested arrays of integers into a flat array of integers (w/out language-provided array flatteners like Ruby's Array#flatten).
# PURPOSE:
#
# Write some code, that will flatten an array of arbitrarily nested arrays of integers into a flat array of integers.
# e.g. [[1,2,[3]],4] -> [1,2,3,4].
#
# Your solution should be a link to a gist on gist.github.com with your implementation.
#
# When writing this code, you can use any language you're comfortable with. The code must be well tested and documented.
# Please include unit tests and any documentation you feel is necessary. In general, treat the quality of the code as
# if it was ready to ship to production.
@drhuffman12
drhuffman12 / image_info.log
Created February 7, 2019 16:17
NUT-4169 images exceeding Cloudinary 25 mega pixel limit
image w/ > 25 mega-pixels (or 25 million pixels)
... 25*1000*1000 == 25,000,000)
... 25*1024*1024 == 26,214,400)
meal_id: 146810, file: iStock-1049447430.jpg, dims: [7360, 4912] is 36,152,320 (> 25*1000*1000 pixels) (> 25*1024*1024 pixels)
meal_id: 146435, file: iStock-1058194670.jpg, dims: [7360, 4912] is 36,152,320 (> 25*1000*1000 pixels) (> 25*1024*1024 pixels)
meal_id: 146660, file: iStock-1059727904.jpg, dims: [7127, 4756] is 33,896,012 (> 25*1000*1000 pixels) (> 25*1024*1024 pixels)
meal_id: 146568, file: iStock-1064715938.jpg, dims: [6720, 4480] is 30,105,600 (> 25*1000*1000 pixels) (> 25*1024*1024 pixels)
meal_id: 146882, file: iStock-1085778942.jpg, dims: [6720, 4480] is 30,105,600 (> 25*1000*1000 pixels) (> 25*1024*1024 pixels)
meal_id: 146894, file: iStock-114251919.jpg, dims: [6496, 4872] is 31,648,512 (> 25*1000*1000 pixels) (> 25*1024*1024 pixels)
@drhuffman12
drhuffman12 / common.rb
Last active February 1, 2019 17:14
NUT-4229_comparing_OUTER_vs_INNER_joins
esha_pks = [6760530, 6776057, 7279784, 7370300, 8253591, 9797725, 10311137, 10455343, 11402152, 17796699, 18295998, 19227419, 21647821, 21868381, 22096443, 25284036, 32992254, 33039508, 35801083, 37408869, 37500344, 38846565, 44116874, 45503193, 45540890, 46292022, 46676413, 46997137, 48713161, 49538949, 52445686, 52668422, 55396354, 55749456, 56973217, 59940706, 66485593, 66941662, 67180364, 69097944, 70879458, 74598952, 74644922, 74715709, 81621084, 81864393, 82291812, 87092433, 91220972, 92292419, 92622167, 96111237, 96843940, 98217617, 98408699, 99470316, 102108591, 107904280, 108078113, 109046683, 110267344, 110684336, 112318653, 115528891, 115725084, 119023790, 119158512, 120247555, 123243383, 123817113, 124422809, 127195547, 129628259, 130922680, 134762489, 140120855, 143885669, 148806873, 149404244, 149810346, 149867253, 154129202, 160165198, 160803062, 163535839, 165656452, 167844561, 167987582, 168849158, 169287900, 169465839, 170000559, 170062431, 170281645, 179569209, 180810565, 181493232, 182530
@drhuffman12
drhuffman12 / docker_cleanup.sh
Last active April 23, 2018 18:40
docker scratchpad
# Remove all images by name
export IMAGE_NAME
IMAGE_NAME=<none>
docker rmi -f `docker images -a | grep $IMAGE_NAME | awk '{print $3}'`
@drhuffman12
drhuffman12 / gist_edit_textbox_height.js
Created April 16, 2018 03:11
Modify Gist Edit Textbox Height
// xpath: '//*[@id="gists"]/div[2]/div[2]/div[2]/div'
// selector: '#gists > div.js-gist-file > div.file.js-code-editor.container-preview.show-code > div.commit-create > div'
// reset to orig:
$('#gists > div.js-gist-file > div.file.js-code-editor.container-preview.show-code > div.commit-create > div').style.height = '352px'
// expand to 600px high:
$('#gists > div.js-gist-file > div.file.js-code-editor.container-preview.show-code > div.commit-create > div').style.height = '600px'
// expand to 900px high:
@drhuffman12
drhuffman12 / keybase.md
Created February 15, 2018 16:48
keybase.md

Keybase proof

I hereby claim:

  • I am drhuffman12 on github.
  • I am drhuffman12 (https://keybase.io/drhuffman12) on keybase.
  • I have a public key ASBPyKOg-p-18ANv6JCy3ywED_bb1obMMNe5rNls0dg4HQo

To claim this, I am signing this object:

@drhuffman12
drhuffman12 / _clean_docker_.sh
Last active August 18, 2017 01:39
Clean Docker containers and images based on given filter text
#!/usr/bin/env sh
filter="$1"
if [ -z "$1" ]
then
echo "Clean Docker containers and images based on given filter text."
echo
echo " Error: No filter argument supplied."
echo " Usage: `basename "$0"` <filter>"
echo " e.g. `basename "$0"` my_image_or_container_name"
echo