Skip to content

Instantly share code, notes, and snippets.

View ThreeSixes's full-sized avatar

ThreeSixes ThreeSixes

  • Portland, OR
  • 13:29 (UTC -07:00)
View GitHub Profile
@ThreeSixes
ThreeSixes / fcc_api.py
Last active October 3, 2022 07:30
Query the FCC API for callsign details.
"""
FCC license search utility.
By ThreeSixes (https://gist.github.com/ThreeSixes/d80299a3e53ef3bf9ac14d0445cc75d3) 3 Oct, 2022.
"""
import requests
class FCCAPIError(RuntimeError):
"""
@ThreeSixes
ThreeSixes / josh-nvm-aware-prompt.sh
Created August 20, 2019 22:08
Josh's NVM aware prompt
# This goes into your ~/.bash_profile in OS X, otheriwse it will typically be your ~/.bashrc.
# This can be called and put in your prompt (PS1 variable) using $(parse_nvm).
parse_nvm() {
nvm_status=''
nvm which > /dev/null 2>&1
if [ "$?" -eq "0" ]; then
nvm_status=`nvm which | grep "Found '" | sed "s/^Found .* with version <\(.*\)>/\1/g"`
nvm_status=" <nvm-$nvm_status>"
@ThreeSixes
ThreeSixes / josh-python-env-aware-prompt.sh
Last active August 20, 2019 22:52
Josh's Python environment aware prompt
# This goes into your ~/.bash_profile in OS X, otheriwse it will typically be your ~/.bashrc.
# This can be called and put in your prompt (PS1 variable) using $(parse_python).
parse_python() {
python_status=''
pipenv_data=`pipenv --venv 2> /dev/null`
if [ "$?" -eq "0" ]; then
echo "$pipenv_data" | grep 'No virtualenv has been created for this project yet!' > /dev/null 2>&1
if [ "$?" -ne "0" ]; then
@ThreeSixes
ThreeSixes / josh-git-aware-prompt.sh
Last active August 20, 2019 22:05
Josh's git-aware BASH prompt
# This goes into your ~/.bash_profile in OS X, otheriwse it will typically be your ~/.bashrc.
# This can be called and put in your prompt (PS1 variable) using $(parse_git).
parse_git() {
git_status_flags=''
git status > /dev/null 2>&1
if [ "$?" -eq "0" ]; then
current_branch=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
git status | grep 'Your branch is ' > /dev/null 2>&1
@ThreeSixes
ThreeSixes / imoCheck.py
Last active January 13, 2021 15:02
How to verify an IMO (International Maritime Organization) number in Python
def getImoCheck(imo):
"""
Check a given IMO number to make sure the check value is accurate and if the IMO is good. Accepts the 7-digit IMO number as an integer argument, and returs a boolean value where True indicates a good IMO.
By ThreeSixes (https://github.com/ThreeSixes)
"""
# Set our return value.
retVal = False
# Starting divisor to get digits staring at the seventh.
divisor = 1000000