Showing posts with label Terminal. Show all posts
Showing posts with label Terminal. Show all posts

University of Illinois CS_400: Object-Oriented Data Structures in C++

I decided to take a refresher on my C++ skills.

The University of Illinois (U-C) had a class on Coursera: "Object-Oriented Data Structures in C++"

https://www.coursera.org/learn/cs-fundamentals-1

The funny thing is, that I actually learned C/C++ at the University of Illinois (UIC), just over 20 years ago!


Getting the instructor's code:
Uki@iMac 18:38 Coursera_OO_data_structures_Cpp $ cd ..
Uki@iMac 18:38 _REPOS $ git clone https://github.com/wadefagen/coursera.git coursera-cs400
Cloning into 'coursera-cs400'...


Setting up macOS for C++

I am following these instructions:

Install Apple XCode


$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates


IMPORTANT, if you get Xcode errors when running the make command, execute this command:

sudo xcode-select --reset




by the way, I cannot get XCode IDE because my 2012 iMac is outdated and does not support higher macOS:





Getting BREW


$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"


the above will take quite a few minutes.

Once BREW is installed, install the following:

brew install ghostscript
brew link --overwrite freetype
 
brew install imagemagick

brew link --overwrite libtool

 

brew install graphviz 
brew install cmake


brew edit valgrind



This will open your default code editor. In the opened file, change the URL in the head section from https://sourceware.org/git/valgrind.git 
to 
git://sourceware.org/git/valgrind.git 
and run the following:

brew update brew install --HEAD valgrind


Test MAKE



$ cd /Volumes/GoogleDrive/My\ Drive/_REPOS/coursera_wadefagen/cpp-std
cpp-std $ make




xcrun: error: active developer path ("/Volumes/SSD500GB/Applications/Xcode.app/Contents/Developer") does not exist
...





Uki@iMac 02:03 cpp-std $ sudo xcode-select --reset
Password:

Uki@iMac 02:07 cpp-std $ make
g++ -std=c++14 -O0 -pedantic -Wall -Wfatal-errors -Wextra -MMD -MP -g -c main.cpp -o .objs/main.o
g++ -std=c++14 -O0 -pedantic -Wall -Wfatal-errors -Wextra -MMD -MP -g -c Cube.cpp -o .objs/Cube.o
g++ .objs/main.o .objs/Cube.o -std=c++14 -o main
g++ cout.cpp -std=c++14 -o cout
g++ cout2.cpp -std=c++14 -o cout2
Uki@iMac 02:08 cpp-std $ open .



Uki@iMac  02:10 cpp-std $ ls -alt

total 96

drwx------@ 1 Uki  staff    16K Aug 12 02:10 ../

drwx------@ 1 Uki  staff    16K Aug 12 02:08 ./

-rwx------@ 1 Uki  staff    54K Aug 12 02:08 cout*

-rwx------@ 1 Uki  staff    54K Aug 12 02:08 cout2*

-rwx------@ 1 Uki  staff    61K Aug 12 02:08 main*

drwx------@ 1 Uki  staff    16K Aug 12 02:08 .objs/

-rwx------@ 1 Uki  staff    26B Aug 10 18:37 .gitignore*

-rwx------@ 1 Uki  staff   368B Aug 10 18:37 Cube.cpp*

-rwx------@ 1 Uki  staff   312B Aug 10 18:37 Cube.h*

-rwx------@ 1 Uki  staff   228B Aug 10 18:37 Makefile*

-rwx------@ 1 Uki  staff   209B Aug 10 18:37 cout.cpp*

-rwx------@ 1 Uki  staff   248B Aug 10 18:37 cout2.cpp*

-rwx------@ 1 Uki  staff   395B Aug 10 18:37 main.cpp*

Uki@iMac  02:14 cpp-std $ ./main

Volume: 13.824

Surface Area: 34.56





Week 2




2.1 Stack Memory and Pointers
https://www.coursera.org/learn/cs-fundamentals-1/lecture/Iccq3/2-1-stack-memory-and-pointers


I got to use Microsoft Code and Terminal properly




How to make the compiled files execute in the command line?


If you get a similar error, you might have to change the mode to execute the file..

zsh: permission denied: ./addressOf

cpp-memory % chmod +x addressOf
cpp-memory % ./addressOf
Value: 7
Address: 0x7ff7b9eef878



















As an Amazon Associate I earn from qualifying purchases.

Installing Pluto.jl notebook for Julia language

 What is pluto.jl

TBD

How to install Julia?

Install Julia language from https://julialang.org/

Start Julia 
    I can do that from Terminal,
    or by clicking an icon
Once Julia's prompt opens,
    click the closing bracket ] to enter the "package mode"


How to Install pluto.jl?


Simply type 


(@v1.7) pkg> add Pluto.jl


The installation is very fast.

Press BACKSPACE to exit the package mode

 Type 



julia> using Pluto
julia> Pluto.run()

At this point, the pluto website should open in your browser:





As an Amazon Associate I earn from qualifying purchases.

How to install Julia language Pluto notebook?

 What is pluto.jl

TBD

How to install Julia?

Install Julia language from https://julialang.org/

Start Julia 
    I can do that from Terminal,
    or by clicking an icon



How to Install pluto.jl?


Once Julia's prompt opens,
    click the closing bracket ] to enter the "package mode"



% julia
(@v1.7) pkg> add Pluto.jl

This will take a few moments.


How to stop a Julia prompt? 

julia> exit()


The installation is very fast.

Press BACKSPACE to exit the package mode

What do I need to do before running Pluto notebook?

I have learned that it is wise to change to the directory you want to work with. 

The support of Pluto notebook to jump thru many directories up or down is very sketchy.




cd /Volumes/_MY_DIRECTORIES_/Julia/Brilliant/
Brilliant % julia
julia> pwd()

How to run Pluto notebook in Julia?


julia> using Pluto
julia> Pluto.run()

At this point, the pluto website should open in your browser:





As an Amazon Associate I earn from qualifying purchases.

How to add VS code executable to the command line on macOS?

 







% nano .zprofile

#### VS code - Uki 2022-06-26 ####
## set PATH to "code" executable so it is available directly from Terminal
export PATH="\$PATH:/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin"
## the following line is the key to launch "code" from the command line
alias code='/Applications/Visual\ Studio\ Code.app/Contents/MacOS/Electron'




After adding these lines, save it in NANO by pressing 

control x 

Do not forget to double-check your work.

% cat .zprofile 

And re-run the content of the .zprofile: 

% . ~/.zprofile
 
 


As an Amazon Associate I earn from qualifying purchases.

How to add VS code executable to the command line on macOS?

 







% nano .zprofile

#### VS code - Uki 2022-06-26 ####
## set PATH to "code" executable so it is available directly from Terminal
export PATH="\$PATH:/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin"
## the following line is the key to launch "code" from the command line
alias code='/Applications/Visual\ Studio\ Code.app/Contents/MacOS/Electron'




After adding these lines, save it in NANO by pressing 

control x 

Do not forget to double-check your work.

% cat .zprofile 

And re-run the content of the .zprofile: 

% . ~/.zprofile
 
 


As an Amazon Associate I earn from qualifying purchases.

How to add "julia" executable to the PATH on macOS

 





% nano .zprofile

#### Julia - Uki 2022-06-26 ####
## set PATH to "julia" executable so it is available directly from Terminal
export PATH="\$PATH:/Applications/Julia-1.7.app/Contents/Resources/julia/bin"

Make sure to change to the version of Julia you have, check the path.
After adding these lines, save it in NANO by pressing 

control x 



 Do not forget to double-check your work.

% cat .zprofile


As an Amazon Associate I earn from qualifying purchases.

How to add "julia" executable to the PATH on macOS

 





% nano .zprofile

#### Julia - Uki 2022-06-26 ####
## set PATH to "julia" executable so it is available directly from Terminal
export PATH="\$PATH:/Applications/Julia-1.7.app/Contents/Resources/julia/bin"

Make sure to change to the version of Julia you have, check the path.
After adding these lines, save it in NANO by pressing 

control x 



 Do not forget to double-check your work.

% cat .zprofile


As an Amazon Associate I earn from qualifying purchases.

Is .zprofile replacing .bash_profile in macOS?

 In the macOS 12+ (Monteray, etc.) the .zprofile is replacing .bash_profile



As an Amazon Associate I earn from qualifying purchases.

Is .zprofile replacing .bash_profile in macOS?

 In the macOS 12+ (Monteray, etc.) the .zprofile is replacing .bash_profile



As an Amazon Associate I earn from qualifying purchases.

How to show hidden files in Apple OS X Finder (AppleShowAllFiles)


Open Terminal and execute the following line:

$ defaults write com.apple.finder AppleShowAllFiles YES


As an Amazon Associate I earn from qualifying purchases.

How to show hidden files in Apple OS X Finder (AppleShowAllFiles)


Open Terminal and execute the following line:

$ defaults write com.apple.finder AppleShowAllFiles YES


As an Amazon Associate I earn from qualifying purchases.

XCode

I am receining an error:

xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools

$ xcode-select --install

xcode-select: error: command line tools are already installed, use "Software Update" to install updates
$ sudo xcode-select -switch /Library/Developer/CommandLineTools
Password:



As an Amazon Associate I earn from qualifying purchases.

XCode

I am receining an error:

xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools

$ xcode-select --install

xcode-select: error: command line tools are already installed, use "Software Update" to install updates
$ sudo xcode-select -switch /Library/Developer/CommandLineTools
Password:



As an Amazon Associate I earn from qualifying purchases.

Eclipse: starting from bash command line

I start Eclipse from Bash command line (in Terminal.app) to make sure it reads all Bash Enviroment settings.


function eclipse () {
nohup bash -ic /Eclipse_Luna_4_4/Eclipse.app/Contents/MacOS/eclipse &
echo "disown PID -- prevent eclipse from closing when you close Terminal"
}


As an Amazon Associate I earn from qualifying purchases.

Eclipse: starting from bash command line

I start Eclipse from Bash command line (in Terminal.app) to make sure it reads all Bash Enviroment settings.


function eclipse () {
nohup bash -ic /Eclipse_Luna_4_4/Eclipse.app/Contents/MacOS/eclipse &
echo "disown PID -- prevent eclipse from closing when you close Terminal"
}


As an Amazon Associate I earn from qualifying purchases.

Terminal: set command line prompt and PATH variables in Bash ~/.profile

As a developer you will find yourself using Command Line (Terminal.app) every day, all the time, so it is worthwhile to set it up to behave just right for you...

Open Application > Utilities > Terminal.app (drag it to your toolbar for quick access)

My shell looks like that, it tells me a lot of info just as verification...

Last login: Mon Sep 15 11:56:15 on ttys000
edit ~/.profile
java version "1.8.0_20-ea"
Java(TM) SE Runtime Environment (build 1.8.0_20-ea-b05)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b05, mixed mode)
git version 1.9.0
/Applications/Android/SDK/android-sdk-macosx/platform-tools/adb
uki@ CNH_PROD $ vi ~/.profile


We can use vi editor, but on daily basis I just type "edit ~/.profile"

# ANDROID - updated: Sept 15, 2014
export ANDROID_HOME=/Applications/Android/SDK/android-sdk-macosx
export PATH=${PATH}:${ANDROID_HOME}/build-tools/19.0.3
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
export PATH=${PATH}:${ANDROID_HOME}/tools

echo "edit ~/.profile"
# Adjust prompt.
# \d – Current date
# \t – Current time
# \h – Host name
# \# – Command number
# \u – User name
# \W – Current working directory (ie: Desktop/)
# \w – Current working directory, full path (ie: /Users/Admin/Desktop)
export PS1="\u@ \W $ "
java -version
git version
which adb


To EDIT hit "i" for insert
To Save and Quit you type ESC + :wq + Enter
I have MUCH MORE configurations in there, but it is specific to what you have on your computer.


As an Amazon Associate I earn from qualifying purchases.

Terminal: set command line prompt and PATH variables in Bash ~/.profile

As a developer you will find yourself using Command Line (Terminal.app) every day, all the time, so it is worthwhile to set it up to behave just right for you...

Open Application > Utilities > Terminal.app (drag it to your toolbar for quick access)

My shell looks like that, it tells me a lot of info just as verification...

Last login: Mon Sep 15 11:56:15 on ttys000
edit ~/.profile
java version "1.8.0_20-ea"
Java(TM) SE Runtime Environment (build 1.8.0_20-ea-b05)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b05, mixed mode)
git version 1.9.0
/Applications/Android/SDK/android-sdk-macosx/platform-tools/adb
uki@ CNH_PROD $ vi ~/.profile


We can use vi editor, but on daily basis I just type "edit ~/.profile"

# ANDROID - updated: Sept 15, 2014
export ANDROID_HOME=/Applications/Android/SDK/android-sdk-macosx
export PATH=${PATH}:${ANDROID_HOME}/build-tools/19.0.3
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
export PATH=${PATH}:${ANDROID_HOME}/tools

echo "edit ~/.profile"
# Adjust prompt.
# \d – Current date
# \t – Current time
# \h – Host name
# \# – Command number
# \u – User name
# \W – Current working directory (ie: Desktop/)
# \w – Current working directory, full path (ie: /Users/Admin/Desktop)
export PS1="\u@ \W $ "
java -version
git version
which adb


To EDIT hit "i" for insert
To Save and Quit you type ESC + :wq + Enter
I have MUCH MORE configurations in there, but it is specific to what you have on your computer.


As an Amazon Associate I earn from qualifying purchases.

Android: updating SDK from command line

You may want to create a script "Update Android SDK.bash" that quickly gets you up to speed without starting IDE (e.g. Eclipse) UI.

echo 'Android SDK home ' $ANDROID_HOME
$ANDROID_HOME/tools/android update sdk --no-ui --all --force 



Notice that it will ask you several times to click letter 'y'
Do you accept the license 'android-sdk-license-bcbbd656' [y/n]: y




Installing Archives:
  Preparing to install archives
  Downloading Android SDK Tools, revision 23.0.2
     (15%, 525 KiB/s, 2 minutes left))









As an Amazon Associate I earn from qualifying purchases.

Android: updating SDK from command line

You may want to create a script "Update Android SDK.bash" that quickly gets you up to speed without starting IDE (e.g. Eclipse) UI.

echo 'Android SDK home ' $ANDROID_HOME
$ANDROID_HOME/tools/android update sdk --no-ui --all --force 



Notice that it will ask you several times to click letter 'y'
Do you accept the license 'android-sdk-license-bcbbd656' [y/n]: y




Installing Archives:
  Preparing to install archives
  Downloading Android SDK Tools, revision 23.0.2
     (15%, 525 KiB/s, 2 minutes left))









As an Amazon Associate I earn from qualifying purchases.

Terminal: RSA host key verification error

In case you get below error in your terminal, you can edit your .ssh/known_hosts file in your home directory.
Error:
RSA host key for xx.xxx.xx.xx has changed and you have requested strict checking.
Host key verification failed.
Solution:
- Find and open in your terminal .ssh/known_hosts:
pico ~/.ssh/known_hosts
- Delete all the content for this host and save file.
- When you log in to xx.xx.xx.xx server, it will prompt you to verify that this is a known host and will append permissions to .ssh/known_hosts file.


As an Amazon Associate I earn from qualifying purchases.

apt quotation..