Skip to content

Instantly share code, notes, and snippets.

View Justintime50's full-sized avatar

Justin Hammond Justintime50

View GitHub Profile
@Justintime50
Justintime50 / compare-two-lists.md
Last active November 17, 2020 01:45
Compare Two Lists for Differences

Compare Two Lists

When you need to find a difference in large lists, simply compare their indexes one at a time and break when something doesn't match.

Usage

x = ['a', 'b', 'c']
y = ['a', 'c', 'c']
@Justintime50
Justintime50 / convert-jks-to-pem.md
Created October 21, 2020 18:20
Convert JKS (Java Keystore) Files to PEM Files

Convert JKS (Java Keystore) Files to PEM Files

Install

This process requires keytool and openssl.

Usage

keytool -importkeystore -srckeystore my_in_file.jks -destkeystore my_out_file.p12 -deststoretype PKCS12
@Justintime50
Justintime50 / ssh-agent-in-crontab.md
Last active April 18, 2024 16:57
Use Your SSH Agent in a Crontab

Use Your SSH Agent in a Crontab

Getting access to SSH inside a Crontab is often a problem for many as the environment in which your cron runs is not the same as your normal shell. Simply running ssh-add will not allow you to use your SSH Agent inside your crontab. Follow the below guide to setup your crontab to use your ssh-agent:

Usage

  1. Install Keychain.
  2. Add the following to your ~/.zlogin file which will be invoked on each login. This will allow your crontab (and normal shell) to use your ssh keys and bypass needing to punch in your password each time you need SSH. This will also span across multiple sessions and shells.
@Justintime50
Justintime50 / setup-macos-mail-server.md
Last active October 26, 2021 06:04
Setup a Mail Server on macOS - No Dependencies Required!

Setup a Mail Server on macOS

After years of trying to setup a mail server on macOS without requiring dependencies or messing with ports to trick my ISP into letting mail out, I figured out a solution.

Note: This guide is opinionated towards a Gmail setup.

Steps

  1. Backup the existing Postfix configuration:
@Justintime50
Justintime50 / reset-xcode-install.md
Last active February 14, 2024 17:17
Reset Your Xcode Installation on macOS

Reset your Xcode Install on macOS

Having troubles with Xcode or their Command Line Tools? Follow this guide to reset your Xcode instance on macOS and resolve issues such as "No Xcode or CLT version detected!"

1) Check if Xcode is installed

xcode-select -print-path
@Justintime50
Justintime50 / import-relative-module.md
Created May 28, 2020 18:33
Import a Relative Module in Python

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 June 30, 2022 16:32
Push any changes from each repo in the current directory - great for mass updating repos at once.
#!/bin/bash
# Copy a set of files to each repo in a dir, create a branch, and push to origin
# Requires GitHub CLI: `brew install gh` and must be logged in with `gh auth login`
# GitHub CLI Docs: https://cli.github.com/manual/
MAIN_BRANCH="master"
BRANCH_NAME="ignore_cassette_diffs"
COMMIT_MESSAGE="chore: ignore cassette diffs via gitattributes"
PR_TITLE="$COMMIT_MESSAGE"
@Justintime50
Justintime50 / laravel-upgrade-mysql-from-v5-to-v8-password.md
Created February 7, 2020 07:46
Upgrading MySQL from v5 to v8 breaks passwords

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 / setup-mailcatcher-docker.md
Created January 23, 2020 04:41
Have you ever needed to test mail functions for a project and didn't want to spam the real web? Use Mailcatcher!

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 / migrate-google-drive-across-domains.md
Created January 15, 2020 20:06
Guide to migrating Google Drives across domains.

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