Tag Archives: macOS

How to Convert M4A to WAV File on macOS

Motivation:

You have downloaded some M4A audio files.

You want to extract convert them to WAV files to listen to them in other devices that do not support playing M4A files.

Procedure:

  • In the Music app on your Mac, choose Music > Preferences, then click Files.
  • Copy the path of Music Media folder location. (An example path is Macintosh HD/Users/admin/Music/Music/Media.)
  • Click the Import Settings… button.
  • In the Import Using pop-up menu, set Import Using = Wav Encoder, then click OK to save the settings.
  • Drag M4A files to the Music app.
  • Select songs in your library, then click File > Convert > Create WAV Version.
  • Go to your library folder (i.e. the Music Media folder location) and copy the WAV files to other devices.
  • Delete the M4A files from your library.

How to Fully Uninstall Cocoapods from macOS

Problem:

You run pod update but you get command not found error.

You want to fully uninstall the Cocoapods from macOS, and then to reinstall it to remove the error.

Solution:

Execute below commands:

for i in $( gem list --local --no-version | grep cocoapods );
do 
    sudo gem uninstall $i; 
done
rm -rf ~/.cocoapods

If you have a Cocoapods icon on the Launchpad then

    • Click on the  Cocoapods icon on the Launchpad,
    • Right click the Cocoapods icon in the Dock,
    • Point your mouse to Options, then click Show in Finder,
    • Right click the Cocoapods icon and select Move to Trash.

Execute below command to reinstall Cocoapods

sudo gem install cocoapods

 

How to connect and upload files to a remote machine using OpenVPN and SSH on macOS

Motivation:

You have a server inside a network. You are granted OpenVPN and SSH access to the server. You have a MacBook. You want to upload files to the server. You want to execute a process on the server (e.g. training a machine learning model).

Procedure:

  • Request a certificate and an Open VPN configuration file (an .ovpn file) from your network administrator.
  • Install Tunnelblick https://tunnelblick.net
  • Drag the Open VPN configuration file to the Tunnelblick Configurations tab.
  • Click the Connect button.
  • On macOS, open Terminal and execute below command
ssh [email protected] -p 7081

where 172.29.64.144 is the machine IP and 7081 is the SSH port

How to Completely Uninstall Python on macOS

Problem:

You have an issue with a Python version (e.g. the 3.7 version) and want to install another version (e.g. the 3.6 version). In order to install a fresh version you need to uninstall the current version first.

Solution:

Assume that the current version is 3.7. Replace 3.7 with another version that you installed.

Follow these 3 steps below.

1. Remove the third-party Python 3.7 framework

sudo rm -rf /Library/Frameworks/Python.framework/Versions/3.7

2. Remove the Python 3.7 applications directory

sudo rm -rf "/Applications/Python 3.7"

3. Remove the symbolic links, in /usr/local/bin, that point to this Python version. Ensure that the links exit using below command

ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/3.7'

then run the following commands to remove all the links:

cd /usr/local/bin/
ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/3.7' | awk '{print $9}' | tr -d @ | xargs rm

Installing a new version:

  1. Download a version from https://www.python.org/downloads/mac-osx/, double click the file and follow the instructions.
  2. Verify installation: python3 –version
  3. Install Homebrew from https://brew.sh
  4. Install virtualenv
pip3 install virtualenv
pip3 install virtualenvwrapper

5.  Create and activate a virtual environment

cd

/Users/admin/Downloads/training_model/model

 
python3 -m virtualenv

/Users/admin/Downloads/training_model/model

source bin/activate

How to Install Windows on your MacBook using Boot Camp

Motivation:

You have a MacBook and you want to use an application that only works on Windows.

Procedure:

1. Prerequisite:
  • Ensure that your macOS is up-to-date and does not have any issue.
  • If you want to reinstall macOS then you can hold down Command+R after powering your machine on.
2. Installing Windows on your MacBook using Boot Camp

In macOS:

  • Finder > Shift+Command+u > Boot Camp Assistant
  • Select 350Gb (or another appropriate size) for Windows. Use Windows 10 version 1909, April 2020 or Windows 10 version 1709, November 2017.
  • Remove unnecessary macOS applications (e.g. Numbers, Pages, Garage Band) if you want to use as much as possible storage for Windows.
  • Install Windows 10.
    – DO NOT USE Disk Management to create new partitions during Windows installation. Only use Disk Management to format an existing partition when installing Windows.
    – During the next boot into OS X, the OSXRESERVED partition is removed and put back into the Core Storage container of the OS X partition.

in Windows:

  • Install Boot Camp drivers.
  • Boot Camp Control Panel… > TrackPad > Tap to Click.
  • Change Computer Name, disable System Protection, enable Remote Desktop, activate Windows.
  • Turn on Automatic Logon
    Command Prompt (Run as Administrator) >> netplwiz
  • Disable Hibernate
    Command Prompt (Run as Administrator) >> powercfg.exe /hibernate off
  • Power management > Change plan settings > Change advanced power settings
    >> Hard disk > Turn of hard disk after > Never
    >> Sleep > Sleep after > Never
  • Adjust System > Display > Brightness and color.
  • Uninstall unnecessary apps.
  • Use Disk Management to shrink the BOOTCAMP partition and create a new DATA partition. Use 150Gb (153600MB) as the amount of space to shrink.
  • Check and install Windows updates.
  • Copy portable apps.
Developer’s tools:
  • Turn the following Windows features on: ASP.NET 3.5, 4.7, Internet Information Service, Telnet Client
  • Install Hyper-V, create an external Virtual Switch for Internet access
  • Install Total Commander, Remote Desktop Connection Manager
  • Install Firefox
  • Install MS SQL Server 2008 R2, MS Office 2007 SP3 (Display >> Scale and layout: 175%), MS Project 2016, MS Visio 2016, Visual Studio 2010, Visual Studio 2015, Adobe Acrobat Pro DC v15.8, Adobe Photoshop CC 2015, TortoiseSVN 1.11.1
  • Install Python 3.6.8, TensorFlow, Keras
3. Removing Windows from your MacBook using Boot Camp

In Windows:

  • Delete all Windows Data partitions, then Extend the Boot Camp volume (C:\) using Windows Disk Management.

In macOS:

  • Finder > Shift+Command+u > Boot Camp Assistant > Continue > Restore
  • If you get any problem with Boot Camp Assistant then delete Windows Boot Camp partition using Disk Utility: Finder > Shift+Command+u > Disk Utility > Partition.
  • If you get a “Ghost” partition after deleting Windows Boot Camp partition using Disk Utility then please use the following procedure to remove it:

Execute below command:

diskutil list

Find EFI IDENTIFIER (e.g. disk0s1).

Execute 2 below commands:

sudo mkdir /Volumes/efi
sudo mount -t msdos /dev/disk0s1 /Volumes/efi

Navigate to /Volumes/efi/EFI. Delete all directories (i.e. Microsoft and Boot) except the APPLE directory.

Execute below command:

diskutil unmount /Volumes/efi
4. Repair or update Boot Camp drivers in Windows
  • Download and install 7-Zip.
  • Download Brigadier 0.2.4.
  • Run Brigadier to automatically detect your Mac model and download the right Boot Camp drivers for Windows 10, and extract them (using 7-Zip) to the same location where Brigadier executable is located.
  • Find and double-click on Setup.exe to run it.

 

 

 

Topic 1 – Operating Systems

Why do I need to learn about operating systems?

Because you will develop your software using an operating system or for an operating system.

What can I do after finishing learning operating systems?

You will be prepared with skills that help you prepare environments for your your programming journey.

You will be prepared with knowledge that helps you understand programming terminologies.

You may even be inspired to learn programming to solve problems.

How many operating systems should I know?

As many as possible. We recommend that you learn how to work with Windows first. Then you learn about basic concepts of an operating system.

How do I learn to use operating systems?

Please read this Andy Rathbone (2015). Windows 10 For Dummies. Wiley book.

How about other operating systems such as macOS, Linux or Unix?

If you have a Mac then you can read this Pogue David (2019). macOS Mojave: The Missing Manual. O’Reilly Media book.

If you have a PC with Ubuntu, or Linux, or Unix then you can read this Mark G. Sobell (2015). A Practical Guide to Ubuntu Linux. Prentice Hall book.

After that please read these Introduction to Computing Principles lecture notes.

After that please read this Abraham Silberschatz et al. (2018). Operating System Concepts. Wiley book.

Terminology Review:

  • Central Processing Unit (CPU).
  • Random-Access Memory (RAM).
  • Hard Disk Drive (HDD).
  • Solid-State Drive (SSD).
  • Programs.
  • Basic Input/Output System (BIOS)
  • Unified Extensible Firmware Interface (UEFI).
  • Boot Loader.
  • Operating System (OS).
  • Monolithic Structure.
  • Microkernels.
  • User Mode.
  • System Calls.
  • Kernel.
  • Kernel Mode.
  • Processes.
  • Threads.
  • Process Synchronization.
  • Memory Management Unit.
  • Logical Address.
  • Physical Address.
  • Paging.
  • File System.
  • Security and Protection.
  • Networks.
  • Virtual Memory.
  • Virtualization.
  • Virtual Machines.

Once you finish learning about operating systems please click Topic 2 – Introduction to Computer Networks to continue.