Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fx-kirin/1d2f2cc5a0ed3038d03fb881c6bb92c0 to your computer and use it in GitHub Desktop.
Save fx-kirin/1d2f2cc5a0ed3038d03fb881c6bb92c0 to your computer and use it in GitHub Desktop.
javascript:date = new Date(); url_root = 'http://nbviewer.ipython.org/'; url = null; gist_re = /^https?:\/\/gist\.github\.com\/(?:\w+\/)?([a-f0-9]+)$/; github_re = /^https:\/\/(github\.com\/.*\/)blob\/(.*\.ipynb)$/; https_re = /^https:\/\/(.*\.ipynb)$/; http_re = /^http:\/\/(.*\.ipynb)$/; loc = location.href; if (gist_re.test(loc)) { gist = gist_re.exec(loc); url = url_root + gist[1]; } else if (github_re.test(loc)) { path = github_re.exec(loc); url = url_root + 'urls/raw.' + path[1] + path[2]; } else if (https_re.test(loc)) { path = https_re.exec(loc); url = url_root + 'urls/' + path[1]; } else if (http_re.test(loc)) { path = http_re.exec(loc); url = url_root + 'url/' + path[1];} if (url) {void(window.open(url, 'nbviewer' + date.getTime()));}
@fx-kirin
Copy link
Author

fx-kirin commented Oct 23, 2019

Add it to your browser's bookmark as bookmarklet. It will open ipynb file in nbviewer on clicking the bookmark from Github.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment