This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # For installation and overview: | |
| # - https://github.com/pyenv/pyenv | |
| # - https://github.com/pyenv/pyenv-virtualenv | |
| # Note all the changes required to dot files | |
| # Example usage *once installed* - using Python 3.10.4 for project in ~/lab/project | |
| # Install Python version | |
| pyenv install 3.10.4 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # Uninstall | |
| # Check directory for installation is correct, delete folder and all files, check it's been removed | |
| xcode-select -p | |
| sudo rm -rf /Library/Developer/CommandLineTools | |
| xcode-select -p | |
| # Re-install, then check which directory it's been installed into | |
| xcode-select --install | |
| # Confirm and monitor installation through the dialog window that opens | |
| xcode-select -p | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # Currently using uninstall/install--would be good to see if can use brew cask upgrade, or just install new version side-by-side | |
| brew cask uninstall r | |
| brew cask install r | |
| # Performance without linking BLAS (vecLib) from Apple's Accelerate Framework, i.e. *no* default multi-threading | |
| Rscript -e "sessionInfo()" | |
| Rscript -e "d <- 2e3; system.time({ x <- matrix(rnorm(d^2),d,d); tcrossprod(x) })" | |
| # Link Apple's BLAS to make R run multi-threaded by default where possible and note performance boost | |
| ln -sf \ | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import socket | |
| def check_internet(host="8.8.8.8", port=53, timeout=3): | |
| # Checks for internet connection by testing to see if it can make a socket connetion to (host, port) | |
| # Host: 8.8.8.8 (google-public-dns-a.google.com) | |
| # Port: 53/tcp | |
| try: | |
| sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| sock.settimeout(timeout) | |
| sock.connect((host, port)) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | confirm_continue_yN() { | |
| # Asks user to confirm to proceed | |
| # $1 is the confirmation message, usually a question | |
| # $2 is the abort message | |
| # Converts user input to lower case before regex check for 'y' or 'yes' | |
| # If it's not one of those responses then exits the script echoing the abort message | |
| read -r -p "$1 [y/N] " response | |
| response_lowercase=$( echo "$response" | awk '{print tolower($0)}' ) | |
| if [[ ! "$response_lowercase" =~ ^(yes|y)$ ]] | |
| then |