Useful snippets

Quit Caddy process

Sun 22. October 2023 | 2023-10-22

  1. Try: sudo ps -eaf | grep -i caddy
  2. Try: sudo -s (Enter sudo shell)
    1. caddy stop
    2. exit

PHP White screen

Sun 22. October 2023 | 2023-10-22

echo "<pre>";
ini_set('display_errors', 'On');
ini_set('html_errors', 0);

Skal kanskje være ini_set('html_errors', 'On');?

Ohmybash

Sun 22. October 2023 | 2023-10-22

Hvordan starte med ohmybash, velge theme og laste ned nødvendig font icons

Installasjon

bash -c "$(curl -fsSL https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh)"

Du får med masse aliases med dette. List alle med alias

Velge theme

nano ~/.bashrc
OSH_THEME="agnoster"

Save & exit: ctrl + x, y, [Enter]

Reload:

. ~/.bashrc

Hvis du har mellomrom i path to oh-my-bash insallation, slik:

# Path to your oh-my-bash installation.
export OSH=/c/Users/Pål Stakvik/.oh-my-bash

Må du enkapsulere path-en i quotes, ellers får du error

skaffe nødvendige font icons

evt. se på agnoster-zsh-theme

last ned Hack-fonten

  1. Gå til https://sourcefoundry.org/hack/ og last ned font. Windows executable funker for WSL og VS Code
  2. Kjør executable i nedlastninger
  3. Godta restart

Sette WSL til å bruke riktig font

  1. Åpne WSL
  2. høyreklikk toppmeny, velg 'properties'
  3. velg "Hack" fonten

ubuntu-omb

Sette VS Code til å bruke riktig font

  1. ctrl + shift + p
  2. settings.json
  3. lim inn "terminal.integrated.fontFamily": "Hack", https://stackoverflow.com/questions/37895501/display-issue-with-oh-my-zsh-agnoster-theme#answer-38475948

vscode-omb

Erstatte user @ hostname

...Med kun hostname:

prompt_context() {
  if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
    prompt_segment black default "$USER"
  fi
}

Eller hva det skal være:

prompt_segment black default "P"

image (9)

prompt_segment black default "%(!.%{%F{yellow}%}.)$USER" skal visstnok også funke, men jeg får bare slik tekst da:

image (8)

Git bash merknader

Får du permission denied ved git add .?

  • Kjør VS Code som administrator

Får du

hint: Waiting for your editor to close the file... 'C:\Users\Pål' is not recognized as an internal or external command,
operable program or batch file.
error: There was a problem with the editor '"C:\Users\Pål Stakvik\AppData\Local\Programs\Microsoft VS Code\bin\code.cmd" --wait'.
Please supply the message using either -m or -F option.

ved git commit (-v)

  • Prøv å kjør git config --global core.editor "code --wait". Les mer https://stackoverflow.com/questions/52195877/how-can-i-fix-git-commit-error-waiting-for-your-editor-to-close-the-file-wi

Oh my bash adding missing code completions

Sun 22. October 2023 | 2023-10-22

source /usr/share/bash-completion/completions/git
__git_complete gco _git_checkout
__git_complete gb _git_branch
__git_complete gbs _git_bisect
__git_complete ga _git_add
__git_complete gcmsg _git_commit
__git_complete gcs _git_commit
__git_complete gd _git_diff
__git_complete gl _git_pull
__git_complete gp _git_push
__git_complete gm _git_merge

npm link library

Sun 22. October 2023 | 2023-10-22

Hvis ting i library ikke oppdatere seg på appen gjennom npm run build så kan du prøve å restarte app serveren. npm run dev altså EDIT 16.08.23 Dette er tredje gangen dette skjer og jeg er fortsatt helt overrasket ov uvitende om hva jeg skal gjøre når jeg ser det EDIT 27.09.2023 EDIT EDIT EIDT EDIT EDIT EDIT EDIT kan hende du må npm unlinke hele library-et også legge det til igjen først

Syntax highlighting i Nano commit diff

Sun 22. October 2023 | 2023-10-22

nano ~/.nanorc

sett inn

https://gist.github.com/keithamus/736220/5e069767b22841610ee18fd2f92bd6026f5eb41d

syntax "gitcommit" "COMMIT_EDITMSG$"
color white "#.*"
color green "#.(modified|added|deleted|unmerged|copy-edit|rename).*"
color yellow start="# Changes.*" end="# Changed.*"
color brightgreen "^\+.*"
color brightred "^-.*"
color brightyellow "(diff|index|---|\+\+\+).*"
color brightmagenta "@@.*"
color white "# Changes .*"
color white "# Changed .*"
color white "#.*\(use .*"
color white "#$"

=

farger i git commit vinduet!

log variable with key

Sun 22. October 2023 | 2023-10-22

VS Code snippet

  "Print variable to console": {
    "scope": "javascript,typescript",
    "prefix": "logvar",
    "body": "console.log('$1', $1)"
  }

List processes

Sun 22. October 2023 | 2023-10-22

netstat -nlp | grep tcp

eg: tcp6 0 0 :::3000 :::* LISTEN 1686/node

killall -9 _process_id_

eg: killall -9 1686