Skip to content

Instantly share code, notes, and snippets.

View jsyzdek's full-sized avatar

Jay Syzdek jsyzdek

View GitHub Profile
@jsyzdek
jsyzdek / gitr.sh
Created September 9, 2023 15:16
GIT reset current branch and remove untracked files
# git clean is destructive, particularly if you have .env files
# and/or /vendor or /node_modules directories.
# Instead, use this to reset your current branch back before a pull or something.
#
# Personally, I keep this in my ~/.bashrc file so it's available on session boot.
alias gitr='git reset --hard && git ls-files --others --exclude-standard | xargs rm'
@jsyzdek
jsyzdek / git-prune-local
Last active September 9, 2023 15:19
Remove all your local git branches but keep master
# WARNING - This is a destructive process. It literally
# removes all local branches except master.
#
# If you make a mistake, there _is_ a way to get back a
# branch using `git reflog` however, why risk it?
git checkout master
git branch | grep -ve "master$" | xargs git branch -D
@jsyzdek
jsyzdek / php-install.sh
Last active September 9, 2023 15:19
common packages to install for Laravel
sudo apt-get update
sudo apt install composer mysql-server -y
sudo apt install php7.4 php7.4-cli php7.4-common php7.4-mysql php7.4-xml php7.4-xmlrpc
php7.4-curl php7.4-gd php7.4-imagick php7.4-cli php7.4-dev php7.4-imap php7.4-mbstring
php7.4-opcache php7.4-soap php7.4-zip php7.4-intl php7.4-fpm php7.4-json
php7.4-bcmath -y
sudo mysql_secure_installation
#remember that now, root user requires sudo to log in:
sudo mysql -uroot -p
#>>>>>>>>>>>>>>>>>>
@jsyzdek
jsyzdek / gitrewrite.sh
Last active September 9, 2023 15:21
git rename person
# This allows you to go back and rewrite the commiters in your
# git history. For example, if you accidentally had "server"
# as your git name.
#
# You can put this in a shell script or run from the command line,
# just be sure to change the values first of course.
git filter-branch --env-filter '
WRONG_EMAIL="wrong@example.com"
NEW_NAME="New Name Value"
@jsyzdek
jsyzdek / git-oneline.sh
Last active September 9, 2023 15:23
Show recent commits in a nicely formatted way
# just do `gitl` from the command-line and you will get a nicely formatted
# commit list.
# Defaults to the most recent 15, but if you add a number you can go as far
# back as you like: `gitl 100`
function gitl () {
NUMBER="${1:-15}"
git log -n $NUMBER --pretty=format:"%C(yellow)%h %C(auto,magenta)%>(12)%ad %Cgreen%<(7)%aN%Cred%d %Creset%s"
}
@jsyzdek
jsyzdek / loadssh.sh
Last active September 9, 2023 15:25
auto load ssh keys
# if your ~/.ssh/config file isn't cutting it for some reason,
# use this. Add as many ssh-add lines as you want.
eval $(ssh-agent -s) > /dev/null
ssh-add ~/.ssh/private-key > /dev/null
@jsyzdek
jsyzdek / sudo openconnect.sh
Last active September 9, 2023 15:26
openconnect without password
# If you want to connect to a vpn using openconnect from the command-line
# you can use this. I had it working with Citrix, and works with OpenVPN too.
echo 'password' | sudo openconnect --user=username --passwd-on-stin vpnurl.com