zackarno / boring_but_important_notes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compilation of boring but important notes

This repo contains notes for myself that I'd rather not spend time googling again.

Python

pyenv for env & python

  • clone or create new repo
  • You can check if you already have the python version required by running pyenv version. If not you need to install with pyenv install x.y.z you can see all the available versions with pyenv install --list. I had the issue where pyenv install --list did not show the required version. I followed the 2nd advice in this GH Issue first to brew upgrade pyenv since I installed it w/ brew. However, this didn't work. Therefore I followed the first advice to get pyenv update to work by following instruction to clone pyenv update and then ran pyenv update which worked.
  • Interestingly the command below will then control both the python version and your virtual env. Don't try to set the local python version with pyenv local x.y.z
  • open in vscode pyenv virtualenv 3.x.x name-of-repo this will create a pyenv managed virtual environment inside the pyenv directory (not repo directory)
  • however from an project you can just call pyenv activate name-of-venv to activateit
  • for jupyter you will need to to
    1. pip install ipykernel in correct activated env
    2. python -m ipykernel install --user --name name-of-env --display-name "name-of-env". Example: python -m ipykernel install --user --name ds-raster-pipeline s --display-name "ds-raster-pipelines"
    3. Then when you open jupyter/jupyter lab the kernel will be recognized....Note you can have just one version of jupyter installed in you base pyenv version and when you open it you will be able to access the kernels after following steps 1 & 2. I only realized I hadn't done this so I had to run: a. pyenv deactivate - > pyenv which python (to make sure i was in pyenv/3.11.4 but not project specific venv) -> pip install jupyterlab

R/R-studio Linux

  • followed R-studio/CRAN directions for installing R
  • as of 2022-09-25 Rstudio dependencies create issue Rstudio desktop installation for Ubuntu. Browsing revealed some work-arounds, but simplest option seemed to be to download directly from daily builds for Ubuntu which should work out of box. This solution was posted here.
  • I downloaded rstudio-2022.07.3-578-amd64.deb which worked fine For getting packages up and running I followed this link... but basically:
  • To use install.packages() you need to install r-base-dev via terminal with sudo apt install r-base-dev
  • Some R packages (i.e tidyverse) depend on non R packages which should be installed via terminal first with: sudo apt install libcurl4-openssl-dev libssl-dev libxml2-dev

QGIS

Linux

Installing QGIS on Linux

Mac

  • Open multiple QGIS instances at once: in terminal - open -n /Applications/QGIS.app
  • I updated QGIS and non of the layers in my local postgres db would load. Running brew upgrade abseil seemed to have resolved it! will report back if it broke other processes/apps

multiple GHs

on windows

  • ssh-keygen -t rsa -b 4096 -C "<personal file comment>" -f ~/.ssh/<personal file name>

  • eval $(ssh-agent -s)

  • ssh-add ~/.ssh/<personal file name>

  • clip < ~/.ssh/<personal public name (i.e .pub)

  • go to github -> settings -> ssh key -> paste

  • ssh -T git@github.com (should say successful)

  • Repeat above steps to make another ssh key and add it to the other GH acccount

  • I tried editing config file in ~/.ssh/ folder as directed, but it does not yet seem to be picking the instructions correctly

  • at this stage I need to keep using ssh-add correct rsa file prior to pushing to the correct GH - it does not seem to automatically register the rsa/creds

  • unclear if user would auto chage -- it seems by running global config --user.email=xxx@yyy.org this fixes ... however restarting computer also semeed to sort i out

  • first time pushing the -u flag seems critical (didn't work without): git push -u origin master

  • git remote set-url origin can be used to change remote rather than removing and adding

On Mac

  • easier -- pretty much just follow instructions on github docs here, but basically set up the config file as in this youtube video... should look into keychain
  • Important When using git remote set-url origin or git clone you need to use ssh url and include your Host listed in config file (12:20 in video) within the ssh url. Hint leave personal/default just as github.com and you wont need to change the url. In this case will just modify when using other accounts

on linux

  • ssh-keygen -t ed25519 -C "youremail@domain.com"
  • Enter file in which to save the key (/home/{user}/.ssh/id_ed25519): /home/{user}/.ssh/{custom_name}
  • eval "$(ssh-agent -s)"
  • ssh-add ~/.ssh/{custom_name} (should then say identity added)
  • cat ~/.ssh/{custom_name}.pub copy contents to clipboard and make new key in GH setting
  • test authentication with ssh -T git@github.com

Git

  • How to undo commit + push (from here) : git reset --hard HEAD^ , then git push -f
  • --hard will restore to state of last commit
  • --soft will restore workind directory to state just before last commit (useful if you want to fix staging/commit messages)
  • to just unstage changes run git reset HEAD -- won't remove from directory just staging

{targets}

I've trouble shot this same problem more than once even though it's very simple. When tar_load_everything() gives error it's often because targets/names are no longer in pipeline. Quickest fix is targets::tar_prune()

postgresl mac

  • downloaded qgis
  • homebrew install postgresql
  • installed pgadmin 4 from dmg
  • combine these

Mac terminal

  • caffeinate -i -s Rscript -e 'targets::tar_make()'
  • caffeinate -i -s Rscript run.R

Sometimes when running a background process in terminal that require a lot of files open in memory can run into error. In this case

  • ulimit -n 100000 # 100000 is just an example and likely way more than enough, probably smart to adjust to less.

  • After updatin R to silicon arm64 version I could now longer run R out of the terminal (i.e caffeinate -i -s Rscript -e 'targets::tar_make()') . This seemed to be b/c it was not correctly identifying the .libPaths() . I messed around with .zshrc quite a bit, but eventually only solution was just brew uninstall r to get rid of the homebrew version. At the time I updated to arm version it was not on hombrew.

Force RGB

Logitech

1+fn+F13 (should be able to find mac forum add link here)

Shiny

  • browser() does not work interactively to debug flex_dashboard() instead use rmarkdown::run("my-dashboard.Rmd") GH issue

About