Skip to content

Instantly share code, notes, and snippets.

@rxian
rxian / obsidian-center-image.js
Last active May 27, 2022 15:52
Obsidian JS snippet for centering images
// Use with JavaScript Init plugin (https://github.com/ryanpcmcquen/obsidian-javascript-init)
var observer = new MutationObserver(function(mutationsList, observer) {
mutationsList.forEach(function(mutation) {
mutation.addedNodes.forEach(function(addedNode) {
addedNode.querySelectorAll('.image-embed').forEach(function(e) {
e.parentNode.style["text-align"] = "center";
});
});
});
});
@rxian
rxian / ubuntu_1604_ml_gpu_setup.sh
Last active July 4, 2019 05:09
Setup PyTorch with GPU support on Ubuntu 16.04
# Last checked on July 3, 2019
# References:
# http://ubuntuhandbook.org/index.php/2017/07/install-python-3-6-1-in-ubuntu-16-04-lts/
# https://yangcha.github.io/CUDA90/
# https://pytorch.org/get-started/locally/
# Install Python3.6
sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt-get update
sudo apt-get install python3.6
@rxian
rxian / ssh_jupyter_notebook.py
Last active July 4, 2019 03:07
A script for starting Jupyter Notebook on SSH server and opening it in a browser (with port forwarding), quit with Control-C.
#!/usr/local/bin/python3
## Written in Python 3.6.4 with Jupyter Notebook 5.7.4 and Pexpect 4.6.0, tested on macOS Mojave
## Please edit the following six lines (maybe also the shebang above)
## Host and login info (use string for password if not authenticated with public key)
hostname = "1.1.1.1"
username = "user"
password = None # "old_fashioned_pwd"
ssh_key = None # "/home/user/public-key.pem"