top of page
Search

Code Monkey

  • Writer: The Archivist
    The Archivist
  • Nov 12
  • 7 min read

I've been doing a thing!


This is actually a slightly older version of my template, but it's a good example of what I'm working with.
This is actually a slightly older version of my template, but it's a good example of what I'm working with.

Before we get into the thick of it, I have very little history with any kind of coding language. I learned some HTML back when Quizilla still existed, I know Markdown well enough to get by, and I studied a smidge of Python before rage quitting when I was quizzed on concepts that were never discussed in the lessons. JavaScript, therefore, was a daunting undertaking for me.


Where should I even begin? People regurgitating information via tutorial videos hasn't been the most fruitful endeavor for me in the past, and there's more than enough junk out there to sift through to make a devil cry. Tutorial or education-type videos have their place, but I want to know enough about the subject in question first and then use them to further my understanding.


Funnily enough, this is where AI has been tremendously helpful. On a whim, I loaded Google Gemini up on my browser. I wanted to see how well it could teach a skill from the ground up.


Overall, it does a decent job, but the caveat is that the user needs to repeatedly have it test their knowledge, and you also have to be aware enough of what you don't know to ask it the appropriate questions. It won't solidify your understanding for you; it requires some reasoning on the user's end and confirming that reasoning. Me typing out what I've learned today is also my way of solidifying my own understanding. If it has the added bonus of helping someone else, then cheers.


For example, I learned that if you have multiple words for a variable, it's best to smoosh them together into a single word with the first word being lower case and capitalizing the first letter of subsequent words, "projectName" instead of "ProjectName." Gemini didn't explain to me why this was automatically. I had to ask why the syntax is formatted this way to learn that different programs will use specific case syntax. A programmer who sees "ProjectName" would recognize it as PascalCase, which signals to that programmer that the following code represents something else entirely than what camelCase ("projectName") would. On a technical level, using either works for the sake of creating a variable in JavaScript; it's mostly the human side that can mistake the intention.


If my understanding is correct, and if it isn't I'm sure I'll have friends who are much smarter than me tell me so, a variable is, on its most fundamental level, like a box that you name and reference throughout the code. I might have a box called "projectName" for one variable and another box called "status" for another variable. The code will interact with whichever box is referenced. I might change what's in the box, but the box name remains the same. For example, I might change the value inside the "status" box from "Incomplete" to "Finished" or "Sent", thus swapping out the box's contents, but the name remains static.


Let's go ahead and break down a real example.


ree

First, you might notice that the first block of code is nestled within the following:

<%*...%>

and the second and third are nestled within

<% ... %>

without the asterisk.


For the first one, this syntax signals that we are working with JavaScript. Specifically, we are working with an Obsidian plugin called, "Templater," which utilizes JavaScript to perform powerful tasks. Throughout, you'll see "tp" referenced, which calls directly to the Templater Plugin.


The first block with the asterisk happens purely in the background whenever it is triggered. There's no output for the viewer to see. It is script commanding the program to prompt the user to fill in an answer whenever a new file is created using that template. Then, the script moves that file into the appropriate series of folders and subfolders, changing the file's name to whatever the user inputted.


The 2nd block is information that will be displayed within the note for the user to see, and I actually just realized that the third block of code is redundant to the "await" command in the first, so it doesn't actually do anything. Lemme just fix that real fast so we don't get confused moving forward.


ree

There, where was I?


Ah, yes, whenever I create a new file using this specific template, the code will run and then delete or overwrite itself. It's a one and done deal, which isn't quite what I'm looking for in regards to my purposes, but we'll get to that later.


Once it runs, that large, cyan text gets replaced with the character's name, and the rest vanishes.


The first word, "const" in reference to "constant," means that whatever value gets put into the "charName" variable box cannot be changed throughout the duration of the script's run. If "charName" is "Cael," I can't later declare "charName" to be "Kosris" within the same block of code.


In this example, "charName" is my variable. The equal sign then denotes that we're about to do something with that variable. In this case, the "await" command causes the script to pause until the next piece

tp.system.prompt("Character Name:")

is resolved. This piece of syntax has the program prompt the user with the text in double quotes.


ree

If I had used

tp.system.prompt("What is your character's name?")

instead, then, What is your character's name? would have been the displayed text.


Once I put in the character's name, the next "await" tells the script to pause again, not because of any user input, but because the system itself is working behind the scenes to move and rename the file, and we wouldn't want the code continuing onto the next line, if there was any, before this operation has completed, because that could lead to errors in more complex blocks.


tp.file.move()

is a bit of script that does the obvious, move the file to whatever folder you want, but if you didn't want to move the file to another folder, you would still have to use it because its secondary function serves to rename the file itself as well. Instead of the file path listed within the above example, I could literally just have this line be


tp.file.move(`${charName}`)

and the file would stay right where I created it instead of moving it to any other folder.


It gets more complicated if you want to choose which folder or subfolder the file gets sorted into, requiring you to use

await tp.system.suggester()

with brackets encasing the folder names. I'm not entirely sure what the underlying reason is for some of the syntax, so for now I'll leave it at that. I understand how to do it; just not enough to explain why it's formatted the way it is.


Seeing as how I'm using Obsidian Bases to fill out tables with information, a JavaScript template that I can plop into a file to read the Base and then produce a nicely formatted list sorted under different headings will save me a ton of time.


But it could be better....


Which is where Dataview comes in.


JavaScript is static. Once the code runs, it's done. So, if I need to change any information, I need to do so manually. It's great for creating new files, but for pre-existing files or pieces of information that may need to change down the line? Not so much.


Dataview, another Obisidian plugin, is active. If I edit some information within Obsidian's Base tables, then that information will automatically change in the Dataview table that's displayed in the note.


Now, I think I can guess a question you may have or may have already had: "But if you're already editing one table, why would you need other tables, and why would they need to be edited as well?"


1) Dataview tables referencing the same item may be spread across multiple notes. This keeps me from having to edit them all across those individual notes.


2) Have you ever read a plain text table with nothing but the borders and text inside the columns and rows? After a few minutes, your eyes might cross. With Dataview, I can have these tables organized under easy-to-read headings that will allow me to quickly suss out the information I want without having to scan a giant list of terms that have absolutely nothing to do with what I want or need.


3+) I'm sure there are other reasons pertaining to how Dataview and Obsidian Bases operate, but meh.


I suspect that the real magic will happen once I integrate JavaScript into the knowledge I'm gaining about Dataview, of which I'm still in the early stages.


I keep coming back to a quote within one of the weekly newsletters I receive from Mark Manson concerning AI:


"AI should be used intentionally, not passively, to help you ask better questions, think more critically, and provide more clarity. If you don’t make it a priority to actively/consciously learn through AI, it’ll end up only learning from you. And the way to do this is to add the friction back into the experience yourself. Don’t just ask AI for an answer. Ask it to give you the two most prominent and competing perspectives on a question. Don’t just ask the AI what it thinks about your idea, ask it to criticize your idea and make it better. Don’t just ask AI to find you information, ask it what information you might be missing. In a world with no friction, the people who actively choose to struggle will be the ones who actually grow."

Other Notable Accomplishments:

  • Transcribed Session 106.6, .10, .11, .12, .13, .14, and .15

    • I don't know how many hours that is off the top of my head, but it was a lot.

    • And that's excluding the actual 2nd half of the performance, which was parts .7-.9

  • My Built With Science routine changed a bit.

    • I'm doing pull-ups on both upper body days now. One is at my current band, the green one

    • The other day I use the heavier resistance band, blue, to make pull-ups easier while pushing for higher reps.

    • This is because I've plateaued on my pull-up progression, and the Jeremy AI within the app actually suggested it. Speaking of another great AI, that one has been a blast to use.

    • I've swapped out Dead Bugs for Hanging Leg Raises, which are more challenging.

    • I've swapped out reverse crunches for my ab roller.

    • I've swapped out one of my tricep overhead extension exercises for bicep curls.

  • I've compiled Cael's journals into the Session Notes files I have just to clean up some of the clutter in Obsidian. I plan to do the same with their correspondence.


Real Talk:

  • Have you tried using AI to learn something new or solidify your understanding of a subject in which you already have some knowledge?

  • If you've used AI in the past, how have you created friction to help yourself grow? Or, if you haven't created friction, how might you do so in the future?


This Week's Obligatory Cat Pic: Salad

The princess caught herself a fly.
The princess caught herself a fly.

 
 
 

Comments


Every upload is a little surprise, sometimes even to me! Let's see what's to come, shall we?

Thanks for subscribing!

bottom of page