Skip to content

Instantly share code, notes, and snippets.


Tom McTavish tommct

View GitHub Profile
tommct /
Last active Jan 10, 2018
Matplotlib normalized histograms

This creates a normalized mass density histogram in matplotlib

bins = np.linspace(-1, 1, 101)
# To get a normalized mass density histogram, we have to do it this way...
hist, bins = np.histogram(df['some_column'], bins=bins, density=True)
hist /= len(bins)
width = bins[1]-bins[0]
fig = plt.figure(figsize=(8, 4))
ax = fig.add_axes([.15, .15, .75, .75])[:-1], height=hist, width=width)
tommct /
Last active Jun 11, 2018
D3 Constrained Zoom Canvas Image

Implements constrained zooming of an image put onto an HTML5 Canvas.

tommct /
Created Aug 28, 2018
MongoDB from Tableau

To get use MongoDB from Tableau, start a mongosqld instance...

mongosqld --mongo-uri "mongodb://<host>:<port>/?connect=direct"

Then from Tableau, select Servers->MongoDB BI Connector with and 3307 as connection details.

tommct /
Last active Aug 29, 2018
Two axes focus+context via brushing
View jupyterthemes.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
tommct /
Last active Sep 27, 2020
Instructions for downloading Jupyter Notebooks from Coursera

From an open Jupyter Notebook homework assignment, select "Coursera" to take you to the home page. Make a new notebook and fill it with the following and excute the cell with:

tar cvfz hw.tar.gz .

This may take a little while to run depending on the packages. Select "Coursera" again to take you to the Home directory. Check the hw.tar.gz file and then Download. After the file is downloaded, delete it.

tommct /
Last active Nov 4, 2020
FreeTDS and pyodbc on Mac OS X 10.8 via Homebrew

After spending many hours trying to get FreeTDS and unixodbc to run on a Mac OS X 10.8 system with the python module, pyodbc, I eventually came to this recipe, which is remarkably simple thanks to homebrew. I also found unixodbc was unnecessary and I couldn't get it to play well with FreeTDS, so this install does not include unixodbc. See also and

Prerequisites: Be sure you have XCode and the Commandline Tools for XCode installed from Apple. Also install homebrew followed with brew update and brew doctor.

Install FreeTDS:

brew install freetds

Test your install:

You can’t perform that action at this time.