Creating a .bash_profile file in OS X and adding PATH directories

If you’re starting out with a fresh install of OS X (10.9 in my example) and are using any development tools, at some point I’m sure you’ll want to add some directories to your system PATH. In short: this allows you to use an application in a specific directory from any other directory – commonly when you’re running commands in Terminal.

To start, we’ll utilize a text editor – in my case I’m using TextMate – but any plain text editor should do. Let’s get to it:

  1. bash_1Let’s first make sure you don’t already have a .bash_profile. In TextMate, go to File > Open. Browse to your home folder (with the house icon) and click “Show Hidden Files”. In your home folder you shouldn’t already see a .bash_profile file. (If you do, then you don’t need to create a new file and can open your file, make changes and skip to step 5.)
  2. bash_2So cancel the open dialog and enter some text into the untitled file currently open. You’re usually entering something like: export PATH=${PATH}:/somedirectory/asubdirectory:/anotherdirectory
  3. bash_3Now let’s save our new .bash_profile. Go to File > Save As. Browse to your home folder (with the little house icon again). Enter the filename as “.bash_profile” (without quotes).
  4. bash_4If you get a message saying “names that begin with a dot are reserved for the system” chose “Use ‘.’
  5. bash_5That’s it. Now if you already have a terminal open run source ~/.bash_profile (this just give you access to the updated PATH).
Creating a .bash_profile file in OS X and adding PATH directories

Local web server for testing / development using Node.js and http-server

localhost8080If you’re developing html / javascript applications and want to test locally, many times you will go beyond what local file access (file:///C:/…) in browsers will allow (like XMLHttpRequests, json calls, cross domain access and Access-Control-Allow-Origin restrictions).

A simple solution instead of deploying your code to apache or IIS is to install a local http server. http-server for Node.js is a fast, easy install and app that will allow you to use any directory as a http://localhost.

Installing this simple http server only takes a few steps:

  1. Install node.js if you don’t already have installed (from
  2. In a command prompt / terminal, now run:
    npm install http-server -g

    (this installs http-server globally so you can access from any folder or directory)

  3. Now using command prompt or terminal, browser to a folder with some html you want to serve as http. (ie: c:\someproject\).
  4. Run:
  5. Open your browser and visit http://localhost:8080.


You can change port 8080 (the default) to anything using “-p”, so http-server -p 8088 would change your local site to http://localhost:8088

Run http-server –help to see the other options available for running.

Local web server for testing / development using Node.js and http-server

Wirecast – Unable to start, find the Quicktime plug-in solution

If installing Wirecast (a great live streaming application by Telestream) and you run across this little error upon starting up for the first time:


Wirecast was unable to start
Unable to find the QuickTime plug-in. Please reinstall Wirecast.


I would not recommend reinstalling Wirecast but simply downloading and installing QuickTime:

  1. Visit and download
  2. Run Setup
  3. I would uncheck the boxes on this dialog:
  4. And at the end of the install I would also click “No Thanks”:



You should now be able to run Wirecast without the QuickTime error. This applied to Wirecast 5 (5.0.3) and Windows 7 x64.

As a side note, I’ve been experimenting with DaCast streaming provider, so far seems to work well.

Wirecast – Unable to start, find the Quicktime plug-in solution

Fixing / Removing Invalid Characters from a File Path / Name – c#

Below is a simple method for fixing bad filenames and paths. This uses the character lists from Path.GetInvalidPathChars and Path.GetInvalidFileNameChars (part of System.IO).

You should be able to pass a filename, directory or path. Example, calling these three lines would yield the below:




You can also pass a string that’s used to replace the bad characters.

cleanPath(@"c:\tem|<p\fi<>le.txt", string.Empty)


 private string cleanPath(string toCleanPath, string replaceWith = "-")  
           //get just the filename - can't use Path.GetFileName since the path might be bad!  
           string[] pathParts = toCleanPath.Split(new char[] { '\\' });  
           string newFileName = pathParts[pathParts.Length - 1];  
           //get just the path  
           string newPath = toCleanPath.Substring(0, toCleanPath.Length - newFileName.Length);   
           //clean bad path chars  
           foreach (char badChar in Path.GetInvalidPathChars())  
                newPath = newPath.Replace(badChar.ToString(), replaceWith);  
           //clean bad filename chars  
           foreach (char badChar in Path.GetInvalidFileNameChars())  
                newFileName = newFileName.Replace(badChar.ToString(), replaceWith);  
           //remove duplicate "replaceWith" characters. ie: change "test-----file.txt" to "test-file.txt"  
           if (string.IsNullOrWhiteSpace(replaceWith) == false)  
                newPath = newPath.Replace(replaceWith.ToString() + replaceWith.ToString(), replaceWith.ToString());  
                newFileName = newFileName.Replace(replaceWith.ToString() + replaceWith.ToString(), replaceWith.ToString());  
           //return new, clean path:  
           return newPath + newFileName;  

Hope it helps!

Fixing / Removing Invalid Characters from a File Path / Name – c#

Remove or Hide PowerPoint Controls on All Slides

ppt3If you customize PowerPoint with controls (button, text boxes, labels, etc.) you may want to delete or hide these to create a clean version of your presentation. Below is a script you can use hide all of the controls (or you can filter). My example uses PowerPoint 2010 but should apply to most recent versions:


1. Create a new module: ppt1

2. Paste the below text:

Public Sub HideControls()

'keep a count of how many items hidden - just fyi
Dim cntrlCount As Integer
    'loop through slides
    For Each sld In ActivePresentation.Slides
        'loop through slide shapes - includes button, text boxes, ole controls, etc
        For Each shp In sld.Shapes
        ''Filter here if you want - by name or type
        ' If InStr(shp.Name, "command") >= 1 Then
        ' If shp.Type = 3 Then
        'set hidden
        shp.Visible = False
        'if you wanted to delete*: shp.Delete
        cntrlCount = cntrlCount + 1

MsgBox cntrlCount & " items affected."

End Sub

3. Click Run (green play button) to run this code and hide your controls. ppt2


If you want to show or unhide your controls, change shp.Visible = False to shp.Visible = True


*Note: if you use shp.Delete, you won’t be able to recover your items.

Remove or Hide PowerPoint Controls on All Slides

Allow Local File Access in Chrome (Windows)

chrome-128Sometimes it’s cool to debug and test javascript applications in Chrome but you want to read / write to local files. Example: you’re looking to use ajax and do a $.getJSON(‘json/somefile.json’). Chrome by default won’t allow this and will throw an error similar to:

Failed to load resource: No 'Access-Control-Allow-Origin' 
header is present on the requested resource. 
Origin 'null' is therefore not allowed access.

XMLHttpRequest cannot load. No 'Access-Control-Allow-Origin' 
header is present on the requested resource. 
Origin 'null' is therefore not allowed access.

Chrome does have a switch to enable this, it’s quite easy to turn on. You’ll need to make sure Chrome is closed completely, and run chrome with the ‘–allow-file-access-from-files’ flag. Ie:

chrome --allow-file-access-from-files

Or you should be able to run:

%localappdata%\google\chrome\application\chrome --allow-file-access-from-files

I’ve made the below into a .bat file I use, if you find it helps.

start "chrome" %localappdata%\google\chrome\application\chrome --allow-file-access-from-files

To see if the flag is set, you can visit:  chrome://version/ and look at the Command Line section and you should see –allow-file-access-from-files

You’ll most likely need to run this with at least admin access, and I would caution visiting unknown sites with this setting on, as they could capitalize on your setting and potentially read local files.

Update, see my newer post on using node and http-server to create a local web server to get around these issues:
Local web server for testing / development using Node.js and http-server

Allow Local File Access in Chrome (Windows)

Enabling SMB / Samba Write on Xbian (XBMC for Raspberry Pi)

Raspi_Colour_RIf you’ve got a Raspberry Pi (if you don’t, please go order one right now), and use Xbian (a great version of XBMC for Pi) you may have connected to your Pi via SMB but noticed it’s read only. Fixing this (to read / write) only takes a few seconds.

Provided you already have Xbian installed and your Pi is connected to your network and you know the address (something like 192.168.x.x – or you should be able to simple use “Xbian”), you can:

  1. On a PC, download and run Putty. Putty is a great – free – ssh terminal app.
  2. Enter your Pi’s ip (or “Xbian”) in the host name textbox.
  3. Click Open to connect to the Pi.
  4. Enter the default username: xbian and password: raspberry
  5. At the prompt, enter: sudo nano /etc/usbmount/usbmount.conf
  6. In Nano (a text editor) find the line: SMBSHARE=no
  7. Change SMBSHARE=no to SMBSHARE=yes
  8. Exit Nano and save (Control+X, Y).
  9. Reboot.
  10. You should now be able to connect to you Pi in Windows using SMB with \\XBIAN\ or find your Pi in your Network and have write permission.

Happy downloading AND uploading.

Enabling SMB / Samba Write on Xbian (XBMC for Raspberry Pi)

PowerPoint VBA / Macro Controls On Slides – Return Focus To The Slide

I recently had the need to add some functionality to some PowerPoint presentations. While it was “fun” to use VBA (brought be back to the classic .asp days) I had forgotten a few issues. One main issue, if you have a button on a slide, when the button is clicked, the focus still remains on the button, not the slide. If you press next or use a presentation ‘clicker’ it won’t advance the slide because you’re still focused on the button. The easiest way I’ve found to return focus back to the slide is by hiding and showing the control. See below:

Private Sub cmdYourButton_Click()
'Do something cool here
cmdYourButton.Visible = False
cmdYourButton.Visible = True
'Focus is now back on the slide!
End Sub

One final note: if you’re looking for the “Developer” tab in PowerPoint, go to File > Options > Customize Ribbon and check “Developer” under ‘Main Tabs’.

Happy presenting!

PowerPoint VBA / Macro Controls On Slides – Return Focus To The Slide

Tweet button / link without javascript – HTML only

Twitter buttonIf you’ve ever wanted to include a ‘Tweet’ button or link but didn’t want to use the popular Tweet Button code from Twitter (it uses a remote javascript function), there is an alternate approved method called “Intents”. This function works great for instances when simple HTML is preferred (emails, pages geared toward older or simple browsers, etc.). However it doesn’t provide extras like showing how many have used the button or creating the image automatically. So how does it work?

Using Twitter’s Web Intents, you can create links like below:

<a href="
&text=Checkout this awesome blog.&via=chrisbitting&hashtags=twitter"
 title="Tweet" target="_blank">Tweet</a>

Which looks like: Tweet

No Javascript!

Be sure to check the documentation for more options and details:

Tweet button / link without javascript – HTML only

Adding attachments to an email using Exchange Web Services

In a previous article on sending email with Exchange Web Services (EWS) we showed how easy it was to integrate with Exchange and send email. If you’ve ever wanted to attach a file to an email that your sending, it’s super easy (much faster than the System.Net.Mail method):

//Create an email message and identify the Exchange service
EmailMessage message = new EmailMessage(service);

//Attach a file - THE MAGIC

//Send the email message and save a copy

That’s it! If you want to see all of the code needed for sending, see Retrieving and Sending Email using Exchange Web Services Managed API 2.0 (c#)

Adding attachments to an email using Exchange Web Services