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 / Create a new MySQL user.mysql
Last active April 9, 2018 04:52
Create a new MySQL user
-- Let’s start by making a new user within the MySQL shell:
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
-- Sadly, at this point newuser has no permissions to do anything with the databases. In fact, if newuser even tries to login (with the password, password), they will not be able to reach the MySQL shell.
-- Therefore, the first thing to do is to provide the user with access to the information they will need.
GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';
--The asterisks in this command refer to the database and table (respectively) that they can access—this specific command allows to the user to read, edit, execute and perform all tasks across all the databases and tables.
-- Once you have finalized the permissions that you want to set up for your new users, always be sure to reload all the privileges.
FLUSH PRIVILEGES;
@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 local branches except the master branch
Last active November 5, 2018 10:53
Remove local branches except the master branch
###########
# DRY-RUN #
###########
# make sure you are on develop; one cannot ever delete the current branch
$ git checkout develop
# get references
$ git fetch
@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