Skip to content

Instantly share code, notes, and snippets.

Avatar

Justin Hammond Justintime50

View GitHub Profile
@Justintime50
Justintime50 / slugify-field-laravel.md
Last active Feb 8, 2021
Guide on how to Slug an HTML Field in Laravel
View slugify-field-laravel.md

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 / update-branch-name.md
Last active Feb 6, 2021
Guide on how to Update a Branch Name
View update-branch-name.md

Update Branch Name

Run the following three commands to update your local repositories branch name replacing the branch names as needed.

git branch -m <OLD_BRANCH> <NEW_BRANCH>
git fetch origin
git branch -u origin/<REMOTE_BRANCH> <LOCAL_BRANCH>
@Justintime50
Justintime50 / webhooks_server.py
Created Jan 30, 2021
A simple Webhooks server example using Python's Flask API.
View webhooks_server.py
from threading import Thread
import json
import os
import argparse
from datetime import datetime
from flask import Flask, request
import logging
API = Flask(__name__)
ADDRESS = None
@Justintime50
Justintime50 / testing-suites-by-language.md
Last active Jan 15, 2021
A collection of testing suites by language - install and usage instructions
View testing-suites-by-language.md

Testing Suites by Language

The testing suites I use for development and CI/CD across various languages and frameworks.

Commands below are 1) installation and 2) usage respectively.

Bash

Linting

@Justintime50
Justintime50 / install-executable-from-tar.sh
Created Dec 30, 2020
Install an executable into your path from a tar archive
View install-executable-from-tar.sh
# 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 / benchmarking.md
Created Nov 11, 2020
Benchmarking commands for various things
View benchmarking.md

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 / compare-two-lists.md
Last active Nov 17, 2020
Compare Two Lists for Differences
View compare-two-lists.md

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 Oct 21, 2020
Convert JKS (Java Keystore) Files to PEM Files
View convert-jks-to-pem.md

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 Oct 8, 2020
Use Your SSH Agent in a Crontab
View ssh-agent-in-crontab.md

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 Oct 4, 2020
Setup a Mail Server on macOS - No Dependencies Required!
View setup-macos-mail-server.md

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: