Skip to content

Instantly share code, notes, and snippets.

@boywijnmaalen
boywijnmaalen / Recursively change permissions
Last active April 9, 2018 05:06
Recursively change permissions
# Recursively change permissions on directories only:
$ find . -type d -exec chmod 777 {} \;
# Breaking it down:
# Uses the find command on the current directory .
# -type d tells find to only look for files of type directory
# -exec tells find to perform the following action on each matching file. In this case it was to chmod each directory to 777.
# This same technique can be used to chown directories and/or perform the same actions on only files.
@boywijnmaalen
boywijnmaalen / MAC nginx php-fpm mariadb blackfire
Last active April 9, 2018 05:09
Mac OS X, Nginx, PHP-FPM, Mariadb specifics and blackfire
# For reference;
# Install: https://github.com/OzzyCzech/dotfiles/blob/master/how-to-install-mac.md
# Brew: https://github.com/Homebrew/brew/blob/master/share/doc/homebrew/FAQ.md
# Start LEMP stack:
$ sudo nginx && launchctl load -w /usr/local/opt/php71/homebrew.mxcl.php71.plist && launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.blackfire-agent.plist && mysql.server start
# Stop LEMP stack:
$ sudo nginx -s stop && launchctl unload -w /usr/local/opt/php71/homebrew.mxcl.php71.plist && launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.blackfire-agent.plist && mysql.server stop
@boywijnmaalen
boywijnmaalen / become another user
Last active April 9, 2018 05:10
become another user
# (must sometimes become root first)
$ su <username>
@boywijnmaalen
boywijnmaalen / tig
Last active April 9, 2018 05:10
Tig
# show branch history
$ tig <branch_name>
# compare two branches
$ tig <branch_name>..<branch_name>
@boywijnmaalen
boywijnmaalen / MySQL Compare db1 <> db2.sql
Last active April 9, 2018 05:11
MySQL Compare db1 <> db2
$ mysqldbcompare --server1=<username>:<password>@localhost --server2=<username>:<password>@localhost --difftype=sql --run-all-tests --changes-for=server2 db_name_1:db_name_2
@boywijnmaalen
boywijnmaalen / Change a specific git commit message
Last active April 9, 2018 05:11
Git edit specific commit
$ git commit --amend -c <COMMIT HASH>
@boywijnmaalen
boywijnmaalen / Changing the Git history
Last active April 9, 2018 05:14
Changing the Git history of your repository using a script
# vim git-author-rewrite.sh
# Copy and paste the script, replacing the following variables based on the information you gathered:
```
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="<old email address>"
CORRECT_NAME="<name>"
CORRECT_EMAIL="<new email address>"
@boywijnmaalen
boywijnmaalen / Remove git tags
Last active April 9, 2018 05:14
Remove git tags
# removes all tags remotly
$ git tag -l | xargs -n 1 git push --delete origin
# removes all tags locally
$ git tag | xargs git tag -d
@boywijnmaalen
boywijnmaalen / Copy file from server A to server B
Last active April 9, 2018 05:14
scp (Copy) file from server A to server B
# To copy a file from B to A while logged into B:
$ scp /path/to/file username@a:/path/to/destination
# To copy a file from B to A while logged into A:
$ scp username@b:/path/to/file /path/to/destination
@boywijnmaalen
boywijnmaalen / git commandos
Last active April 9, 2018 05:14
Git Commandos
# how to retrieve the hash for the current commit in Git?
$ git rev-parse HEAD
# how do I delete a tag from a Git repo?
$ git tag -d release01
$ git push origin :refs/tags/release01