Refreshing .profile without restarting Terminal Window in Linux / Mac OS X

As you begin programming you are often asked to configure your Mac’s environment, and asked to add a PATH or other ENVironmental variable to your profile.

Youtube videos encourage their audience to set their environmental variables by opening and closing their terminal windows. This works fine but
With Linux/Unix/MacOSx this works fine but did you know you can launch Terminal from the command prompt?

To open a new terminal window

$ open -a Terminal ~

Using ~ is short-hand for “the current user’s home directory”


# common startup files


Installing Sublime Text

[trx_accordion counter=”on” initial=”1″]
[trx_accordion_item title=”Step1″]In my the previous post, I outlined the process to set up your Django Virtual Environment, based on the CodingEntrepreneurs Udemy course “Coding for Entrepreneurs: Learn Python, Django, and More. Within that course they suggest using the Komodo editor. However I found that the intenseness text autocomplete feature didn’t fully work right out of the box. When I asked the moderators I was turned onto Sublime Text. I found the editor to be excellent with the autocomplete features working as soon as I opened my Django project directory. The following are the steps for installing Sublime Text[/trx_accordion_item][trx_accordion_item title=”Installing Sublime Text”]
Download the Sublime Text installer.
From here you should be able to install, but if you want to watch someone, head over to Tuts+ Django course and watch the free preview videos.[/trx_accordion_item][trx_accordion_item title=”Opening Django Project”]After installation, just go File –> Open, and navigate to your project folder.


SublimeTextSampleFile[/trx_accordion_item][trx_accordion_item title=”References”]Sublime text has some excellent documentation accessible right from the help menu.[/trx_accordion_item][/trx_accordion]

Installing and Setting up a Django Project into a Virtual Environment

[trx_accordion counter=”on” initial=”1″]
[trx_accordion_item title=”Introduction”]The CodingEntrepreneurs have an excellent online Udemy course “Coding for Entrepreneurs: Learn Python, Django, and More.” Obviously to take the course you need to install Django. To that end, they have a great Youtube video.

Starting/stopping the video as I follow along is great, but I prefer to also have notes in outline format. Notes help me understand learning objectives and serve as a review after I’ve completed the lesson.

This post provides companion notes to their Youtube.

[/trx_accordion_item][trx_accordion_item title=”Install Python”]Udemy tutorial requires Python 2.7.5 or greater. From a terminal command prompt you can simply run python and check your installed version

If you need to upgrade your python version, goto, download and install.[trx_block class=”codesample”]Oden:~ user$ python
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.[/trx_block][trx_icon icon=”icon-info” color=”#1e73be”]When I ran the python installer, there was a comment about using pip2.7; which is not important as both pip and pip2.7 are linked to the same pip executible[/trx_accordion_item][trx_accordion_item title=”Verify Installation”]Verify the python upgrade, run python and verify its the correct version.[trx_block class=”codesample”]Oden:~ user$ python
Python 2.7.9 (v2.7.9:648dcafa7e5f, Dec 10 2014, 10:10:46)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.[/trx_block][/trx_accordion_item][trx_accordion_item title=”Install Package Installer for Python”][trx_icon icon=”icon-info” color=”#1e73be”] Its OK if version of PIP is slightly different (i.e. greater version) than what is listed here or in the youtube video.
Online documentation for pip is available.
[trx_block class=”codesample”]Oden:~ user$ sudo easy_install pip

WARNING: Improper use of the sudo command could lead to data loss
or the deletion of important system files. Please double-check your
typing when using sudo. Type “man sudo” for more information.

To proceed, enter your password, or type Ctrl-C to abort.

Searching for pip
Best match: pip 1.5.6
Adding pip 1.5.6 to easy-install.pth file
Installing pip script to /Library/Frameworks/Python.framework/Versions/2.7/bin
Installing pip3.4 script to /Library/Frameworks/Python.framework/Versions/2.7/bin
Installing pip3 script to /Library/Frameworks/Python.framework/Versions/2.7/bin

Using /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
Processing dependencies for pip
Finished processing dependencies for pip[/trx_block]
You can verify that a pip and pip2.7 are identical version.[trx_block class=”codesample”]Oden:~ user$ pip2.7 -V
pip 1.5.6 from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (python 2.7)

Oden:~ user$ pip -V
pip 1.5.6 from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (python 2.7)[/trx_block]
You can also verify that pip and pip2.7 are the identical executable file.[trx_block class=”codesample”]Oden:~ user$ find / -name pip2.7 2>/dev/null

Oden:~ user$ find / -name pip2>/dev/null

Oden:~ user$ cd /usr/local/bin/
Oden:~ user$ ls pip*
lrwxrwxr-x 1 root admin 65 Dec 19 16:15 pip@ -> ../../../Library/Frameworks/Python.framework/Versions/2.7/bin/pip
-rwxr-xr-x 1 root wheel 249 Sep 2 2013 pip-2.7*
lrwxrwxr-x 1 root admin 66 Dec 19 16:15 pip2@ -> ../../../Library/Frameworks/Python.framework/Versions/2.7/bin/pip2
lrwxrwxr-x 1 root admin 68 Dec 19 16:15 pip2.7@ -> ../../../Library/Frameworks/Python.framework/Versions/2.7/bin/pip2.7[/trx_block][/trx_accordion_item][trx_accordion_item title=”Install Python Virtual Environment”]Best practices separate Python projects into their own virtual environments, so that any changes to your main computers software doesn’t introduce issues. With Virtual environments your virtual environment can have its own Python version along with its own set of Python packages.
[trx_block class=”codesample”]Oden:~ user$ sudo pip install virtualenvl
Downloading/unpacking virtualenv
Downloading virtualenv-1.11.6-py2.py3-non-any.why (1.6MB): 1.6MB downloaded
Installing collected packages: virtualenv
Successfully installed virtualenv
Cleaning up…[/trx_block][/trx_accordion_item][trx_accordion_item title=”Create Virtual Environment for a Project”]You can create your project directory anywhere; below I’m showing it created on the users desktop.
[trx_icon icon=”icon-info” color=”#1e73be”]Note the tilde ~ character simply refers to the current user’s home directory.
[trx_icon icon=”icon-info” color=”#1e73be”]If at anytime you want to clear the terminal window use the ⌘-k shortcut.
[trx_block class=”codesample”]Oden:~ user$ cd ~/Desktop
Oden:~ user$ pwd
Oden:~ user$ virtualenv LearnDjango

New python executable in LearnDjango/bin/python
Installing setuptools, pip…done.[/trx_block][/trx_accordion_item][trx_accordion_item title=”Activate the Project’s Virtual Environment”]Activating the project is required.
[trx_icon icon=”icon-info” color=”#1e73be”] bin/activate simply adds the VIRTUAL_ENV and changes the PATH, environmental variables.
[trx_icon icon=”icon-info” color=”#1e73be”] When the Virtual environment is active the command prompt is prefaced with the project name, in this case prefaced with (LearnDjango).[trx_block class=”codesample”]Oden:~ user$ cd LearnDjango
Oden:~ user$ pwd
Oden:~ user$ source bin/activate
(LearnDjango)Oden:LearnDjango user$
[/trx_block][/trx_accordion_item][trx_accordion_item title=”Verify Virtual Environment Installation”]To see and check what python packages are installed you can use the pip freeze or pip list commands.[trx_block class=”codesample”](LearnDjango)Oden:LearnDjango user$ pip freeze

(LearnDjango)Oden:LearnDjango user$ pip list
pip (1.5.6)
setuptools (3.6)
wsgiref (0.1.2)[/trx_block][/trx_accordion_item][trx_accordion_item title=”Install Django into Virtual Environment”]From the virtual environment directory, use pip.[trx_icon icon=”icon-info” color=”#1e73be”] If you are following the Udemy class, you can install the other python packages with “pip install django django-registration south stripe”[trx_block class=”codesample”](LearnDjango)Oden:LearnDjango user$ pip install django
Downloading/unpacking django
Downloading Django-1.7.1-py2.py3-none-any.whl (7.4MB): 7.4MB downloaded
Installing collected packages: django
Successfully installed django
Cleaning up…[/trx_block][/trx_accordion_item][trx_accordion_item title=”Verify Django Installation”]Rerun the pip freeze and see that Djano has been installed.[trx_block class=”codesample”](LearnDjango)Oden:LearnDjango user$ pip freeze
Django==1.7.1[/trx_block][/trx_accordion_item][trx_accordion_item title=”Create Django Project”]Creating a Django project uses the program.[trx_block class=”codesample”]Oden:~ user$ startproject my_project
[/trx_block][trx_icon icon=”icon-info” color=”#1e73be”]This is a good time to familiarize yourself with the standard project directory structure.[trx_block class=”codesample”]
Oden:~ user$ ls
total 8
drwxr-xr-x 7 user staff 238 Dec 20 15:02 ./
drwx——@ 21 user staff 714 Dec 20 14:42 ../
lrwxr-xr-x 1 user staff 56 Dec 20 14:42 .Python@ -> /Library/Frameworks/Python.framework/Versions/2.7/Python
drwxr-xr-x 17 user staff 578 Dec 20 14:55 bin/
drwxr-xr-x 3 user staff 102 Dec 20 14:42 include/
drwxr-xr-x 3 user staff 102 Dec 20 14:42 lib/
drwxr-xr-x 4 user staff 136 Dec 20 15:02 my_project/ [/trx_block][trx_icon icon=”icon-info” color=”#1e73be”]Best practice suggests renaming you project folder to src, via the finder or using “mv my_project src” from the terminal window command prompt.[/trx_accordion_item][trx_accordion_item title=”Start Django Server”]The is used to start the Django web server. For a complete list of commands available see the and documentation. [trx_block class=”codesample”](LearnDjango)Oden:LearnDjango user$ python runserver
Performing system checks…

System check identified no issues (0 silenced).

You have unapplied migrations; your app may not work properly until they are applied.
Run ‘python migrate’ to apply them.

December 20, 2014 – 23:05:16
Django version 1.7.1, using settings ‘my_project.settings’
Starting development server at
Quit the server with CONTROL-C[/trx_block][/trx_accordion_item][trx_accordion_item title=”View Django Project”]To test Django server and view the default application, open the server URL “ in a web browser.”


Dual sided scanning with single sided scanner

I recently purchased a Brother multifunction printer (MFC-7460DN) – its great to be able to print, fax and scan on the network. But it it only scans single side documents!!!

PDF Labs  to the rescue with a free (non-commercial distribution use) solution. The process is very simple. I’ll share how I set it up to work with my Mac OS X 10.x (Yosemite).

  1. Brother Control Center software
    1. For this walk through I’ve assumed you already installed all the software that comes with the Brother multifunction printer (MFC-7460DN.) If not head over to Brother Support and download the appropriate drivers.
      Download Brother Software
  2. PDFServer
    1. Download and install PDF Labs PDFserver software (its free for home use; a commercial license to distribute is required.) The installation doesn’t require anything special
    2. Optional – Since the PDFserver is a command line tool, I like to remind myself that I installed the software by adding a note into my user profile. Again this is not necessary but, great if you sometimes forget what you have installed.
      1. Open a Terminal window
      2. Edit your profile (with your favorite editor) and add the following; which simply reminds you that you have extra tools installed.
         echo PDFtk has been installed to /opt/pdflabs/pdftk/
         echo    man pdftk for usage
         echo    see
  3. Configuring Control Center to scan to file
    1. Launch Control Center
    2. Set the File scan options for the ODD pages
      Note: Once you understand what this all does you can modify as you need, but for now use:
      Name the File: Odd
      Turn off: Insert Date in File Name
      Set the Destination Folder to “Downloads”
      Select File Type: PDF
    3. Place you documents in the scanner, then Click “Start Scanning”
    4. When the documents are done, take them from the output slot and insert them upside down into the scanner (note they will be in reverse order, last page on top, first page on bottom)
    5. Change the “Scan to File” settings by change the File Name to “Even” then, Click “Start Scanning”
    6. You should now have two documents Odd.PDF and Even.PDF in your Downloads folder
  4. Combine the Files into one PDF
    1. In your terminal window (re-open if you closed it); change to the directory with your files
      cd ~/Downloads
    2. Now combine the files with:
      pdftk A=Odd.pdf B=Even.pdf shuffle A Bend-1 output collated_pages.pdf
    3. Your file will be in the called “collated_pages.pdf” with odd and even pages properly oriented.

This process is pretty simple, but I hope to use Mac Automator to create a easier workflow.



Mac OSX Yosemite – Simple Finder Hidden File Toggle

Wouldn’t it be nice to use Finder to see all your files, including your hidden files.

Well there are lots of postings showing you how to use the Terminal to run a command line script that toggles some of the Apple Finder default behaviors. But opening a terminal window every time is a pain, there has to be an easier way.

Wouldn’t it be nice to simple click an icon?  Well there is an easy way using the Automator

1 – Head over to launchpad, the launch Automator


2 – Select Application



3 – Next Drag Run Shell Script onto the workflow pane



4 – Select correct shell: ‘/bin/bash’ and type the following, and save the file to the desktop:
(I saved mine as ‘HiddenFileTOGGLE’)

#!/bin/bashSTATUS=`defaults read AppleShowAllFiles`
if [ $STATUS == TRUE ];
defaults write AppleShowAllFiles FALSE
elsedefaults write AppleShowAllFiles TRUE

killall Finder

5 – Now ever ytime you want to change, just double click ‘HiddenFileTOGGLE’

Setting up Multisite WordPress with GoDaddy Hosting and URL Forwarding

Setting up Multisite WordPress with GoDaddy Hosting and URL Forwarding


My journey into WordPress started, over 6 years ago. I first set up a site.  Then, about 20 months ago, when Amazon Web Services started offering a try it Free for one year, I decided I could kill two birds with one stone. I could host my own wordpress site and learn about cloud technologies at the same time. I set up, the hard way installing WordPress from scratch, but then discovered BitNami – a mega repository of preconfigured Amazon Machine Images for instantly deploying cloud services.

I was able to simple set up my Amazon EC2 (elastic computer cloud) with WordPress 3.x in 20 minutes – probably less if had know what I was doing. But as the year ended, I found the cost to host more than what GoDaddy and other web hosting companies charged. There were some tradeoffs. But that story is for another blog entry.

As I began running my own WordPress site, I stumbled across a GoDaddy FAQ that said you could run multiple sites on a single server (provided the sites were low usage sites.)  And thus began my journey to set up a Multisite WordPress.

What is Multisite WordPress? 

In simple terms, its the ability to run multiple WordPress sites from one single installation.  For example and can both reside on the same physical server, using the same base WordPress php code and a single MySQL database.

Multisite should not to be confused with multiple WordPress sites installed separately (into their own directories) on the same server; each using its own MySQL database.

Visit the WordPress Multisite support forum if you need additional help; I posted a couple of questions when I got stuck and had them answered promptly (within a day.)

Why did I choose Multisite?

In my case, I am the primary administrator for several sites, without the need to overly worry about failure compartmentalization. In other words, the benefits of logging into one location to manage all the sites outweighed the potential costs if I experienced a problem when I upgraded WordPress (or plugins etc…)

How did I install Multisite?

The rest of this blog assumes you

  • have an existing WordPress site hosted by GoDaddy
  • are the administrator of the GoDaddy hosted server and WordPress site.
  1. Backup you WordPress
    1.  Start by ensuring you have a backup of your entire WordPress. If you don’t know how, research a method, select a backup method, then backup, the restore and, most importantly – prove to yourself you can rebuild your WordPress from your backup!
    2. I used the  GoDaddy backup approach; by logging into GoDaddy’s cPanel for my server; then selecting Backup Wizard to save my “Home Directory” and “MySQL” database. This approach saves ZIPPED files that through the same GoDaddy menu can be used to restore the entire WordPress public_html directory and the MySQL database.
  2. Upgrade Wordpres
    1. Upgrade to latest WordPress; In my case I happened to time it when WordPress 4.0 (yes a scary Dot Oh release) was released.
    2. From the plugins, I simply selected upgraded my WordPress 3.9x to 4.0; I was fortunate and everything worked fine.
  3. Enable Multisite
    1. I started by following GoDaddy’s FAQ – The are basically worthless and provide such sketchy detail, as to be indecipherable. Once you have actually finished installing Multisite you should be able to review the FAQ and figure out what the bleep they were trying to say in the first place.
    2. Follow the excellent Youtube by instructions (Note make sure you check to see if there is a newer video; At first I found and older video that lead me astray and wasn’t as clear)  WPKB also has a document version (but again the Youtube is better)
    3. Just follow the Youtube it works.
    4. On selecting which multisite approach to use (using Subdomains or  Subdirectories), I chose to use subdomains.  I choose this approach because I had a better sense on how to redirect URL requests. Mainly  I knew how to make sure if someone typed into the web browser  “MySecondSite.Com” or “MyMainSite.Com” they would end up in the right place.
  4.   Add your second site
    1. At this point you can easily add a second WordPress site by logging into the WordPress as the master site administer and selecting “My Sites” and “Creating a New Site” then filling in the form.
  5. Buy your second site Domain name and add it to your WordPress server
    1. For me I simply purchased “” through GoDaddy.
    2. From the cPanel park your Domain name
    3. Make sure to point the domain to the main WordPress install directory. GoDaddy automatically creates a domain root in a subdirectory!! CHANGE THIS – For example – in my case – it needs to say “/public_html” NOT “/public_html/philiptopham
  6. Mapping a different Domain name to the SubDomain
    1. At this point if you In my case I wanted people to type “” I didn’t want people to type “” into the browser. So I needed to install a URL Domain Mapping tool.
    2. Install the WordPress MU Domain Mapping plugin; the plugin’s installation instructions worked well. At the time of this writing the plugin is listed as compatible with WordPress 3.9.2 but I installed on WordPress 4.0 with no issues (thus far)
    3. The configuration instructions were also straight forward.
      1. In my case the I chose to CREATE a CNAME record.
      2. I logged in to my Godaddy account.
      3. Selected “MyMainSite.Com”  –> Then edit DNS Zone File
      4. Add CNAME “philiptopham” pointing to “@”; waited about 10 minutes and was able to login.
      5. Test by going to WordPress main account then “visiting” each site and verifying the URL resolves correctly.