Skip to content

Instantly share code, notes, and snippets.

View Justintime50's full-sized avatar

Justin Hammond Justintime50

View GitHub Profile
@Justintime50
Justintime50 / find-php-ini.md
Created May 23, 2021 05:10
Find your php.ini File

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
@Justintime50
Justintime50 / import-export-sql-docker.md
Last active October 10, 2021 06:39
Learn how to import or export SQL from a Docker Container

Import or Export SQL from a Docker Container

To export SQL, you must have permissions to do so (AKA: root).

# Importing SQL
docker exec -i CONTAINER_NAME mysql -uUSERNAME -pPASSWORD DATABASE_NAME < MY_FILE.sql

# Exporting SQL
docker exec -i CONTAINER_NAME mysqldump -uroot -p DATABASE_NAME &gt; MY_FILE.sql
@Justintime50
Justintime50 / remote-git-repo-default-branch-name.md
Last active January 4, 2023 23:51
Grab the remote repo's default branch name

Grab a Remote Repo's Default Branch Name

git remote show REMOTE_REPO_URL | grep 'HEAD branch' | cut -d' ' -f5
@Justintime50
Justintime50 / limit-concurrent-threads-python.py
Created April 10, 2021 03:46
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
Justintime50 / git-branch-checker.sh
Created April 6, 2021 02:54
# Prints the local branches of your git repos to console. Perfect for helping clean up
#!/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 March 8, 2021 23:42
Make emoticons from letters, great for Slack messages
// 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
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
@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 / 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 / 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