Skip to content

Instantly share code, notes, and snippets.

Justin Hammond Justintime50

View GitHub Profile
@Justintime50
Justintime50 / print-tables.md
Last active Jul 30, 2020
Print data into tables on the console in Python
View print-tables.md

Print Data to Tables on Console via Python

Printing stuff to console (formatted) is hard. Make it easy with autoformatting table columns with this example. There are even a few edge cases included here!

table = []
        headers = ['id', 'user_id', 'weight_ounces', 'rate_cents', 'country_code', 'created_at', 'effective_date', 'service', 'per_piece_cents', 'per_pound_cents']
        table.append(headers)
        for row in summary:
            data = [row.id, row.user_id, row.weight_ounces, row.rate_cents, row.country_code, row.created_at.strftime('%Y-%m-%d %H:%M:%S'), row.effective_date.strftime('%Y-%m-%d %H:%M:%S'), row.service, row.per_piece_cents, row.per_pound_cents]
@Justintime50
Justintime50 / reset-xcode-install.md
Created Jul 25, 2020
Reset Your Xcode Installation on macOS
View reset-xcode-install.md

How to resolve: No Xcode or CLT version detected!

Step 1

xcode-select -print-path

# This is the output, is no output the Xcode is not installed. We need to install it Skip to Step 6
/Library/Developer/CommandLineTools
@Justintime50
Justintime50 / upload-python-package.sh
Created Jun 4, 2020
Upload a python package by running this script
View upload-python-package.sh
#!/bin/bash
echo "Uploading Python package, this will generate new binaries. Press any button to proceed."
read -rn 1
python3 setup.py sdist bdist_wheel
echo "__token__" | python3 -m twine upload dist/*
echo "Python package uploaded!"
@Justintime50
Justintime50 / import-relative-module.md
Created May 28, 2020
Import a Relative Module in Python
View import-relative-module.md

Import a Relative Module in Python

This is great when testing a local version of something like a client library and you need to test your changes and not import the globally installed version.

Usage

import sys
sys.path.insert(0, "/path/to/your/package_or_module")
import my_module
@Justintime50
Justintime50 / mass-git-push.sh
Last active May 4, 2020
Push any changes from each repo in the current directory - great for mass updating repos at once.
View mass-git-push.sh
#!/bin/bash
# Push any changes from each repo in the current directory
echo -e "Pushing changes from each repo..."
for DIR in */ ; do
printf '\n%s\n' "$DIR"
cd "$DIR" || exit
git checkout master
git add README.md
git commit -m "Updated Travis-CI Badge Link"
@Justintime50
Justintime50 / laravel-upgrade-mysql-from-v5-to-v8-password.md
Created Feb 7, 2020
Upgrading MySQL from v5 to v8 breaks passwords
View laravel-upgrade-mysql-from-v5-to-v8-password.md

Upgrading MySQL from v5 to v8 breaks passwords

Frameworks such as Laravel will no longer work with the native mysql passwords when upgraded. Follow these steps to correct:

Usage

docker exec -it database_container bash
mysql -u root -p
ALTER USER username IDENTIFIED WITH caching_sha2_password BY 'MYPASSWORDHERE';
@Justintime50
Justintime50 / git-check.md
Created Jan 29, 2020
Check if a directory is a git repo and warn the user.
View git-check.md

Git Check

Check if a directory is a git repo and warn the user.

Usage

Add this to your ~/.zshrc file or ~/.bash_profile and source it.

function git-check() {
@Justintime50
Justintime50 / setup-mailcatcher-docker.md
Created Jan 23, 2020
Have you ever needed to test mail functions for a project and didn't want to spam the real web? Use Mailcatcher!
View setup-mailcatcher-docker.md

Setup Mailcatcher on Docker

Have you ever needed to test mail functions for a project and didn't want to spam the real web? Use Mailcatcher!

Usage

docker run -d -p 1080:1080 -p 1025:1025 --name=mailcatcher -itd --network=mailcatcher sj26/mailcatcher
@Justintime50
Justintime50 / add-ssh-passphrase-to-ssh-agent.md
Last active Feb 10, 2020
Tired of typing in your SSH passphrase when using Git? Get ride of it!
View add-ssh-passphrase-to-ssh-agent.md

Add SSH Passphrase to SSH Agent

Tired of typing in your SSH passphrase? Get rid of it!

This process may need to be done on each login.

ssh-add

# If you need to specify the SSH location/file, use the following
@Justintime50
Justintime50 / migrate-google-drive-across-domains.md
Created Jan 15, 2020
Guide to migrating Google Drives across domains.
View migrate-google-drive-across-domains.md

Migrate Google Drive Across Domains

Guide to migrating Google Drives across domains.

Intro

Have you ever needed to migrate files or an entire drive structure from one domain to another? Many people have. Whether you rebrand or just want to share some files with another company quickly, there is a growing need to do this; however, Google does not provide a way to automatically migrate files across domains. I spent the last two years brainstorming and testing methods to do this after the company I worked for rebranded and we suddenly had a need to move 4+ terrabytes of data and thousands of folders across domains. Here is the journey we took to get there.

What didn't work

You can’t perform that action at this time.