Skip to content

Instantly share code, notes, and snippets.

View joram77's full-sized avatar

Joram Declerck joram77

View GitHub Profile
@joram77
joram77 / sshfs_correctly_write_mount_with_private_key.txt
Last active November 9, 2022 22:28
Unable to write mount remote disk with SSHFS: permission denied writing files/folders on mapped drive
Problem: cannot write to mounted folder via SSHFS , permission denied
Solution: use the right switches to map the remote user AND explicitly state identity file
sshfs -o allow_other,defer_permissions,IdentityFile=~/.ssh/id_rsa_mycompany surfer@example.com:/ ~/example_local_mount_point/
The file system may not always do the right thing itself though--for example, if the file system retrieves file information from another computer and reports user/group IDs as is, the kernel will not see any alien IDs as belonging to the user that mounted the volume. (This can happen if user ID translation is not enabled or sometimes doesn't work with sshfs.) The
The defer_permissions (formerly defer_auth) option is useful in such cases. It causes osxfuse to assume that all accesses are allowed--it will forward all operations to the file system, and it is up to somebody else to eventually allow or deny the operations. In the case of sshfs, it would be the SFTP server eventually making the decision about what to allow or disal
@joram77
joram77 / tomcat_windows_service_change_java_XmX_Xms_params.md
Last active March 30, 2020 15:42
Tomcat windows service change java XmX Xms params via registry keys

registry key

HKLM\Software\Wow6432Node\Apache Software Foundation\Tomcat8\Parameters\Java

Values

JvmMs eg. 512
JvmMx eg. 4096

start "HTTP 200 logs" "C:\cygwin64\bin\bash.exe" --login -i "/cygdrive/c/checkWebapp\checkHttp200.sh"
function setObjectPropertiesFromArray(Entity $item): void
{
foreach ($_POST as $var => $value) {
if (is_callable(array($item, "set" . ucfirst($var)))) {
$item->{"set" . ucfirst($var)}($value);
}
}
/** Substring of a given string until the first space occuring before the given max length. **/
function substringUntilSpace(start, length, s) {
let trimmedString;
if (s.length > length) {
trimmedString = s.substr(start, length);
if (s.charAt((start + length)) != ' ') {
const lispace = trimmedString.lastIndexOf(" ");
if (lispace != -1) trimmedString = trimmedString.substr(start, lispace);
}
} else trimmedString = s;
@joram77
joram77 / xpath-text-contains.txt
Created July 17, 2021 07:19
Xpath text contains
//*[text()[contains(.,'TEXT HERE')]]
@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"
@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
    
# 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 .
select schema_name as database_name from information_schema.schemata order by schema_name;