Skip to content

Instantly share code, notes, and snippets.


Justin Hammond Justintime50

View GitHub Profile

Import SQL into a Docker Container

Need to import SQL into a Docker container? Use this simple command:

Justintime50 /
Created Apr 13, 2021
Grab the remote repo's default branch name

Grab a Remote Repo's Default Branch Name

git remote show REMOTE_REPO_NAME | grep 'HEAD branch' | cut -d' ' -f5
Justintime50 /
Created Apr 10, 2021
An example of how to limit concurrent threads in Python
import time
from threading import BoundedSemaphore, Thread
def main():
max_num_threads = 100
thread_limiter = BoundedSemaphore(max_num_threads)
# OS's have limits on the number of threads that can be opened at once,
# be aware of that with this number (eg: don't try something like 10,000+)
Justintime50 /
Created Apr 7, 2021
Print debugging in Python

Print Debugging in Python

If ever you need to debug in Python, add the following where you'd like to start debugging.

import pdb; pdb.set_trace()
Justintime50 /
Created Apr 6, 2021
# Prints the local branches of your git repos to console. Perfect for helping clean up
# Prints the local branches of your git repos to console. Perfect for helping clean up
# USAGE: "$HOME/git"
main() {
echo "Getting branches of each project"
check_git_branches "$1"
Justintime50 / emotify.js
Created Mar 8, 2021
Make emoticons from letters, great for Slack messages
View emotify.js
// Make emoticons from your letters for Slack
let words = "Alright fine, I did the needful and joined you.";
words = words.replace(/[.,/#!$%^&*;:{}=\-_`'~()]/g, "")
function emotify() {
let w = words.split("");
for (let i = 0; i < w.length; i++) {
if (w[i] !== " ") {
w[i] = ":cs-" + w[i] + ":"
Justintime50 /
Created Feb 21, 2021
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

# Install dnsmasq
brew install dnsmasq
sudo brew services start dnsmasq

# Configure
Justintime50 /
Created Feb 9, 2021
Move a commit to another branch

Move Commit to Another Branch

New Branch

git branch newbranch
git reset --hard HEAD~1
git checkout newbranch
Justintime50 /
Last active Feb 8, 2021
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.



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

Justintime50 /
Last active Feb 6, 2021
Guide on how to Update a Branch Name

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>