Skip to content

Instantly share code, notes, and snippets.

Thomas Aarholt thomasaarholt

  • University of Oxford
  • Oxford, UK
Block or report user

Report or block thomasaarholt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@thomasaarholt
thomasaarholt / .profile
Created Feb 27, 2019
.profile used on Machine Learning Cluster
View .profile
GNU nano 2.5.3 File: /shared/users/thomasaar/.profile
PS1='$(pwd): '
echo 'Hello Thomas - edit PATH using "profile"'
echo "YOU ARE NOT IN HOME - YOU ARE ON SHARED"
# This is a comment
echo 'Enabling environment for pyprismatic'
export CPLUS_INCLUDE_PATH=/usr/local/cuda-10.0/include:$CPLUS_INCLUDE_PATH
export LD_LIBRARY_PATH=$HOME/fftw_gcc5_build/lib64:/usr/local/cuda-10.0/lib64:$HOME/prismatic_gcc5/lib:$LD_LIBRARY_PATH
export LIBRARY_PATH=$HOME/fftw_gcc5_build/lib64:/usr/local/cuda-10.0/lib64:$HOME/prismatic_gcc5/lib:$LIBRARY_PATH
@thomasaarholt
thomasaarholt / .inputrc
Created Feb 27, 2019
Absolutely necessary .inputrc hotkeys for navigating in bash
View .inputrc
"\e[A": history-search-backward
"\e[B": history-search-forward
"\e[C": forward-char
"\e[D": backward-char
@thomasaarholt
thomasaarholt / colorbar.py
Last active Mar 11, 2019
Add colorbar next to image
View colorbar.py
from mpl_toolkits.axes_grid1 import make_axes_locatable
def colorbar(mappable):
"mappable is img = plt.imshow()"
ax = mappable.axes
fig = ax.figure
divider = make_axes_locatable(ax)
cax = divider.append_axes("right", size="5%", pad=0.05)
cax.aname = 'colorbar'
return fig.colorbar(mappable, cax=cax)
@thomasaarholt
thomasaarholt / Remote_Notebook.md
Last active Mar 21, 2019
Remote Jupyter Notebook through ssh tunnel
View Remote_Notebook.md

Using Jupyter notebook remotely via a ssh tunnel.

Especially good for running on headless devices, such as supercomputers or clusters.

Remotely:

# remote_port should be value between 8888 and 9000
jupyter notebook --no-browser --port=remote_port

Locally, new terminal window

@thomasaarholt
thomasaarholt / savefig_no_whitespace.py
Last active Mar 20, 2019
Save matplotlib figures with no whitespace
View savefig_no_whitespace.py
import matplotlib.pyplot as plt
def save(filepath="image.png", fig=None):
'''Save the current image with no whitespace
Example filepath: "myfig.png" or r"C:\myfig.pdf"
Based on answers from https://stackoverflow.com/questions/11837979/
'''
import matplotlib.pyplot as plt
if not fig:
fig = plt.gcf()
@andrewjesaitis
andrewjesaitis / gist:7778867
Created Dec 3, 2013
Just an example of dividing a continuous matplotlib colormap into a distinct array of colors
View gist:7778867
import matplotlib as mpl
num_colors = len(values)
cm = mpl.cm.get_cmap(name='YlGnBu_r')
currentColors = [cm(1.*i/num_colors) for i in range(num_colors)]
@piscisaureus
piscisaureus / pr.md
Created Aug 13, 2012
Checkout github pull requests locally
View pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

You can’t perform that action at this time.