Code that runs where you think.
Your notes stop being a place where code is pasted and become a place where it runs. Run and Copy on every block, the output right beneath it, many languages, and the colours of whatever Obsidian theme you already use.
Are these two embeddings close?
Cosine similarity, before I trust the search results.
from math import sqrt
def cosine(a, b):
dot = sum(x * y for x, y in zip(a, b))
na = sqrt(sum(x * x for x in a))
nb = sqrt(sum(y * y for y in b))
return dot / (na * nb)
q = [0.2, 0.7, 0.1]
d = [0.25, 0.6, 0.2]
print(round(cosine(q, d), 2)) An illustration drawn on this page; the output is worked out in advance.
Three reasons
-
The answer stays with the question.
Because the output lands right beneath the block that produced it, so the note holds the question, the code and the result together, instead of a terminal window you close and forget.
-
It looks like it belongs.
Because Coder draws with your theme’s colours instead of bringing its own, so a dark vault stays dark and a custom theme stays yours.
-
Copy without selecting.
Because every block gets a Copy button, so taking code out of a note is one click, not a careful drag across lines.
01How it works
Nothing new to learn.
You write code the way you always have. Coder only adds what was missing.
-
01
Write the block as usual
Three backticks and the language, like any note.
-
02
Press Run
The block runs, and its output appears right underneath.
-
03
Change it, run it again
Edit a number and run again. The note becomes a place to try things, not only to keep them.
02Themes
One block, three themes.
The same code as it appears in three different vaults. The plugin has no colours of its own: every colour you see comes from the theme.
-
const words = "the hard part".split(" "); console.log(words.length);Output3Light
-
const words = "the hard part".split(" "); console.log(words.length);Output3Dark
-
const words = "the hard part".split(" "); console.log(words.length);Output3Your theme
03Install
Three steps, then your first note.
- Download the latest release. From the plugin’s page on GitHub: main.js, manifest.json and styles.css.
- Put it in your vault. In a new folder inside your vault’s .obsidian/plugins.
- Turn it on. In Obsidian: Settings › Community plugins, then enable Obsidian Coder.
- Type
- Obsidian plugin
- Licence
- Open source
- Price
- Free
- Status
- Available
Obsidian is a trademark of Dynalist Inc. Obsidian Coder is an independent plugin, not made or endorsed by them.
Your next note might run.
The source is open on GitHub. Download it, read it, or make it better.