Skip to content

Instantly share code, notes, and snippets.

View skounis's full-sized avatar

Stavros Kounis skounis

View GitHub Profile
@skounis
skounis / purge.md
Last active February 15, 2022 06:12
Purge MySQL Binary logs

To show binary logs

mysql> SHOW BINARY LOGS;
mysql> PURGE BINARY LOGS BEFORE '2021-01-01 00:00:00';

Disable

@skounis
skounis / composer-patch-example.json
Created January 11, 2022 10:02
Apply Drupal 9 patches with composer - example
"extra": {
"enable-patching": true,
"patches": {
"drupal/core": {
"Comments are not filtered on language": "https://www.drupal.org/files/issues/2020-07-02/comments-comments_are_not_filtered_on_language-2751267-33.patch",
}
}
}
@skounis
skounis / composer-patches.json
Last active January 11, 2022 10:11
Apply Drupal 9 patches with composer - patch
"extra": {
"enable-patching": true,
"patches": {
"drupal/core": {
"{patch-1 description}": "{patch-1 file path or URI}",
"{patch-2 description}": "{patch-2 file path or URI}",
}
}
}
@skounis
skounis / require-composer-patches.sh
Last active January 11, 2022 09:51
Apply Drupal 9 patches with composer - require
composer require cweagans/composer-patches
@skounis
skounis / convert.sh
Created January 3, 2022 16:51
Find and convert files ending with CRLF to LF
#
# Reference
# https://www.baeldung.com/linux/find-convert-files-with-crlf
#
grep -rIl -m 1 $'\r' | xargs -P0 -I {} dos2unix {}
@skounis
skounis / .htaccess
Created January 3, 2022 09:24
Prevent listing and redirect to a subdirectory with .htaccess
Options All -Indexes
RedirectMatch ^/$ /site/
@skounis
skounis / .htaccess
Created December 22, 2021 07:10
Protect dumps and shell scripts with .htaccess
# Protect dumps and shell scripts
<Files ~ "\.sql$">
Deny from all
</Files>
<Files ~ "\.sql.gz$">
Deny from all
</Files>
<Files ~ "\.sh$">
@skounis
skounis / stop-kill.sh
Created December 1, 2021 10:44
Stop / Kill all the docker containers
#
# Source
# https://typeofnan.dev/how-to-stop-all-docker-containers/
#
# Stop
docker stop $(docker ps -q)
# Kill
docker kill $(docker ps -q)
@skounis
skounis / dump-nocache.sh
Last active November 14, 2023 14:09
Dump Drupal DB without cache tables with drush
# Without cache
drush sql-dump --structure-tables-list=cache,cache_* > dumpfile.sql
# Without cache, search index and watchdog
drush sql-dump --structure-tables-list=cache,cache_*,search_index,watchdog > dumpfile.sql
# Without table spaces
drush sql-dump --structure-tables-list=cache,cache_*,search_index,watchdog --extra-dump="--no-tablespaces --column-statistics=0 --set-gtid-purged=OFF" > db.sql
@skounis
skounis / git-rebase-and-sign.sh
Created November 9, 2021 10:55
Retroactively Sign Git Commits
# First read
# https://webdevstudios.com/2020/05/26/retroactively-sign-git-commits/
#
# 1. Change into the working branch the commits were made
# 2. Rebase and go back `~xx` commits. For example last two
git rebase -i HEAD~2
# 3. Replace "pick" with "rework" in the next prompt and save.
# 4. Push
git push --force-with-lease