Menu

Sviluppo Posts

Risolvere “Using $this when not in object context” in closure

Cosa ho imparato oggi: come risolvere l’errore “Using $this when not in object context” quando si lavora con una closure.

E’ semplice, si usa il metodo bindTo() della closure:

if (is_callable($closure)) {
    $closure = $closure->bindTo($this, $this);
    $closure(); // Call your closure as you wish!
}

Continua

Eliminazione veloce di directory con tanti file (es. node_modules)

Cosa ho imparato oggi: come eliminare velocemente una directory con tanti file (es. node_modules).

Salva questo file in FastDelete.reg, eseguilo per aggiungere il comando Fast Delete al tasto destro del mouse su una cartella.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\Fast Delete]
"Position"="Top"
"icon"="C:\\Windows\\explorer.exe"

[HKEY_CLASSES_ROOT\Directory\shell\Fast Delete\command]
@="\"C:\\Windows\\System32\\cmd.exe\" /Q /S /C \"echo DELETING... & DEL /F /Q /S \"%1\" > NUL & RMDIR /Q /S \"%1\"\""

Continua

Riavviare Apache su CentOS

Cosa ho imparato oggi: come riavviare Apache su CentOS:

## Start ##
service httpd start
## Stop ##
service httpd stop
## Restart ##
service httpd restart

Continua

Cercare file per contenuto in Linux

Cosa ho imparato oggi: come cercare file per contenuto in Linux.

grep --include=*.php -rnw '/path/to/somewhere/' -e "pattern"

Continua

events.js: 183 throw er; // Unhandled ‘error’ event

Cosa ho imparato oggi: come risolvere l’errore di Node.js: events.js: 183 throw er; // Unhandled ‘error’ event

rm -rf node_modules
rm package-lock.json yarn.lock
npm cache clear --force
npm install

Continua