Skip to content

Instantly share code, notes, and snippets.

View Justintime50's full-sized avatar

Justin Hammond Justintime50

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / benchmarking.md
Created November 11, 2020 17:18
Benchmarking commands for various things

Benchmarking

ZSH

$ for i in $(seq 1 5); do time zsh -i -c exit; done
zsh -i -c exit  0.18s user 0.18s system 97% cpu 0.364 total
zsh -i -c exit  0.19s user 0.19s system 98% cpu 0.382 total
zsh -i -c exit  0.18s user 0.19s system 99% cpu 0.372 total
zsh -i -c exit 0.19s user 0.20s system 98% cpu 0.391 total
@Justintime50
Justintime50 / install-executable-from-tar.sh
Created December 30, 2020 21:52
Install an executable into your path from a tar archive
# Install an executable into your path from a tar archive
URL="https://github.com/Justintime50/freedom/releases/download/v0.2.0/freedom_0.2.0_linux_amd64.tar.gz" \
TAR=${URL##*/} \
BINARY="free" \
curl -LJO "$URL" && tar -xf "$TAR" "$BINARY" && mv "$BINARY" "$HOME/bin/$BINARY" && rm "$TAR"
@Justintime50
Justintime50 / slugify-field-laravel.md
Last active February 8, 2021 17:14
Guide on how to Slug an HTML Field in Laravel

Slug an HTML Field in Laravel

Follow this guide to learn how to easily slug an HTML field in Laravel. You can also use this guide for other HTML projects with some tweaking.

Usage

HTML

The following is an example where when text is entered into the title field, it will dynamically slug it in the slug field.

@Justintime50
Justintime50 / setup-dnsmasq.md
Last active July 6, 2022 21:34
Guide on setting up dnsmasq for localhost development

Setup DNSMasq for Localhost Development

Local development requires you to edit your /etc/hosts file constantly to add custom local domains. Maintaining this file across machines and projects can become taxing. Let's use a service like dnsmasq to dynamically set any .localhost domain to point to 127.0.0.1

# Install dnsmasq
brew install dnsmasq
sudo brew services start dnsmasq

# Configure