Setting up a Software Development Environment for Mac OS, Ubuntu Linux and Windows


 

INTRODUCTION

I show how to set up a software development environment for Mac OS Ubuntu Linux and Windows When we're done, we'll be able to develop programs in C, C++, Python, Javascript, and Lisp using Unix tools.

SYSTEM SETUP - Ubuntu Linux

Ubuntu Linux on a MacBook

You can run Ubuntu on a Mac. But it's easier on an older Mac which doesn't have the recent security features.

Macbook
Preliminaries

I will install on an old MacBook Pro (17-inch, Early 2009) running OS X El Capitan Version 10.11.6 (15G31).

Macbook

You can read through these excellent guides on Install Linux on a Mac and how to dual boot Linux and Mac OS I took a little from both and from the Ubuntu web site documentation.

Installing the Boot Loader

The Mac's own boot manager has problems recognizing the Ubuntu OS. Thus you need to install a third party EFI (Extensible Firmware Interface) boot manager to be able to dual boot the Mac into Ubuntu or Mac OS. Visit the rEFInd Boot Manager Web Page. Download rEFIfind version refind-bin-0.11.2.zip

Downloading rEFFind

Disable SIP (System Integrity Protection) so you can install the boot loader. Shut down the Mac for 30 seconds. Then reboot in recovery mode. You can hold down the Option key and select the Recovery Disk. Select Terminal from the OSX Utitities menu bar and type csrutil disable. Then reboot again.

Unzip and install. You'll see I've already installed it once before.rEFInd

Gauss:refind-bin-0.11.2 sean$ sudo ./refind-install ShimSource is none Installing rEFInd on OS X.... Installing rEFInd to the partition mounted at /Volumes/ESP Found rEFInd installation in /Volumes/ESP/EFI/refind; upgrading it. Found suspected Linux partition(s); installing ext4fs driver. Installing driver for ext4 (ext4_x64.efi) Copied rEFInd binary files Notice: Backed up existing icons directory as icons-backup. Existing refind.conf file found; copying sample file as refind.conf-sample to avoid overwriting your customizations.

Now Shut Down your Mac.

Disk Drive and Partitions

Bring up the Disk Utility and resize your Mac OS partition smaller to give more room to Ubuntu. If you have extra non-contiguous partitions which you cannot merge, you can at least format them as ExFat so Linux can see them later.

In detail, here are our disk partititions,

Seans-MBP:~ sean$ diskutil list /dev/disk0 (internal, physical): #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *320.1 GB disk0 1: EFI EFI 209.7 MB disk0s1 2: Linux Filesystem 130.0 GB disk0s2 3: Linux Swap 9.7 GB disk0s3 4: Apple_HFS Recovery HD 650.0 MB disk0s4 5: Microsoft Basic Data Untitled 100.5 GB disk0s5 6: Apple_Boot Recovery HD 650.0 MB disk0s6 7: Apple_CoreStorage Gauss 77.7 GB disk0s7 8: Apple_Boot Recovery HD 650.0 MB disk0s8 /dev/disk1 (internal, virtual): #: TYPE NAME SIZE IDENTIFIER 0: Apple_HFS Gauss +77.3 GB disk1 Logical Volume on disk0s7 D016C459-3197-4791-9145-96EF497E4E65 Unlocked Encrypted Seans-MBP:~ sean$ diskutil listFilesystems Formattable file systems These file system personalities can be used for erasing and partitioning. When specifying a personality as a parameter to a verb, case is not considered. Certain common aliases (also case-insensitive) are listed below as well. ------------------------------------------------------------------------------- PERSONALITY USER VISIBLE NAME ------------------------------------------------------------------------------- ExFAT ExFAT Free Space Free Space (or) free MS-DOS MS-DOS (FAT) MS-DOS FAT12 MS-DOS (FAT12) MS-DOS FAT16 MS-DOS (FAT16) MS-DOS FAT32 MS-DOS (FAT32) (or) fat32 HFS+ Mac OS Extended Case-sensitive HFS+ Mac OS Extended (Case-sensitive) (or) hfsx Case-sensitive Journaled HFS+ Mac OS Extended (Case-sensitive, Journaled) (or) jhfsx Journaled HFS+ Mac OS Extended (Journaled) (or) jhfs+
Create a Bootable Ubuntu USB Stick

Download Ubuntu Desktop, version Ubuntu 20.04.1 LTS (Focal Fossa). You'll get a file in your Downloads folder called ubuntu-20.04.1-desktop-amd64.iso

Create a Bootable USB Stick for Mac. I'll go through a worked example below.

You'll need a 2GB USB thumb drive or larger. Insert it and bring up Disk Utility with the option of Show All Devices

Select the device, not the volume. Make sure it's NOT you hard drive or backup drive!

Now erase the disk specifying format = MS-DOS (FAT) and Scheme = GUID Partition Map

Next, install the open source utility Etcher, downloading the version for Mac OS.

Now run it, selecting the Ubuntu ISO file and the thumb drive the push Flash. Etcher will ask for your system password and give you an estimated time.

After completion, select Eject

Install Ubuntu

Connect an Ethernet cable to your Internet Service Provider and the other end to your Mac; use a USB to Ethernet dongle if you don't have a native Ethernet port on your Mac.

Plug the USB drive containing the Ubuntu Linux distribution into your Mac. Restart your Mac. If you installed rEFInd the boot manager will automatically appear. Select the EFI Boot icon from the list in the boot device menu.

If you have a problem seeing the boot manager, or if you already have done an Ubuntu installation do this: as soon as the Mac starts to boot up, hold down the Option key. Keep holding it down until you see the Mac's boot manager display a list of available devices you can start up from. Select the EFI Boot icon from the list in the boot device menu.

Now go through the Ubuntu installation process.

You'll see either This computer currently has no detected operating systems. Or if you had previously installed Ubuntu, This computer has Ubuntu 20.04.1 LTS (Focal Fossa) on it.. Select something else since we want to fiddle with partitions.

Here is the list of partitions,

Now select the partition you want to use for Ubuntu (the 130GB) and hit - to delete it. You'll see it converted to free space.

Reformat the freespace using + as Ext4 journaling file system with mount point /.

Do the same for Linux swap space, giving yourself about 10GB,

Finally, click on the Format ? box, then click on Install Now

Your last chance, so double check what Ubuntu wants to do!

Now continue the installation. Ubuntu asks you where you are located. Next, enter user name and password. You will be the superuser.

Now let the installation complete, remove the thumb drive and reboot into Ubuntu automatically. Ubuntu asks if you want to update; say yes.

Just for grins, open Terminal and run a manual updating and upgrade all software, then remove unneeded software,

sudo apt-get update sudo apt-get upgrade sudo apt-get autoremove
Two Display Screens Show Up Instead of One

The Mac comes up with two displays shown. Toggle one display to avoid showing one blank display when screen sharing.

Ubuntu Freezing at Boot Time

My computer was freezing upon bootup. It's a problem with NVIDIA drivers, and you can fix Ubuntu freezing by turning them off at bootup. I'll repeat the instructions here with minor changes for my system. Upon bootup, hit the ESCAPE key once. You might have to experiment to get the timing right. You'll go into a boot menu,

Hit the E key to go into edit mode and add the option nomodeset after the the quiet splash in the linux line,

Then save and reboot. To make changes permanent, not just for this boot, edit the grub configuration file,

sudo gedit /etc/default/grub
sudo update-grub2
Wireless Connection

Connect to your local Wireless node by clicking on the top right menu bar settings.

Select Wireless settings, and type in your Wireless Key and connect.

If you cannot connect to Wireless, you may need to install the Wireless driver. I found it by looking at Broadcom Linux Wireless Drivers Install using the line below and reboot after you install.

sudo apt install bcmwl-kernel-source
Mounting an Additional FAT Partition

I had an unused partition, so I launched the Disks application and formatted it as Extended FAT to be visible to Ubuntu. You might have to toggle the Right Arrow icon to mount it; it will say mounted at /media/sean/Backup

Here then is the final partition map,
Reading USB Drives Formatted in Extended FAT

To read a USB drive formatted in Extended FAT format, install the drivers.

sudo apt-get install exfat-utils exfat-fuse

Now you can format a USB drive as Ex FAT, plug it into your computer, and read it.

Ubuntu Linux on a CyberPowerPC

It's much easier to set up Ubuntu on a PC. In short, follow the excellent Ubuntu Desktop Installation instructions.

I have a CyberpowerPC with AMD motherboard, 1TB SATA disk drive, wireless PCI module, GPU card, Acer monitor, USB keyboard and three button mouse.

I downloaded the Ubuntu .iso file and created a USB flash drive. I powered up my PC with the USB drive inserted, and paused the boot sequence to select the USB drive to boot from. After that, I installed Ubuntu according to the instructions.

Ubuntu Linux Tweaks

Changing the Terminal Type
I want to execute the bash startup files the same way Mac OS does. So you need tell Ubuntu to run the terminal window as a login shell:
File Sharing Between Mac and Ubuntu Computers

Install Vim first so you can edit files. Here's how to change the hostname of your system.

# Edit this file and change the name to Gauss sudo vim /etc/hostname # Edit this file and change the name sudo vim /etc/hosts cat /etc/hosts 127.0.0.1 localhost 127.0.1.1 Gauss ... sean:~$ hostnamectl -h set-hostname --transient Gauss sean:~$ hostnamectl Static hostname: Gauss Icon name: computer-desktop Chassis: desktop Machine ID: 0652ebd89a594c33ae8a1ebd60fb8356 Boot ID: 11fcbdc84fdb4c40982b5e7f0f33ea91 Operating System: Ubuntu 20.04.1 LTS Kernel: Linux 5.4.0-48-generic Architecture: x86-64 sudo hostnamectl -h set-hostname Gauss sudo hostname Gauss reboot

To install file sharing across computers, find out your username

users sean

then install Samba, and give a sharing password,

sudo apt-get install samba sudo smbpasswd -a sean

Let's share the Desktop directory under $HOME. First copy the system config file to your local directory,

sudo cp /etc/samba/smb.conf ~

Edit the smb.conf file by adding these lines to the end,

[share] path = /home/sean/Desktop valid users = sean read only = no

Start the Samba client,

sudo apt-get install smbclient sudo service smbd restart

To speed up SMB sharing, (it still takes a minute or two on my Mac), add the IP addresses and hostnames of all your local computers to the /etc/hosts file.

Install ifconfig so you can see the IP addresses.

sudo apt install net-tools

Get the hostname on my Ubuntu Linux computer and its IP address

hostname Gauss ifconfig ... inet 333.333.3.33 netmask 255.255.255.0 broadcast 333.333.3.255 ...

Now go to the Mac OS computer and get the hostname and IP address,

hostname Artificer ifconfig ... inet 333.333.3.34 netmask 0xffffff00 broadcast 333.333.3.255 ...

Back in Ubuntu, edit the hosts file by doing sudo vim /etc/hosts. Add these two host names and their IP addresses.

127.0.0.1 localhost ... 333.333.3.33 Gauss 333.333.3.34 Artificer

Launch the File Manager application. In your Home directory, double click the Desktop directory. Turn on sharing in Local Network Share and allow others to create and delete files.

Finally you must open the firewall for Samba,

sudo ufw allow Samba

Back on Mac OS, mount the shared remote directory, which will prompt you for the Samba password you just set,

cd ~/Desktop mkdir Ubuntu mount -t smbfs //sean@Gauss/Desktop ~/Desktop/Ubuntu

You'll see the shared directory on the Ubuntu machine, so go ahead and Connect

Screen Sharing from Mac to Ubuntu

Go to the Ubuntu settings to enable screen sharing,

In Terminal you'll see the screen sharing server listening on port 5900

sean:~$ ss -lnt State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 50 0.0.0.0:139 0.0.0.0:* LISTEN 0 5 0.0.0.0:5900 0.0.0.0:* LISTEN 0 128 127.0.0.53%lo:53 0.0.0.0:* LISTEN 0 5 127.0.0.1:631 0.0.0.0:* LISTEN 0 50 0.0.0.0:445 0.0.0.0:* LISTEN 0 50 [::]:139 [::]:* LISTEN 0 5 [::]:5900 [::]:* LISTEN 0 5 [::1]:631 [::]:* LISTEN 0 50 [::]:445 [::]:*

You'll need to fiddle with the protections on GNOME to make the Mac screen sharing work properly and not give you the error message Screen sharing software is not compatible when you attempt to connect.

gsettings set org.gnome.Vino require-encryption false

and maybe you open ports in the firewall,

sudo ufw allow from any to any port 5900 proto tcp [sudo] password for sean: Rules updated Rules updated (v6)
If that still doesn't work you could try to disable the firewall entirely!
sudo ufw disable

But first, install the GUI for the firewall and tinker with the settings.

sudo apt install gufw gufw

On the Mac, you'll see the remote screen share, in Finder

Click Share Screen and enter the password.

Here's the Ubuntu Linux screen share on the Mac,

Secure Shell Login

I've followed instructions from the article How to Enable SSH on Ubuntu 18.04 to ssh from my Mac to my Ubuntu on my local net. I haven't tried it yet from outside my router but look at Ubuntu's instructions SSH Server Configuration and Servers Behind NAT

Install the ssh server,

sudo apt install openssh-server

Check the status

sudo systemctl status ssh ● ssh.service - OpenBSD Secure Shell server Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled) Active: active (running) since Fri 2019-11-29 11:39:54 PST; 33s ago Main PID: 5638 (sshd) Tasks: 1 (limit: 4279) CGroup: /system.slice/ssh.service └─5638 /usr/sbin/sshd -D

Open the firewall

sudo ufw allow ssh Rule added Rule added (v6)

Back on the Mac, ssh into the Ubuntu machine using the IP address. You'll be asked to register an RSA encryption key the first time.

ssh sean@192.168.1.68 sean@192.168.1.68's password: Welcome to Ubuntu 20.04.1 LTS (Focal Fossa) (GNU/Linux 4.15.0-70-generic x86_64) ... ls blender-2.90.1-linux64/ Desktop/ Downloads/ Pictures/ Templates/ Videos/ ctags/ Documents/ EnglishStreet.jpg Music/ Public/ logout Connection to 192.168.1.68 closed.
Other Ubuntu Apps and Tweaks

Ubuntu comes with Thunderbird email among other applications. You can open Ubuntu Software in the Applications folder and search for more.

Install Gnome-Tweaks using the Ubuntu software app (shopping bag icon).

In the Settings you can launch apps upon startup,

Putting Apps on the Dock

Usually you can run an app from the terminal command line, and when it appears on the dock, you can right click its icon, select add to favorites and that will add it permanently to the dock.

But you might have to do this manually for some apps. In this example, I downloaded Blender for Linux, then made the app appear in the dock.

Copy the file ~/Desktop/Blender.desktop from the Blender linux directory and make a few changes to point to the executable in Exec and the Blender icon in Icon.

[Desktop Entry] Name=Blender GenericName=3D modeler GenericName[ar]=3D المنمذج ثلاثي الأبعاد ... GenericName[zh_TW]=3D 模型 Comment=3D modeling, animation, rendering and post-production Comment[sv]=3d-modellering, animering, rendering och efterbehandling ... Comment[zh_TW]=3D 模型、動畫、算圖和後製 Keywords=3d;cg;modeling;animation;painting;sculpting;texturing;video editing;video tracking;rendering;render engine;cycles;game engine;python; Exec=/home/sean/blender-2.90.1-linux64/blender %f Icon=/home/sean/blender-2.90.1-linux64/blender.svg Terminal=false Type=Application Categories=Graphics;3DGraphics; MimeType=application/x-blender;

Now move the file to where Gnome can find it.

cd ~/.local/share/applications mv ~/Desktop/Blender.desktop .

Go to where Blender was installed, and launch it from the command line,

cd ~/blender-2.90.1-linux64 ./blender

After it comes up, right click on its icon in the dock Add to Favorites Now you should see the Blender icon permanently in the dock.

Mac OS

Well, Mac OS is Unix, so you get most of what you want out of the box. Note that Mac OS Catalina only supports 64-bit applications. There are also security features which you'll need to work around when running third party apps.

Working Around Catalina Security

When you try to run a third party executable, e.g. ClozureCommonLisp, the OS will block it as follows in Mac OS Catalina:

Go to the Settings->Security and Privacy and allow the exe to run:

You can then open the exe:

Windows

You get everything installed out of the box.

PROGRAMMING TOOLS

Developer Tools Mac

XCode

Mac OS X comes with most of the the Unix utilities make, diff, gcc, g++ (the clang equivalent), lldb, etc. already installed. To get recent versions, you can install the free XCode IDE from the Apple App Store

Download XCode from Apple App Store

If XCode doesn't ask you upon use whether you would like to install the command line tools, you can do it manually:

# You may have to install XCode command line tools first. xcode-select --install
Bash

Mac OS Catalina has moved to a new shell zsh from bash (Apple Support: Use zsh as the default shell on your Mac) but you can install your own version of bash and use it. Mac was using an old 3.2.57 release version.

Download the Bash source code from Bash from GNU Web Site

Unpack the bash-5.0.tar file, move it to a convenient directory, cd into that directory, then run these commands,

cd /Users/seanoconnor/Desktop/Apps/MacOS/Bash/bash-5.0 ./configure make sudo make install

This installs bash into both /usr/local/bin and /usr/local:

seanoconnor:~$ /usr/local/bin/bash --version GNU bash, version 5.0.0(1)-release (x86_64-apple-darwin19.0.0) Copyright (C) 2019 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software; you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

Make the new version of bash your default shell for all terminals. First edit this file and add the new bash path at the top:

sudo vi /etc/shells 1 # List of acceptable shells for chpass(1). 2 # Ftpd will not allow users to connect who are not using 3 # one of these shells. 4 5 /usr/local/bin/bash 6 /bin/bash 7 /bin/csh 8 /bin/dash 9 /bin/ksh 10 /bin/sh 11 /bin/tcsh 12 /bin/zsh

Then change the default shell on the command line and in the Terminal Preferences

seanoconnor:~$ chsh -s /usr/local/bin/bash Changing shell for seanoconnor. Password for seanoconnor:

Close all terminal windows, open a terminal window up again, and check the version

seanoconnor:~$ echo $BASH_VERSION 5.0.0(1)-release
Brew

Brew is the macOS version of apt-get for Ubuntu Linux.

# Install brew /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" # Update brew to the latest version. brew update --verbose
rsync

The macOS version of rsync old (2006). Use brew to install the latest version. Make sure your path includes /usr/local/bin where the new rsync resides.

brew install rsync which rsync /usr/local/bin/rsync rsync --version rsync version 3.1.3 protocol version 31 Copyright (C) 1996-2021 by Andrew Tridgell, Wayne Davison, and others. Web site: http://rsync.samba.org/ Capabilities: 64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints, socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace, append, ACLs, xattrs, iconv, symtimes, no prealloc, file-flags

If you reinstall to upgrade the version, you may run into this problem. Just follow the advice that brew tells you:

brew reinstall rsync Error: The following directories are not writable by your user: /usr/local/include /usr/local/lib/pkgconfig /usr/local/share/locale /usr/local/share/man/man3 You should change the ownership of these directories to your user. sudo chown -R $(whoami) /usr/local/include /usr/local/lib/pkgconfig /usr/local/share/locale /usr/local/share/man/man3 And make sure that your user has write permission. chmod u+w /usr/local/include /usr/local/lib/pkgconfi
Ctags

Universal Ctags is a successor to Exuberant Ctags. First install Brew. Then install ctags,

brew install --HEAD universal-ctags/universal-ctags/universal-ctags

If you have problems, uninstall,

brew uninstall universal-ctags

Then reinstall as above. Make sure your path in your .bash_profile contains /usr/local/bin.

Developer Tools Ubuntu Linux

Naturally, you've got all the unix tools or can easily install them using sudo apt-get from the terminal.

Ctags

To install it on Ubuntu Linux, download several tools first, then download the source code, build and install

sudo apt install linuxbrew-wrapper brew doctor sudo apt install automake cd ~ git clone https://github.com/universal-ctags/ctags.git cd ctags/ sudo apt install pkg-config sudo apt install pkgconf ./autogen.sh ./configure make sudo make install ctags --help

But for the nostalgic, exuberant ctags is still available on Ubuntu Linux

sudo apt install exuberant-ctags

UNIX Tools Windows

Load Cygwin utilities from Cygwin home. Choose download to disk without installing to C:/Install/Cygwin Use direct connection and pick a mirror site. Next, run setup.exe. Pick view=full. Now select all the defaults and also be sure to add bash, bison, byacc, cvs, ctags, diff, flex, gcc, g++, gdb, hexedit, ncurses, make, python, sed, tar, zip and unzip. Then run setup again but this time install from the local disk. You'll get a cygwin icon on the desktop which you can launch shell commands from.

Cygwin Setup

Bash Settings

I'm using the bash shell. Read the Beginner's Guide, Tutorial, and Reference then go to your home directory, and place the bash startup files .bash_login, .bash_logout and .bashrc there.

In Windows the home directory is in C:/Documents and Settings/Sean Erik O'Connor. Note: If your user name in your /home directory contains spaces, it will cause trouble. cygwin gets it from the windows logon name. You can edit the /etc/passwd file and change the Cygwin user name (first field), then rename your directory.

#============================================================================= # # FILE NAME # # .bash_profile : # DESCRIPTION # # bash shell startup file for Unix systems, executed upon login. # # Install into your home directory ~. Also called .profile or # .bash_login # # See also install documentation for various apps here: # http://seanerikoconnor.freeservers.com/WebDesign/artificer.html # # DATE # # 15 Oct 20 # # AUTHOR # # Sean E. O'Connor # #============================================================================= # #------------- Portability ------- # # Try to determine which system we are running on. #----------------------------------------------------------------------------- #--- Set the path #----------------------------------------------------------------------------- # Be sure to put useful scripts and executables into the home bin directory: ~/bin bins="/usr/local/bin:~/bin" # To set the hostname manually on Mac OS X # sudo hostname Artificer" # sudo scutil --set LocalHostName Artificer # sudo scutil --set ComputerName Artificer # sudo scutil --set HostName Artificer # In System Preferences/Sharing change 'Computer Name' to Artificer. # In your local network configuration, rename the name provided by DHCP. # Find out the hostname. In cygwin bash, strip off the trailing \r introduced. # The alternative is to use tr -d '\r' hostname=`python3 -c "import platform; print( platform.node() )" | sed 's/^[ \r\n\t]*$//'` ###echo "hostname=|${hostname}|" if [ "${hostname}" == "" ] ; then echo "Could not get a hostname. We will guess a new Mac system!" hostname="Artificer" fi # This script requires Python 3.x # To call the default python2.7.2 for Mac OS X in a terminal window, comment out this line, and do # source ~/.bash_profile # Mac OS if [ "${hostname}" == "Artificer" ] ; then py3bin="/Library/Frameworks/Python.framework/Versions/3.9/bin" ###echo "Using Mac OS X System Python version path = ${PATH}" # Ubuntu Linux elif [ "${hostname}" == "Gauss" ] ; then py3bin="/usr/local/bin" ###echo "Using Ubuntu Linux Python version path = ${PATH}" fi # CMake tool used for Blender. cmakebin="/Applications/CMake.app/Contents/bin/" # Latest version of make. makebin="/usr/local/bin" # Final path. PATH="${HOME}:${makebin}:${cmakebin}:${py3bin}:${bins}:${PATH}" export PATH # Make sure Python 3 is installed on your system. Get the version and redirect from stderr to stdout. python_version=`python -V 2&gt;&1` # Delete minor versions (numbers after the first dot), and spaces, e.g. Python 3.9.3 =&gt; Python3 python_version_stripped=`echo ${python_version} | sed 's/\.[0-9]//g' | sed 's/[ \r]//g'` # Check the version and give help. if [ "${python_version_stripped}" != "Python3" ] ; then echo "WARNING: Calling o l d python version ${python_version} from `which python` in path $PATH" fi # Default settings. ls_color_option="-G" desk_dir="${HOME}/Desktop" thumb_dir="/Volumes/ALNILAM" extra_bin_path="/usr/local/bin" # Windows 7 64-bit running in Parallels running in Mac OS. if [ "${hostname}" == "SEANOCONNORBC36" ] ; then ###echo "Overriding Mac settings --- this is a Windows machine!" ls_color_option="--color=tty" desk_dir="/cygdrive/c/cygwin/home/Sean" thumb_dir="/cygdrive/e" # Windows has endless trouble with blanks in filenames, so use DOS 8.3 equivalent file name. desk_dir="/cygdrive/c/docume~1/Sean/Desktop" fi #------------- Export base directories for use by other programs ------------- # The root directory has /Sean under it and /Sean/WebSite underneath that. export desk_dir export thumb_dir ##echo "Root dir |${desk_dir}|, thumb dir |${thumb_dir}|, desk_dir |${desk_dir}|" #------------- Directory Shorthands ------------- # Top level directories sean_dir="${desk_dir}/Sean" app_dir="${desk_dir}/Apps/MacOS" export sean_dir export app_dir # Level 1. arts_dir="${sean_dir}/Arts" business_dir="${sean_dir}/Business" family_dir="${sean_dir}/Family" science_dir="${sean_dir}/Sciences" web_dir="${sean_dir}/WebSite" export arts_dir export business_dir export family_dir export science_dir export web_dir # Quickly cd to subdirectories by typing cd subdir. # Need . in the list to avoid having to put ./ in front of directories. export CDPATH=.:~:${sean_dir}:${pp_src_dir} # Mac system tweaks. if [ "${hostname}" == "Artificer" ] ; then # Show hidden files in finder (needs a relaunch of finder). defaults write com.apple.finder AppleShowAllFiles TRUE fi # Finish up the aliases. source .bashrc export PATH ###echo "Bash version = ${BASH_VERSION}"
#---------------------------------------------------------------------------- # # TITLE # # .bashrc # # DESCRIPTION # # # Bourne Again Shell (bash) startup file for Unix systems. Executed # everytime we start a subshell. Install into your home directory ~. # Put aliases and functions here. # # Use source .bashrc to reset the environment after you are in a # terminal window. Place the line "source .bashrc" into .bash_profile # to execute this file's commands upon login. # # To debug, use sh -x .bashrc # # DATE # # 15 Oct 20 # # AUTHOR # # Sean E. O'Connor # #---------------------------------------------------------------------------- #------------- Aliases ------------- # # Be sure to put useful scripts and executables into the home bin directory, ~/bin or global /usr/local/bin # alias desk='cd ${desk_dir}' alias sean='cd ${sean_dir}' alias app='cd ${app_dir}' alias art='cd ${arts_dir}/Visual/Painting/OriginalWorks' alias bus='cd ${business_dir}' alias fam='cd ${family_dir}' alias sci='cd ${science_dir}' alias math='cd ${science_dir}/Mathematics' alias comp='cd ${science_dir}/ComputerScience' alias acc='cd ${business_dir}/Accounts' alias web='cd ${web_dir}' alias wd='cd "${web_dir}/WebDesign"' alias mw='cd ${web_dir}/WebDesign/MaintainWebPage' alias priv='cd ${web_dir}/private' alias artw='cd ${web_dir}/Art' alias crc='cd ${web_dir}/CommunicationTheory/ChannelCoding/Crc' alias lif='cd ${web_dir}/ComputerScience/Automata/Life' alias lis='cd ${web_dir}/ComputerScience/Compiler/ParserGeneratorAndParser/SourceCode/ParserGenerator' alias plu='cd ${app_dir}/../Plum' pp_dir="${web_dir}/Mathematics/AbstractAlgebra/PrimitivePolynomials" pp_proj_dir="${pp_dir}/Project" pp_bld_dir="${pp_dir}/Project/Build" pp_src_dir="${pp_dir}/Project/SourceCode" pp_exe_dir="${pp_bld_dir}/Bin" alias pp='cd ${pp_dir}' alias ppb='cd ${pp_bld_dir}' alias pps='cd ${pp_src_dir}/Primpoly' alias ppsc='cd ${pp_src_dir}/PrimpolyC' # Other directories. #------------- Git ------- # Location of git repository. export GITREPOS="${web_dir}/private/repos" #------------- Set prompt ------- # # Define colors for the text in a prompt. # startcolor="\[\e[" black="30" red="31" green="32" yellow="33" blue="34" magenta="35" teal="36" white="37" separator=";" blackbackground="40" redbackground="41" greenbackground="42" yellowbackground="43" bluebackground="44" magentabackground="45" tealbackground="46" whitebackground="47" reset="0" boldtext="1" underline="4" blink="5" inverted="7" endcolor="m\]" resetcolor="\e[0m" whiteonblue="${startcolor}${white}${separator}${bluebackground}${endcolor}" redonblue="${startcolor}${red}${separator}${bluebackground}${endcolor}" # Set the prompt to # time \@, date \d, user name \u, host name \h, current directory \w # \W basename of current directory, \$ if UID = 0 (root), use # instead of $ export PS1="${redonblue}\u:${whiteonblue}\w${resetcolor}\$ " ###echo ${PS1} #------------- Shell options ------------- # # Set vi edit mode for the command line. # Hit &lt;ESC&gt; to go into vi's edit command mode: # h Move cursor left # l Move cursor right # A Move cursor to end of line and put in insert mode # 0 (zero) Move cursor to beginning of line (doesn't put in insert mode) # i Put into insert mode at current position # a Put into insert mode after current position # dd Delete line (saved for pasting) # D Delete text after current cursor position (saved for pasting) # p Paste text that was deleted # j Move up through history commands # k Move down through history commands # u Undo set -o vi # Don't wait for job termination notification set -o notify # Don't use ^D to exit set -o ignoreeof # Use case-insensitive filename globbing shopt -s nocaseglob # Make bash append rather than overwrite the history on disk shopt -s histappend # When changing directory small typos can be ignored by bash # for example, cd /vr/lgo/apaache would find /var/log/apache shopt -s cdspell shopt -s cdable_vars #------------- Completion options ------------- # # These completion tuning parameters change the # default behavior of bash_completion: # Define to avoid stripping description in --option=description of './configure --help' COMP_CONFIGURE_HINTS=1 # Define to avoid flattening internal contents of tar files COMP_TAR_INTERNAL_PATHS=1 # If this shell is interactive, turn on programmable completion enhancements. # Any completions you add in ~/.bash_completion are sourced last. case $- in *i*) [[ -f /etc/bash_completion ]] && . /etc/bash_completion ;; esac #------------- History options ------------- # # Don't put duplicate lines in the history. export HISTCONTROL="ignoredups" # Ignore some controlling instructions export HISTIGNORE="ls:ls *:[ ]*:&:cd:cd ..:exit:hi:s:f:m:um" # Whenever displaying the prompt, write the previous line to disk export PROMPT_COMMAND="history -a" #------------- Aliases ------------- # # If these are enabled they will be used instead of any instructions # they may mask. For example, alias rm='rm -i' will mask the rm # application. # # To override the alias instruction use a \ before, ie # \rm will call the real rm not the alias. # # To see all aliases, type alias. # Use unalias to remove a definition. # Interactive operation... alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' alias up='cd ..' # Default to human readable figures alias df='df -h' alias du='du -hac' # Misc :) alias less='less -r' # raw control characters alias whence='type -a' # where, of a sort alias grep='grep --color' # show differences in colour alias hi=history # Some shortcuts for different directory listings alias ls='ls -hF ${ls_color_option}' alias dir='ls --color=auto --format=vertical' alias ll='ls -l' # long list alias la='ls -A' # all but . and .. alias l='ls -CF' # #------------- Utility functions ------------- # Recursive search for a string in a file. function grepall() { if [ $# == 0 ] then echo "Usage: grepall &lt;string&gt;" fi # Grab the function argument, bash style. pat=$1 echo "Searching all subdirectories for pattern ${pat}" find . -name '*.[ch]' -exec grep -iH "${pat}" {} ';' find . -name '*.hpp' -exec grep -iH "${pat}" {} ';' find . -name '*.cpp' -exec grep -iH "${pat}" {} ';' find . -name '*.py' -exec grep -iH "${pat}" {} ';' find . -name '*.m' -exec grep -iH "${pat}" {} ';' find . -name '*.js' -exec grep -iH "${pat}" {} ';' find . -name '*.java' -exec grep -iH "${pat}" {} ';' find . -name '*.pl' -exec grep -iH "${pat}" {} ';' find . -name '*.prl' -exec grep -iH "${pat}" {} ';' find . -name '*.html' -exec grep -iH "${pat}" {} ';' find . -name '*.css' -exec grep -iH "${pat}" {} ';' find . -name 'makefile' -exec grep -iH "${pat}" {} ';' find . -name '*.dat' -exec grep -iH "${pat}" {} ';' find . -name '*.txt' -exec grep -iH "${pat}" {} ';' } function touchall() { find . -exec touch {} ';' } function testOptions() { if [ $# == 0 ] then echo "Number of arguments to testOptions is $#" fi # No spaces around the equals allowed in bash! a1=$1 echo "You said |${a1}|" # Compare the first 3 letters. if [ "${a1:0:3}" == "tes" ] then echo "You said testOptions tes" else echo "What did you say?" fi } # Launch gvim editor. function gvim() { # No file name given? if [ $# == 0 ] then # Remove the old file. fileName="${HOME}/temp.txt" if [ -f "${fileName}" ] ; then echo "Removing file ${fileName}" rm -rf ${fileName} fi # Remove any swap file. fileNameSwap="${HOME}.vim/.swp/temp.txt.swp" if [ -f "${fileNameSwap}" ] ; then echo "Removing swap file ${fileNameSwap}" rm -rf ${fileNameSwap} fi # Create a new file. echo -n &gt; ${fileName} echo "Opening temporary file ${fileName}" else fileName=$1 fi # Launch GUI Vim on my Mac OS X machine. if [ "${hostname}" == "Artificer" ] ; then open -a MacVim "${fileName}" # Launch GUI Vim on my Ubuntu Linux machine elif [ "${hostname}" == "Gauss" ] ; then /usr/bin/gvim "${fileName}" # Else assume gvim installed on a Unix system. else /usr/bin/gvim "${fileName}" fi } # Remove temporary files. function cleanall() { if [ $# != 0 ] then echo "Usage: cleanall" fi find . -name '*~' -print -exec rm -f {} \; find . -name '._*' -print -exec rm -f {} \; find . -name '.DS_Store*' -print -exec rm -f {} \; find . -name 'Thumbs.db' -print -exec rm -f {} \; find . -name '*.swp' -print -exec rm -f {} \; find . -name '*.o' -print -exec rm -f {} \; find . -name '*.class' -print -exec rm -f {} \; find . -name '*.o~$' -print -exec rm -f {} \; find . -name '*.o~&gt;' -print -exec rm -f {} \; find . -name '*.dSYM' -print -exec rm -rf {} \; find . -name '*.obj' -print -exec rm -rf {} \; find . -name '*.ncb' -print -exec rm -rf {} \; find . -name '*.suo' -print -exec rm -rf {} \; find . -name '*.idb' -print -exec rm -rf {} \; find . -name '*.pdb' -print -exec rm -rf {} \; find . -name '*.manifest' -print -exec rm -rf {} \; find . -name '*.Spotlight-V100' -print -exec rm -rf {} \; find . -name '*.Trash*' -print -exec rm -rf {} \; find . -name '*.fseventsd' -print -exec rm -rf {} \; }
# # FILE NAME # # .bash_logout # # DESCRIPTION # # bash shell executed upon logout. # Install into your home directory ~. # # DATE # # 19 Apr 10 # # AUTHOR # # Sean E. O'Connor # # # Clean up. # rm -f ~/.bash_history #rm -f ~/.viminfo

Git

I use Git for source code control. It's out of the box in Mac OS and you can install in Ubuntu Linux using

sudo apt install git

It's described in the Git Pro 2 Book. Here's an example of how I set up my Git repository for my Primpoly project using local repositories.

Git Configuration.

The bash parameter ${web_dir} points to my top level web directory on my disk.

In your home directory $HOME, edit the file .gitconfig to add your email and user name plus your default editor,

[user] email = seanerikoconnor@gmail.com name = Sean E. O'Connor [core] editor = vim excludesfile = /Users/seanoconnor/.gitignore_global [merge] tool = opendiff conflictstyle = diff3 [difftool] prompt = false # Don't prompt the user to hit RETURN before the next file difference. [difftool "opendiff"] # cmd = echo 'base(ancestor base for the merge) = # ' \"$BASE\" 'local(file on current branch) = ' \"$LOCAL\" 'remote(file to be merged) = ' \"$REMOTE\" 'merged(what mergetool should write) = ' \"$MERGED\" cmd = opendiff \"$LOCAL\" \"$REMOTE\" -merge \"$MERGED\" [mergetool "opendiff"] cmd = opendiff \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\" trustExitCode = true [push] default = simple [credential] helper = cache [alias] unstage = reset HEAD -- uncheckin = checkout --
and which files to ignore globally by git,
# .gitignore_global # # The file types which Git should ignore, i.e. not be added to the repository. # Vim backup files. *~ *.swp # Mac OS X file manager configuration files. .DS_Store # All Ctags files. tags # HTML versions of LISP, Python, C, C++ files. *.lsp.html *.c.html *.h.html *.cpp.html *.hpp.html *.py.html # HTML and CSS files. *.html *.css # Image directories. /Images # PDF files. *.pdf
Create a Bare Repository

Create a local directory to serve as the Git repository.

cd ${web_dir} cd private mkdir repos cd repos

In your .bashrc file in home directory, add the location of the local Git repository,

#------------- Git ------- # Location of git repository. export GITREPOS="${web_dir}/private/repos"
Make a subdirectory for the project, then initialize the repository.
$ mkdir Primpoly ; cd Primpoly $ git --bare init Initialized empty Git repository in $web_dir/private/repos/Primpoly/ $ la HEAD branches/ config description hooks/ info/ objects/ refs/
Add Files to Source Code Control

Go to the directory containing the source files and initialize Git.

cd ~/Desktop/Sean/WebSite/Mathematics/AbstractAlgebra/ PrimitivePolynomials/Project/SourceCode/Primpoly $ git init Initialized empty Git repository in /Users/seanoconnor/Desktop/Sean/WebSite/Mathematics/ AbstractAlgebra/PrimitivePolynomials/Project/SourceCode/Primpoly/.git/

Place the source files under source code control. We don't add the html files since they are automatically generated.

$ git add *.cpp *.h /FactorTables $ git status On branch master Initial commit Changes to be committed: (use "git rm --cached <file>..." to unstage) new file: FactorTables/c02minus.txt ... new file: FactorTables/c12plus.txt new file: Primpoly.cpp ... new file: ppUnitTest.h Untracked files: (use "git add <file>..." to include in what will be committed) Primpoly.cpp.html ... ppUnitTest.h.html

Your files are staged now. When ready, do a commit,

$ git commit -m "Initial import from SVN." [master (root-commit) 75fa9b1] Initial import from SVN. 32 files changed, 46548 insertions(+) create mode 100755 FactorTables/c02minus.txt ... create mode 100755 FactorTables/c12plus.txt create mode 100755 Primpoly.cpp ... create mode 100755 ppUnitTest.h

Now we let the local directory Primpoly know about the remote repository.

$ git remote add origin $GITREPOS/Primpoly/ $ git remote show origin $ git remote -v origin ${web_dir}/private/repos/Primpoly/ (push)

Then we push up to the remote repository,

$ git push origin master Counting objects: 35, done. Delta compression using up to 8 threads. Compressing objects: 100% (35/35), done. Writing objects: 100% (35/35), 1.10 MiB | 0 bytes/s, done. Total 35 (delta 2), reused 0 (delta 0) To $GITREPOS/Primpoly/ * [new branch] master -> master

To avoid specifying origin and master each time you pull and push, you can track the remote repository,

$ git pull There is no tracking information for the current branch. Please specify which branch you want to merge with. See git-pull(1) for details. git pull <remote> <branch> If you wish to set tracking information for this branch you can do so with: git branch --set-upstream-to=origin/<branch> master $ git branch --set-upstream-to=origin/master Branch master set up to track remote branch master from origin.

Verify the git repository is set up correctly by doing a test clone from the remote repository, and verify there are no differences between it and your local repository,

$ cd ~/Desktop $ git clone $GITREPOS/Primpoly Cloning into 'Primpoly'... done. $ diff -r ~/Desktop/Primpoly \ ~/Desktop/Sean/WebSite/Mathematics/AbstractAlgebra/ PrimitivePolynomials/Project/SourceCode/Primpoly

You can use Mac OS X mergetool/opendiff to resolve conflicts.

$ git mergetool

Make

Get a new version of make which you can download. To install, do the usual GNU procedure,

cd /Users/seanoconnor/Desktop/Apps/MacOS/Make/make-4.3 ./configure make sudo make install make --version GNU Make 4.3 Built for x86_64-apple-darwin19.4.0 ...

PROGRAMMING LANGUAGES

C++ Language and Compilers

Start by reading the textbooks A Tour of C++ by Bjarne Stroustrup and The C++ Programming Language, 4th Edition then read the latest updates in the C++ Super-FAQ and the C FAQ

Photo of Bjarne Stroustrup.

Mac OS X development tools contain the clang C++ and C compilers. They come with XCode.

Ubuntu Linux To get C++ and C working in Ubuntu Linux, you can use g++ which is installed already. Or you can install clang, but you have to explicity install its libraries,

sudo apt-get install clang sudo apt-get install libc++-dev sudo apt-get install libc++abi-dev

Then you can compile thus:

$ cat foo.cpp #include <string> #include <iostream> using namespace std; int main(int argc,char** argv) { string s(argv[0]); cout <<s <<endl; } $ clang++ -std=c++11 -stdlib=libc++ foo.cpp

If that doesn't work (but it should), change your makefiles by replacing the default library -stdlib=libc++, with the older GNU library -stdlib=libstdc++

# This is OK if we switch to the older GNU library. $ clang++ -std=c++11 -stdlib=libstdc++ foo.cpp

Windows You can use the C++ compiler in the Cygwin development tools or you can download Visual Studio Express and follow instructions.

C++ GUIs

I haven't tried them yet but the C++ GUIs FoxTookit and WxWidgets sound interesting. WxWidgets looks a lot like Windows API with classes. Here is a tutorial ending up with source code for a tetris game.

LLDB Debugger

I use the lldb debugger in the llvm toolchain which comes installed on Mac OS X.

# Load executable compiled with -g option. lldb Bin/Primpoly.exe (lldb) target create "Bin/Primpoly.exe" Current executable set to 'Bin/Primpoly.exe' (x86_64). # Set a breakpoint in the code. (lldb) b ppBigInt.cpp:433 Breakpoint 2: where = Primpoly.exe`BigInt::operator unsigned long() const + 18 at ppBigInt.cpp:433, address = 0x000000010000fa92 # Run the program. (lldb) run 2 4 Process 49251 launched: '/Users/seanoconnor/Desktop/Sean/WebSite/Mathematics/AbstractAlgebra/ PrimitivePolynomials/Project/Build/Bin/Primpoly.exe' (x86_64) Primpoly Version 16.1 - A Program for Computing Primitive Polynomials. Copyright (C) 1999-2021 by Sean Erik O'Connor. All Rights Reserved. ... Process 49251 stopped * thread #1: tid = 0x8a8db2, 0x000000010000fa92 Primpoly.exe` BigInt::operator unsigned long(this=0x00007fff5fbf8d18) const + 18 at ppBigInt.cpp:433, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1 frame #0: 0x000000010000fa92 Primpoly.exe`BigInt::operator unsigned long (this=0x00007fff5fbf8d18) const + 18 at ppBigInt.cpp:433 430 BigInt::operator ppuint() const 431 throw( BigIntOverflow, bad_exception ) 432 { -> 433 ppuint result = 0 ; 434 ppuint b = base_() ; 435 436 for (int i = static_cast<unsigned int> digit_.size()) - 1 ; i > 0 ; --i) # Backtrace (lldb) bt * thread #1: tid = 0x8a8db2, 0x000000010000fa92 Primpoly.exe `BigInt::operator unsigned long(this=0x00007fff5fbf8d18) const + 18 at ppBigInt.cpp:433, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1 * frame #0: 0x000000010000fa92 Primpoly.exe`BigInt::operator unsigned long (this=0x00007fff5fbf8d18) const + 18 at ppBigInt.cpp:433 frame #1: 0x00000001000dc1b9 Primpoly.exe`unitTest() + 16233 at ppUnitTest.cpp:641 frame #2: 0x0000000100000c89 Primpoly.exe`main(argc=3, argv=0x00007fff5fbff600) + 89 at Primpoly.cpp:162 frame #3: 0x00007fff934cd5ad libdyld.dylib`start + 1 # Step to next line. (lldb) n Process 49251 stopped * thread #1: tid = 0x8a8db2, 0x000000010000fa9d Primpoly.exe `BigInt::operator unsigned long(this=0x00007fff5fbf8d18) const + 29 at ppBigInt.cpp:434, queue = 'com.apple.main-thread', stop reason = step over frame #0: 0x000000010000fa9d Primpoly.exe`BigInt::operator unsigned long(this=0x00007fff5fbf8d18) const + 29 at ppBigInt.cpp:434 431 throw( BigIntOverflow, bad_exception ) 432 { 433 ppuint result = 0 ; -> 434 ppuint b = base_() ; 435 436 for (int i = static_cast<unsigned int> digit_.size()) - 1 ; i > 0 ; --i) 437 { # List breakpoints. (lldb) br l Current breakpoints: 1: file = 'ppBigInt.cpp', line = 433, locations = 1, resolved = 1, hit count = 1 1.1: where = Primpoly.exe`BigInt::operator unsigned long() const + 18 at ppBigInt.cpp:433, address = 0x000000010000fa92, resolved, hit count = 1 2: name = 'l', locations = 0 (pending) 3: name = 'list', locations = 0 (pending) 4: name = 'l', locations = 0 (pending) # Delete all breakpoints. (lldb) br del About to delete all breakpoints, do you want to do that?: ÆY/nÅ y All breakpoints removed. (4 breakpoints) # Print a value. (lldb) p digit_ (std::__1::vector<unsigned long, std::__1::allocator< unsigned long> >) $4 = size=4 { [0] = 4 [1] = 3 [2] = 2 [3] = 1

Python

On Mac OS go to the Python Web Site and download the latest version of Python.

macOS Don't use the shipping python.

Python 3 installs into /Library/Frameworks/Python.framework/Versions/3.9 The installer will prefix the Python 3 path to your existing path in your .bash_profile

export PATH # Setting PATH for Python 3.9 # The original version is saved in .bash_profile.pysave PATH="/Library/Frameworks/Python.framework/Versions/3.9/bin:${PATH}" export PATH

I don't like this so I remove the added lines above and wire up my path as follows:

cat ~/.bash_profile ... # Point to Python 3 py3bin="/Library/Frameworks/Python.framework/Versions/3.9/bin" # Add to the front of your path so Python 3 is called first. export PATH="${HOME}:${pdflatexpath}:${ctagspath}:${libhidarcpath}: ${arcpath}:${scipypath}:${py3bin}:${bins}:${cmakepath}:${PATH}" ...

Create symbolic links so typing python on the command line calls python3,

cd /Library/Frameworks/Python.framework/Versions/3.9/bin sudo ln -s python3.9 python

Create symbolic links so typing pip on the command line calls pip3,

cd /Library/Frameworks/Python.framework/Versions/3.9/bin sudo ln -s pip3.9 pip

On Ubuntu Linux install pip using

sudo apt install python3-pip

On Ubuntu Linux do the following symbolic links:

cd /usr/bin/python3 sudo ln -s python3.9 python cd /usr/bin sudo ln -s pip3 pip

Upgrade pip, then check your Python and Pip versions:

pip3 install --upgrade pip
python -V Python 3.9.3 pip -V pip 21.0.1 from /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip (python 3.9)

For Python 3.9.x, install SSL root certificates

pip install certifi Collecting certifi Using cached certifi-2020.12.5-py2.py3-none-any.whl (147 kB) Installing collected packages: certifi Successfully installed certifi-2020.12.5

Windows On a Windows system, install into C:\Program Files\Python Go to Start/Control Panel/System/Advanced/Environment Variables and add the string ;C:\Python31; to the end of the path. For cygwin, in your Bash profile in your home directory, /cygdrive/c/cygwin/home/.bashrc, put PATH="/cygdrive/c/Python31:${PATH}" or else you can do a symbolic link, cd /usr/bin ; rm python ; ln -s /cygdrive/c/Python31/python3 python"

Mac or Ubuntu Linux Place code in your .bash_profile to set the path to Python 3.x Then run python -V to check the version is 3x and type quit() to exit. Keep the tutorial and library reference handy. Or better yet, download the whole set.

If you program LISP already, Python is very similar.

PyCharm

I use the free community edition of PyCharm IDE for source level debugging. There is some setup needed:

Point PyCharm to the location of the Python interpreter by going to Preferences->Project Interpreter.

To create a new project from an existing file do File->Open and select the file.

Edit the configuration to put in command line arguments for your script.

Troubleshooting

  • You need to define a main() function or PyCharm won't run.
  • If you get the error saying the SDK cannot be written to, try deleting all the Python interpreters in the list except the one you are using.

You can do source level debugging in the IDE

Debugging Python on the Command Line

In this example, we use my program updateweb.py The program has been set up to either run from the command line or as a module.

if __name__ == '__main__': """Python executes all code in the file, so all classes and functions get defined first. Finally we come here. If we are executing this file as a Python script, the name of the current module is set to main, thus we'll call the main() function.""" main() else: """When using as a module, start python, then import the module and call it: python import updateweb updateweb.main(["--test"]) Or if you want to debug, do this: python import pdb import updateweb pdb.run('updateweb.main(["--test"])') b updateweb.main c """ pass

Run Python and import the debugger module, and the entire script itself

seanoconnor:~/Desktop/Sean/WebSite/WebDesign/MaintainWebPage$ python Python 3.9.3 (v3.9.3:e723086bc3, Apr 2 2021, 08:25:55) [Clang 6.0 (clang-600.0.57)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import pdb >>> import updateweb

Set up the debugger to run starting in the main() function with arguments,

>>> pdb.run('updateweb.main(["--test"])')

Set a breakpoint in main

(Pdb) b updateweb.main Breakpoint 1 at /Users/seanoconnor/Desktop/Sean/WebSite/WebDesign/MaintainWebPage/updateweb.py:554

Start running the program. We stop at the breakpoint,

(Pdb) c > /Users/seanoconnor/Desktop/Sean/WebSite/WebDesign/MaintainWebPage/updateweb.py(558)main() -> print("""

List the source lines around the breakpoint

(Pdb) l 553 554 B def main(raw_args=None): 555 """Main program. Clean up and update my web site.""" 556 557 # Print the obligatory legal notice. 558 -> print(""" 559 updateweb Version 5.8 - A Python utility program which maintains my web site. 560 Copyright (C) 2007-2021 by Sean Erik O'Connor. All Rights Reserved. 561 562 It deletes temporary files, rewrites old copyright lines and email address 563 lines in source files, then synchronizes all changes to my web sites. (Pdb)

Print a variable

(Pdb) p raw_args ['--test']

Backtrace shows the calling stack,

(Pdb) bt /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/bdb.py(580)run() -> exec(cmd, globals, locals) (1)() > /Users/seanoconnor/Desktop/Sean/WebSite/WebDesign/MaintainWebPage/updateweb.py(581)main() -> CommandLineSettings(user_settings, raw_args )

See (Pdb) help and the Online Python Manual for more information.

Common Lisp

LISP is always ten years ahead at any given time.

Ubuntu Linux

sudo apt-get install sbcl

Macs Download the install package for the binary from Steel Bank Common Lisp. Unpack and follow instructions. Use the AMD binary, which is 64-bits, for Mac OS Catalina; you'll need to work around OS security issues.

$ sudo INSTALL_ROOT=/usr/local sh install.sh ... SBCL has been installed: binary /usr/local/bin/sbcl core and contribs in /usr/local/lib/sbcl/

Once installed, you'll get a bare-bones command line REPL. Try running $ sbcl from the command line and try

(car '(a b c)) (cdr '(a b)) (cons 'a '(b c)) (quit)

You can also run a LISP script from file directly:

cat hello.lsp #!/usr/local/bin/sbcl --script ; Shebang to call the LISP interpreter for this file. ; Do chmod 755 hello.lsp to make the file executable. ; ; hello.lsp ; A simple LISP test program. ; Print a string to the console. (write-line "Hello, World!") ; Convert a LISP list to a string. (defun list-to-string (lis) (format nil "~A" lis)) ; Function which prints a LISP expression and its evaluation to the console. (defun show-example( x ) (write-line (list-to-string `(,x => ,@(eval x))))) ; Print this example: ; (((LAMBDA (X) (1+ X)) 2) => . 3) (show-example '( (lambda(x) (1+ x)) 2) ) (show-example '(defvar dog)) (show-example '(setf dog '(husky))) (show-example 'dog)
./hello.lisp Hello, World! (((LAMBDA (X) (1+ X)) 2) => . 3) ((DEFVAR DOG) => . DOG) ((SETF DOG '(HUSKY)) => HUSKY) (DOG => HUSKY)

For convenience, I load my Common LISP parser generator project in the SBCL startup file .sbclrc

(load "LR(1)AndLALR(1)ParserGenerator.lsp") (load "LR(1)AndLALR(1)Parser.lsp") (test-parser-generator) (test-parser)

However, your life will be much easier if youw download and install Slime Unpack and install the slime directory in /Applications/slime then install this .emacs file in your home directory:

(setq inferior-lisp-program "/usr/local/bin/sbcl") (add-to-list 'load-path "/Applications/slime") (require 'slime) (slime-setup)

Vim, Ctags, Emacs, Slime, Steel Bank Common Lisp.

You should also install Emacs Invoke Emacs and with the command M-x slime go into Lisp interaction mode. Useful REPL commands are Control-c Control-p to move back one prompt, Control-c Control-n to move forward, Control-a and Control-e to go to beginning and end of the line, Control-x o to switch between buffers, Control-C Control-D d to lookup documentation for a symbol, and Control-X Control-S to exit emacs.

For LISP tutorials and references online see

I've also used CLISP

Perl

I was programming in Perl and switched over to Python after discovering this article.

FORTRAN

The first language I learned was FORTRAN from Bill Joy at U. C. Berkeley!

Berkeley Computing Center Punched card circa 1975.

It now has object oriented programming!

On Ubuntu Linux install GNU Fortran using

sudo apt-get install gfortran

Here's a sample program

$ cat circle.f90 ! A module containing classes. module class_Circle implicit none private real :: pi = 3.1415926535897931d0 ! Module-wide private constant ! Circle class. type, public :: Circle ! Member variable. real :: radius contains ! Member functions defined here but implemented elsewhere in the module. procedure :: area => circle_area procedure :: print => circle_print end type Circle ! Circle member functions implemented here. contains function circle_area( this ) result( area ) class( Circle ), intent( in ) :: this real :: area area = pi * this%radius ** 2 end function circle_area subroutine circle_print(this) class( Circle ), intent( in ) :: this real :: area area = this%area() ! Call the type-bound function print *, 'Circle: r = ', this%radius, ' area = ', area end subroutine circle_print end module class_Circle program circle_test use class_Circle ! Use the classes in the module. implicit none type( Circle ) :: c ! Declare a variable of type Circle. c = Circle( 1.5 ) ! Use the implicit constructor, radius = 1.5. call c%print ! Call the type-bound subroutine end program circle_test

Build it and run it!

$ gfortran circle.f90 -o circle ./circle Circle: r = 1.50000000 area = 7.06858349

Math Software

There are a number of free alternatives to MATLAB and Mathematica for symbolic and matrix computation.

SciPy

SciPy is a scientific math suite for Python.

Here's how to install on Mac.

python -m pip install --user numpy scipy matplotlib ipython jupyter pandas sympy nose statsmodels

You can list the packages installed using either python -m pip list or pip list.

pip list Package Version ----------------------- cycler 0.10.0 kiwisolver 1.1.0 matplotlib 3.1.2 numpy 1.17.4 pandas 0.25.3 patsy 0.5.1 pip 19.3.1 pyparsing 2.4.5 python-dateutil 2.8.1 pytz 2019.3 scipy 1.3.3 setuptools 42.0.2 six 1.13.0 statsmodels 0.10.2

To uninstall a package, for example, numpy, do

pip uninstall numpy

Here's an example taken from Normality Tests in Python Run python from the command line and type in these commands:

import numpy as np from numpy import mean from numpy import std from matplotlib import pyplot from statsmodels.graphics.gofplots import qqplot from scipy.stats import shapiro from scipy.stats import normaltest from scipy.stats import anderson # I generated random numbers from a N( 0, 10^2 ) distribution using the Box-Muller-Marsaglia method. NormalDeviatesList = [ -9.594, -6.614, 7.974, 8.959, 26.220, -11.746, -16.308, ... # Map to an np array type. NormalDeviatesArray = np.array( NormalDeviatesList ) # Mean and standard deviation look OK. mean(NormalDeviatesArray) -0.10023199999999999 std(NormalDeviatesArray) 9.95592528857946 # Plot a histogram and QQ plot. pyplot.hist(NormalDeviatesArray) pyplot.show() qqplot(NormalDeviatesArray, line='s') pyplot.show() # Run a few Normality tests. stat, p = shapiro(NormalDeviatesArray) stat 0.9996619820594788 p 0.5912390351295471 # So failed to the reject Normal hypothesis at 5% level using Shapiro-Wilks test. stat, p = normaltest(NormalDeviatesArray) stat 1.2465252328072989 p 0.5361921912564886 # So again, failed to the reject Normal hypothesis at 5% level using D’Agostino’s K^2 Test. result = anderson(NormalDeviatesArray) print('Statistic: %.3f' % result.statistic) Statistic: 0.350 p = 0 for i in range(len(result.critical_values)): sl, cv = result.significance_level[i], result.critical_values[i] if result.statistic < result.critical_values[i]: print('%.3f: %.3f, data looks normal (fail to reject H0)' % (sl, cv)) else: print('%.3f: %.3f, data does not look normal (reject H0)' % (sl, cv)) 15.000: 0.576, data looks normal (fail to reject H0) 10.000: 0.655, data looks normal (fail to reject H0) 5.000: 0.786, data looks normal (fail to reject H0) 2.500: 0.917, data looks normal (fail to reject H0) 1.000: 1.091, data looks normal (fail to reject H0)

Normal Histogram

QQ Plot

Sympy

Sympy is a symbolic math package built on top of Python.

Here's how to install on Mac.

First install mpmath by doing

git clone https://github.com/fredrik-johansson/mpmath.git cd mpmath git pull sudo python setup.py install
Then install sympy by doing
git clone https://github.com/sympy/sympy.git cd sympy git pull sudo python setup.py install
To do plotting, install matplotlib by doing,
python -mpip install -U matplotlib
Test by running Python, importing sympy and running a few commands,
python >>> from sympy import * >>> init_printing() >>> x = Symbol('x') >>> f = Function('f') >>> f = sin(x) >>> diff(f,x) cos(x) >>> integrate(f,x) -cos(x) >>> f.series(x,0,10) x - x**3/6 + x**5/120 - x**7/5040 + x**9/362880 + O(x**10) >>> a = Symbol('a') >>> b = Symbol('b') >>> c = Symbol('c') >>> d = Symbol('d') >>> m = Matrix( [[ a, b] , [c, d] ] ) >>> m ⎡a b⎤ ⎢ ⎥ ⎣c d⎦ >>> m.eigenvals() ⎧ _________________________ _________________________ ⎫ ⎪ ╱ 2 2 ╱ 2 2 ⎪ ⎨a d ╲╱ a - 2⋅a⋅d + 4⋅b⋅c + d a d ╲╱ a - 2⋅a⋅d + 4⋅b⋅c + d ⎬ ⎪─ + ─ - ────────────────────────────: 1, ─ + ─ + ────────────────────────────: 1⎪ ⎩2 2 2 2 2 2 ⎭ >>> m * (m ** -1) ⎡ a⋅d b⋅c ⎤ ⎢───────── - ───────── 0 ⎥ ⎢a⋅d - b⋅c a⋅d - b⋅c ⎥ ⎢ ⎥ ⎢ a⋅d b⋅c ⎥ ⎢ 0 ───────── - ─────────⎥ ⎣ a⋅d - b⋅c a⋅d - b⋅c⎦ >>> simplify( m * (m ** -1)) ⎡1 0⎤ ⎢ ⎥ ⎣0 1⎦

And here's a simple plot,

>>> plot(x**2,(x,-1,1))

Sympy plot( x**2, (x,-1,1))

Octave

Octave is a free MATLAB clone.

Run Octave.app from /Applications. It comes up in a terminal window. In the window, cd to your working directory containing your MATLAB .m files. Type the name of your MATLAB function or type the name of the .m file if you have just an inline main program.

SageMath

SageMath is a free mathematics software system comparable to Mathematica. You can interact with it using the Jupyter notebook interface. Follow the download instructions. Double click to launch. When you launch it, it will open up a couple of windows in your default web browser. This takes a few minutes, so wait patiently.

Sage 9.0 on MacOS Catalina has problems launching due to security. System Preferences ➤ Security & Privacy and click on Allow apps downloaded from: App Store and identified developers

Sage also has problems launching the Jupyter notebook. You must go around the security again. In a terminal window, type the commands,

xattr -rd com.apple.quarantine /Applications/SageMath-9.0.app/ /Applications/SageMath-9.0.app/Contents/Resources/sage/sage

Now you can launch the Sage app.

I've used it on my primitive polynomial finder

R

R is a statistical and plotting language.

For the Mac you can Download R as a package. Be sure to check the signature of the *.pkg file before you install it.

pkgutil --check-signature R-3.6.0.pkg Package "R-3.6.0.pkg": Status: signed by a certificate trusted by Mac OS X Certificate Chain: 1. Developer ID Installer: Simon Urbanek (VZLD955F6P) SHA1 fingerprint: 7B 6B 81 12 E6 26 8C 16 F8 D4 ----------------------------------------------- 2. Developer ID Certification Authority SHA1 fingerprint: 3B 16 6C 3B 7D C4 B7 51 C9 FE ----------------------------------------------- 3. Apple Root CA SHA1 fingerprint: 61 1E 5B 66 2C 59 3A 08 FF 58 md5 R-3.6.0.pkg MD5 (R-3.6.0.pkg) = 64ede92058dde6c4e4c2c11e0ba8a60c
Once installed, run on the command line. I found out we can use equals for variable assignment (see below).
R R version 3.6.0 (2019-04-26) -- "Planting of a Tree" Copyright (C) 2019 The R Foundation for Statistical Computing Platform: x86_64-apple-darwin15.6.0 (64-bit) > x = c( 1, 2, 3, 4, 5, 6, 7 ) > var(x) [1] 4.666667 > mean(x) [1] 4 > sum(x) [1] 28 > 2 * x [1] 2 4 6 8 10 12 14
Read Introduction to R

Keras and TensorFlow2

We show how to install Keras which is a wrapper for TensorFlow2, the convolutional neural net implementation from Google.

As of this writing, TensorFlow2 only supports Python 3.7. So as not to disturb the Python 3.9 installation, we'll create a Python virtual environment for it and install it within.

Check whether you have Python 3.7 already installed. If don’t, install it from the Python web site.

which python3.7 /usr/local/bin/python3.7 python3.7 -V Python 3.7.2

Install the Python virtual environment,

pip install virtualenv Collecting virtualenv Downloading https://files.pythonhosted.org/packages/05/f1/ 2e07e8ca50e047b9cc9ad56cf4291f4e041fa73207d000a095fe478abf84 ...

Create a virtual environment for TensorFlow2 which uses Python 3.7 in your home directory. This will create a subdirectory python37fortensorflow2.

virtualenv -p python3.7 python37fortensorflow2

Activate it. You’ll get a command line prompt showing you are in the virtual environment with the version of Python you chose.

source python37fortensorflow2/bin/activate (python37fortensorflow2) seanoconnor:~$ python -V Python 3.7.4

Upgrade pip in the virtual environment,

(python37fortensorflow2) seanoconnor:~$ pip install --upgrade pip

Install a current stable CPU-only TensorFlow2 package. This will take a while.

(python37fortensorflow2) seanoconnor:~$ pip install tensorflow

Install Keras within the Python virtual environment. This will take a while. I followed the Keras documentation

(python37fortensorflow2) seanoconnor:~$ pip install keras

You can run Python and import Keras as follows:

(python37fortensorflow2) seanoconnor:~$ python >>> import tensorflow.keras as keras >>>

I follow the hands-on tutorial Getting Started with Keras for Deep Learning since the author shows how to set up your own image set, combined with the theory in the book, Deep Learning by Ian Goodfellow and Yoshua Bengio and Aaron Courville

You'll also need to install imutil, scikit-learn, and matplotlib. Numpy should already be installed as a dependencyj

(python37fortensorflow2) seanoconnor:~$ pip install opencv-contrib-python (python37fortensorflow2) seanoconnor:~$ pip install imutils scikit-learn matplotlib (python37fortensorflow2) seanoconnor:~$ pip install numpy Requirement already satisfied: numpy in ./python37fortensorflow2/lib/python3.7/site-packages (1.18.0)

When you are done, deactivate your Python virtual environment (you can activate any time as above). The command line prompt reverts back to normal, and you're back to the latest Python again.

(python37fortensorflow2) seanoconnor:~$ deactivate $ python -V Python 3.9.3

To uninstall TensorFlow2,

pip uninstall tf-nightly-2.0-preview

To uninstall your Python virtual environment,

pip uninstall virtualenv

EDITORS

VIM Programmer's Editor

Download gvim from Vim for Mac and Ubuntu Linux. Don't forget the Vim User Manual and tutorial.

In Ubuntu Linux do this:

The latest Ubuntu versions jinstall gvim like this:
sudo apt-get install vim sudo apt install vim-gtk3

I've customized the Vim GUI in the startup file .vimrc which lives in the home directory ~ on Mac or Ubuntu Linux. On Windows the home directory is C:/Program Files/vim Here is my .vimrc

" NAME " " .vimrc " " DESCRIPTION " " Settings for Vim editor loaded upon startup. " " NOTES " " UNIX, Mac OS X: Copy to ~/.vimrc " Windows: Copy to C:/Program Files/vim/_vimrc " " AUTHOR " " Bram Moolenaar &lt;Bram@vim.org&gt; " Sean E. O'Connor 15 Oct 2020 " " " Use Vim settings, rather then Vi settings (much better!). " This must be first, because it changes other options as a side effect. set nocompatible " Mouse and window behavior tuned for Microslime Windows. behave mswin " Restore Control-F to page forward instead of find dialog box. "unmap&lt;C-F&gt; " Allow backspacing over everything in insert mode. set backspace=indent,eol,start " Turn on backup option. set backup " Create the backup directory if it doesn't exist. if !isdirectory($HOME.'/.vim/.backup') silent call mkdir( $HOME.'/.vim/.backup', 'p' ) endif " Store backups in the home directory ~/.vim/.backup. set backupdir=~/.vim/.backup " Make a backup before overwriting the current buffer. set writebackup " Overwrite the original backup file. set backupcopy=yes " Put swap files in the home directory ~/.vim/.swp if !isdirectory($HOME."/.vim/.swp") silent call mkdir( $HOME.'/.vim/.swp', 'p' ) endif set directory=~/.vim/.swp set history=500 " Keep 500 lines of command line history. set ruler " Show the cursor position all the time. set showcmd " Display incomplete commands. set incsearch " Do incremental searching. set hlsearch " Searches are highlighted. set wildmenu " File name completing using tabs cycles through all possibilities. set lazyredraw " Don't redraw screen while running macros. set lines=60 " Number of lines visible on the screen. set columns=140 " Number of columns visible on the screen. winpos 400 0 " Initial window position (MacBookPro). set winwidth=140 " Initial window width. set winminwidth=140 " set cursorline " Highlight the current line. set number " Show line numbers. set nosmartindent " Don't use smart indenting. set tabstop=4 " Tabs are 4 spaces wide. set softtabstop=4 " When editing, tabs are 4 spaces wide. set shiftwidth=4 " Indent 4 spaces. set expandtab " Expand tabs into spaces. set smarttab set showmatch " Show matching parentheses. set matchtime=5 " Match time is 1/2 sec. " Error blink and bell. set errorbells set visualbell " Set file paths to my most commonly used directories (MacBookPro). set path="~/Applications/vim/**" set path+="~/Desktop/Sean/WebSite/**" " Default directory is my current active subdirectory " in my web page directory. " This is where :e . takes us. cd ~/Desktop/Sean/WebSite/Mathematics/AbstractAlgebra/ PrimitivePolynomials/Project/SourceCode " Set paths for tags files generated by Ctags. See :help tags " "./tags" means search for the file "tags" in the same directory as the current f i l e you are editing. " "tags" means search for the file "tags" in the current working directory (the directory shown by the command :pwd) " NOTE: this is affected if you set autochdir (see below). " Then search from the directory containing tags to your home directory. set tags=./tags,tags;~ " Automatically change the current working directory to the one containing the file which was opened. See :help autochdir "Note: When this option is on some plugins may not work. set autochdir " Color them the same as the C group-name "Type". highlight link xType Type " | Color scheme and font for the full gVim GUI. " | Use the default for launching vim from a command window. if has("gui_running") colorscheme torte " To verify the if condition, on the Vim command line, do " :echo has("x11") " and look for 1 or 0. " " To find out the font type: " In the Vim command line, do " :set guifont=* " to make a menu come up. " " Select the font from the menu. " " Do the command " :set guifont? " to find out the name. " " In the if tests below, add " set guifont=&lt;name of the font&gt; " Escape all spaces with backslashes. " if has("gui_win32") set guifont=Courier_New:h13:b " Test for Mac first. elseif has("mac") set guifont=Menlo\ Regular:h12 " On Ubuntu Linux elseif has("x11") set guifont=Courier_New:h13:b " Otherwise else set guifont=* endif endif " Switch syntax highlighting on, when the terminal has colors. " Also switch on highlighting the last used search pattern. if &t_Co &gt; 2 || has("gui_running") syntax on set hlsearch endif " Abbreviations. My name: :iabbrev soc Sean E. O'Connor " Right arrow. :iabbrev rar &#10148; " Insert html math symbols. map ,th i&lt;em&gt;Theorem.&lt;/em&gt; map ,pf i&lt;em&gt;Proof.&lt;/em&gt; map ,lem i&lt;em&gt;Lemma.&lt;/em&gt; map ,cor i&lt;em&gt;Corollary.&lt;/em&gt; map ,qed i$\blacksquare$ " Insert Blender hotkeys. map ,bprop i&lt;img src="Images/bprop.jpg" alt="Properties Area" width="50" height="25"/&gt; &lt;em class="hotkey"&gt; Properties Area&lt;/em&gt; map ,bren i&lt;img src="Images/bren.jpg" alt="Render Properties" width="50" height="25"/&gt; &lt;em class="hotkey"&gt;Render Properties&lt;/em&gt; map ,bwor i&lt;img src="Images/bwor.jpg" alt="World Properties" width="25" height="25"/&gt; &lt;em class="hotkey"&gt;World Properties&lt;/em&gt; map ,bhot a &lt;em class="hotkey"&gt;&lt;/em&gt;&lt; ESC&gt;4hi " Insert html emphasis. map ,em a &lt;em&gt;&lt;/em&gt;&lt;ESC&gt;4hi " Insert html paragraph. map ,par i&lt;p&gt;&lt;CR&gt;&lt;CR&gt;&lt; /p&gt;&lt;ESC&gt;ki " Insert hyperlink. map ,hr i&lt;a href=""&gt;&lt;/a&gt;&lt;ESC&gt;0f"a " Insert an image. map ,img i&lt;img class="centeredsmaller" src="Images/thingumbob.jpg"& gt;&lt;ESC&gt;4bdwi " Insert a scroll box. map ,sb i&lt;div class="scrollBox"&gt; &lt;div class="scrollBoxContent"&gt;& lt;CR&gt;&lt;CR&gt;&lt;/div&gt;&lt; /div&gt;&lt;ESC&gt;ki " Reload this VIM resource file. map ,sou :source $HOME/.vimrc&lt;CR&gt; " Save the file. map ,sa :w&lt;CR&gt; " Trim blanks at end of all lines. Turn off search highlighting. map ,tbe :%s/\s*$//&lt;CR&gt;&lt;ESC&gt; :nohlsearch&lt;CR&gt;&lt;ESC&gt; " Make p in Visual mode replace the selected text with the "" register. vnoremap p &lt;Esc&gt;:let current_reg = @"&lt;CR&gt; gvs&lt;C-R&gt; =current_reg&lt;CR&gt;&lt;Esc&gt; " Turn off highlighting after searches. map ,&lt;SPACE&gt; :nohlsearch&lt;CR&gt; " Toggle comment lines. You can highlight the range " with the mouse and then type ,to map ,to :call ToggleComment()&lt;CR&gt; function! ToggleComment() " Get the line under the cursor " Check if it begins with | if getline(".") =~ '^|' let s:savedSearchPat=@/ s/^|// let @/=s:savedSearchPat else let s:savedSearchPat=@/ s/^/|/ let @/=s:savedSearchPat endif endfunction " You can highlight lines of text before you call this function which converts angle brackets and ampersands to HTML. map ,ch :call CleanHTML()&lt;CR&gt; function! CleanHTML() s/&/\&amp;/g s/&gt;/\&gt;/g s/&lt;/\&lt;/g endfunction " Convert C comments on a line to C++ comments. map ,cc :call ConvertCCommentToCpp()&lt;CR&gt; function! ConvertCCommentToCpp() " Get the line under the cursor " Check if contains a /* if getline(".") =~ '\/\*' let s:savedSearchPat=@/ s/\/\*/\/\// let @/=s:savedSearchPat endif if getline(".") =~ '\*\/' let s:savedSearchPat=@/ s/\*\/// let @/=s:savedSearchPat endif endfunction " Justify a paragraph. map ,j gqap
Searching Multiple Files in Vim

For example, to search all *.cpp files in the current directory for the word static_cast, do this on the vim command line:

:vimgrep /static_cast/ **/*.cpp :copen 20

You can then go to the line containing the pattern you want and hit return to go to the file.

Searching Patterns in Multiple Files in Vim

File Differences in Vim
To do file differences, load the first file, ignore whitespace with :diffopt=iwhite, then do :diffsplit <second file name>. :diffupdate will resync if needed.

LibreOffice - Free Replacement for Microsoft Office

LibreOffice is free office suite compatible with Microsoft Office. Their apps can replace Excel, Word and PowerPoint. There are also Math and Database apps. LibreOffice apps can read Excel, Word and PowerPoint files, but may not be able to write recent versions of the file format.

On Mac OS Catalina, you will get a warning message when you try to launch the first time.

Just open LibreOffice again by right clicking on the app icon and selecting open

ΤεΧ

For Mac OS download an install bundle from the MacTex TeX User's Group,

For Ubuntu Linux install using the install instructions,

sudo apt install texlive-latex-extra

Then try it out on a LaTeX file by processing it to a .pdf

pdflatex MortgageLoanDerivation.tex

View the .pdf file with either

evince MortgageLoanDerivation.pdf

or

xdg-open MortgageLoanDerivation.pdf

Be sure to read the quickie introduction A (Not So) Short Introduction to LATEX2ε

Art Software

GIMP Paint Program

Similar to Adobe Photoshop with paint tools and layers, but free, GIMP runs on both Windows, Mac, and Ubuntu Linux download it and its documentation from Gimp

Gimp

In Ubuntu Linux install with

sudo apt-get install gimp

Blender

Blender is a free 3D rendering and animation tool. I have a worked example on my art page.

Inkscape

I use Inkscape to do the drawing and generate SVG files.

To install on Ubuntu Linux,

sudo apt install inkscape

Right click on the Dash, and Add to Favorites

INTERNET

Netzero ISP

I used connect to the internet through the dialup telephone line using Netzero but now I use AT&T Uverse.

FTP

On Mac OS I use the FTP client Transmit. Not free but very easy to use.

On Ubuntu Linux I use the free FTP client FileZilla. which is easily installed,

sudo apt install filezilla

Zip File Compression Software Windows

Install PKZIP from PKWare or use Gzip

Web Browsers

Download the Firefox, Opera and Chromium browsers. Safari comes with MacOS.

Email Clients

On Ubuntu Linux install Thunderbird email,
sudo apt-get install thunderbird

GAMES

Stellarium

Stellarium is a free planetarium program.

On Ubuntu Linux install using
sudo apt install stellarium

Red Pill Screen Saver

Get the source code from GitHub opx3 / RedPill2. You can clone the repository using

git clone https://github.com/opx3/RedPill2.git

Build in XCode in Release mode. Let XCode update your settings. Double click on RedPill.saver to load it.