Skip to content

Instantly share code, notes, and snippets.

View joram77's full-sized avatar

Joram Declerck joram77

View GitHub Profile
# B from C fromdomain D frompath E statuscode F to G rewriterule(formula below)
="if ($host = """&C8&""") { rewrite ^"&REGEXREPLACE(regexreplace(B8,"(.+)\?(.*)","$1"),"^(https://|http://)([^/]+)(.+)","$3")& "$ "& F8 &"? permanent; }"
# C fromdomain (formula below)
=index(split(B3,"/"),0,2)
sudo badblocks -sv /dev/sda > bad-blocks-result
sudo fsck -t ext4 -l bad-blocks-result /dev/sda1
----
sudo add-apt-repository universe
sudo apt-get install hfsprogs hfsplus
sudo fsck.hfsplus /dev/sda2
@joram77
joram77 / Makefile
Last active December 6, 2022 09:50
Xdebug makefile to quickly turn off and on xdebug extension in PHP-fpm container and reload service
DOCKER_CP_XDEBUG_ON=docker cp docker/php-fpm/docker-php-ext-xdebug-on.ini php-fpm_1:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
DOCKER_CP_XDEBUG_OFF=docker cp docker/php-fpm/docker-php-ext-xdebug.ini php-fpm_1:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
.PHONY: about xdebug-on xdebug-off
about:
echo "Xdebug Makefile https://github.com/joram77 - Joram Declerck"
echo "- Install: copy contents to Makefile in your project"
echo "- Usage: make xdebug-on or make xdebug-off"
%div.button
= render layout: 'folder/link_layout', locals: {link: link} do
= button_contents_variable
#folder/_link_layout.html.haml contents:
%a{href: link}
= yield # contents of button_contents_variable will be nested in the %a tag
# inspired by https://stackoverflow.com/questions/35933558/unexpected-error-using-yield-in-haml-nesting
zend_extension=xdebug
[xdebug]
xdebug.mode=debug # develop has impact on performance
xdebug.client_port = 9000
xdebug.idekey=PHPSTORM
xdebug.client_host=host.docker.internal
SELECT * FROM information_schema.tables
select schema_name as database_name from information_schema.schemata order by schema_name;
# copy current dir
cp -rv . ~/backup/$(basename "$PWD").bak.$(date '+%Y-%m-%d_%H-%M-%S')
# or tar current dir
tar -cvzf ~/backup/$(basename "$PWD").bak.$(date '+%Y-%m-%d_%H-%M-%S').tar.gz .
# tar current dir and exclude dot dirs/files in root to tar
tar --exclude="./.*" -cvzf /tmp/backup/$(basename "$PWD").bak.$(date '+%Y-%m-%d_%H-%M-%S').tar.gz .
@joram77
joram77 / install-mailhog-mhsendmail-macos.md
Last active July 17, 2021 07:46
Set up mailhog and configure PHP sendmail to use mhsendmail on macos

Mailhog and mhsendmail as PHP sendmail on macos

Useful for intercepting all PHP mails in a web interface when developing on your localhost. This uses the mhsendmail command for the PHP configuration instead of the normal sendmail command to avoid sending mails to the WWW when testing.

  1. install go
  2. install mhsendmail
    go get github.com/mailhog/mhsendmail
    
@joram77
joram77 / wordpress-cli-reset-user-password.sh
Created July 17, 2021 07:25
Wordpress cli reset user password
wp user update user@example.com --prompt=user_pass
# or alternatively
wp user update user@example.com --user_pass="YourSuperSecurePassword"