Start your notebook on the remote host:
remote_user@remote_host$ ipython notebook --no-browser --port=8889
Remote connect from your local machine:
local_user@local_host$ ssh -N -f -L localhost:8888:localhost:8889 remote_user@remote_host
| # Display matplotlib RGB images | |
| # https://www.pyimagesearch.com/2014/11/03/display-matplotlib-rgb-image/ | |
| # matplotlib: pyplot and mpimg to load and display our images | |
| # plt.axis("off"): to remove the axes of the figure | |
| # OpenCV: images are stored in BGR order rather than RGB! | |
| # Matplotlib | |
| import matplotlib.pyplot as plt | |
| import matplotlib.image as mpimg |
| #!/usr/bin/env python | |
| # read from input | |
| a = int(raw_input()) # first | |
| b = int(raw_input()) # second | |
| print a + b |
| #!/usr/bin/env python | |
| def say_hello(): | |
| print("Hello, World!") | |
| say_hello() |
| #!/usr/bin/env python | |
| print "Hello, World!" |
| import json | |
| from pprint import pprint | |
| with open('data.json') as f: | |
| data = json.load(f) | |
| pprint(data) |
| import json | |
| data = [ | |
| { | |
| 'greeting': 'Hi!' | |
| 'name': 'David' | |
| }, | |
| { | |
| 'greeting': 'Hello' | |
| 'name': 'Peter' |
| # Assume an existing non-empty list a, and a position i. | |
| # Find p, the position of the smallest element in a[i:N]. | |
| # The only difference is that: | |
| # instead of starting at position 0, we start at position i | |
| p = i | |
| j = i + 1 | |
| while j < len(a): | |
| if a[j] < a[p]: |
| # Assume an existing non-empty list a. | |
| # Find p, the position of the smallest element in a. | |
| # The smallest element could be at any position. | |
| # Therefore, we will have to examine every position. | |
| # Therefore, we use our do-something-n-times pattern. | |
| p = 0 | |
| j = 1 | |
| while j < len(a): |
| #!/usr/bin/env python | |
| # Assume an existing list of strings a. | |
| # Write a Python fragment which writes each string in a to standard output, one per line. | |
| # Explanation | |
| # When you run this locally, the output will be "dog", "cat" and "mouse", one per line. | |
| # However, when you run this code from another pgoram, the output will depend upon the value of a provided by that program. | |
| if __name__ == "__main__": |