Skip to content

Instantly share code, notes, and snippets.

Avatar

Justin Hammond Justintime50

View GitHub Profile
@Justintime50
Justintime50 / reset-xcode-install.md
Last active May 29, 2021
Reset Your Xcode Installation on macOS
View reset-xcode-install.md

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

@Justintime50
Justintime50 / install-xdebug-macos.md
Created May 23, 2021
Learn how to install PHP's Xdebug on macOS.
View install-xdebug-macos.md

Install Xdebug on macOS

Installing Xdebug on macOS has changed a lot through the years. The most recent workflow to accomplish this is as follows:

# Install PHP
brew install php
# brew install php@7.4

# Install GNU `sed` and `grep`, installer will fail without them
@Justintime50
Justintime50 / find-php-ini.md
Created May 23, 2021
Find your php.ini File
View find-php-ini.md

Find your php.ini File

I always forget where my php.ini file is and which one is configured. Use the following command to find it:

php -i | grep php.ini

# Output
Configuration File (php.ini) Path => /usr/local/etc/php/7.4
Loaded Configuration File => /usr/local/etc/php/7.4/php.ini
View import-sql-docker.md

Import SQL into a Docker Container

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

docker exec -i CONTAINER_NAME mysql -uUSERNAME -pPASSWORD DATABASE_NAME < MY_FILE.SQL
@Justintime50
Justintime50 / remote-git-repo-default-branch-name.md
Created Apr 13, 2021
Grab the remote repo's default branch name
View remote-git-repo-default-branch-name.md

Grab a Remote Repo's Default Branch Name

git remote show REMOTE_REPO_NAME | grep 'HEAD branch' | cut -d' ' -f5
@Justintime50
Justintime50 / limit-concurrent-threads-python.py
Created Apr 10, 2021
An example of how to limit concurrent threads in Python
View limit-concurrent-threads-python.py
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
Justintime50 / pdb-python.md
Created Apr 7, 2021
Print debugging in Python
View pdb-python.md

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
Justintime50 / working-with-ssh-keys.md
Last active Apr 6, 2021
Run the following commands to generate and copy an SSH key.
View working-with-ssh-keys.md

Working with SSH Keys

Follow this guide to generate an SSH private/public key pair, retrieve it, or send it to a client machine.

Usage

# 1) Generate an SSH Key
ssh-keygen -t rsa
@Justintime50
Justintime50 / git-branch-checker.sh
Created Apr 6, 2021
# Prints the local branches of your git repos to console. Perfect for helping clean up
View git-branch-checker.sh
#!/bin/bash
# Prints the local branches of your git repos to console. Perfect for helping clean up
# USAGE: git-branch-checker.sh "$HOME/git"
main() {
echo "Getting branches of each project"
check_git_branches "$1"
}
@Justintime50
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] + ":"