Skip to content

Instantly share code, notes, and snippets.

View TfTHacker's full-sized avatar

TfTHacker

View GitHub Profile
@TfTHacker
TfTHacker / canvas.ts
Created December 6, 2022 04:29
Obsidian Canvas JSON format (TypeScript definition)
export type Side = 'top' | 'right' | 'bottom' | 'left';
export interface CanvasData {
nodes: (CanvasFileData | CanvasTextData | CanvasLinkData)[];
edges: CanvasEdgeData[];
}
export interface CanvasNodeData {
id: string;
x: number;
/* See Tweet thread for info on the use of this file: https://twitter.com/TfTHacker/status/1588781787865808897?s=20&t=iDq6L-u4SHnJ5UfN0r7yzQ */
/* I am not a CSS dude, so no promises this is well written CSS */
.nav-folder-title {
font-weight: 600 !important;
color:steelblue;
}
[data-path="Teaching"] > .nav-folder-title-content::before {
@TfTHacker
TfTHacker / open-file-from-ribbon-commandpalette.js
Last active September 26, 2022 10:58
Adds command to ribbon and command palette to open a given file
<%*
//
// updated: 2022-09-26
//
// Script adds a Command Palette command to open a file
//
// Install:
// 1. Add this text to a markdown file in your Templater "templates" folder
// 2. In templater settings, add the file you created in step 1 to the Startup section of Templater Settings
@TfTHacker
TfTHacker / vs-code-open-current-file.js
Created September 24, 2022 12:54
Create Ribbon and Command Palette commands to open Visual Studio Code
<%*
//
// Script adds a ribbon button and command in the Command palette to open the current document in VS CODE
//
// Install:
// 1. Add this text to a markdown file in your Templater "templates" folder
// 2. In templater settings, add the file you created in step 1 to the Startup section of Templater Settings
// 4. Restart Obisidan. Now the command should be available in the command palette
//
@TfTHacker
TfTHacker / launch-resources-via-command-palette.js
Created April 17, 2022 15:15
Launch web resources via command palette
<%*
/*
Templater script to add commands to the command palette to quickly launch web resources
Brought to you by TfT Hacker (https://twitter.com/TfTHacker)
Last update: 2022-04-17
Instructions:
To add a site:
Add a new line with the title of the site and the url to the web page.
@TfTHacker
TfTHacker / FastStart-GenerateListOfInstalledPlugins.js
Last active April 1, 2024 06:47
Creates a list of all plugins installed in an Obsidian vault
<% Object.values(app.plugins.manifests).map(p=>p.id).sort((a,b)=>a.localeCompare(b)).join('\n') %>
@TfTHacker
TfTHacker / FastStart-StartupScript.js
Last active April 1, 2024 06:39
FastStart Script for Obsidian - makes it easy to delay the startup of plugins
<%*
fastStart = async (filename, delayInSecond) => {
if (tp.file.exists(filename)) {
const f = tp.file.find_tfile(filename);
let plugins = (await app.vault.read(f)).split(/\r?\n/);
setTimeout(async () => {
plugins.forEach(async (p) => await app.plugins.enablePlugin(p))
}, delayInSecond * 1000)
}
}
@TfTHacker
TfTHacker / ScriptableReadwiseRandomHighlight.js
Last active October 14, 2023 21:52
Scriptable - Readwise random highlights
// Widget for iOS using the Scriptable app
// Uses Readwise API for pulling back random highlights.
// This duplicates the Readwise widget, so there is no additional value
// I did this as a learning exercize.
let accessToken = args.widgetParameter ? args.widgetParameter : "Your token here if you are testing, otherwise add it in the widget"
let headers = { "Authorization": "Token " + accessToken };
function getRandomInt(max) {
@TfTHacker
TfTHacker / WeekdayWeekendForTemplater
Created October 17, 2021 08:29
Weekday/Weekend for templater
<%*
window.fileDate = app.plugins.getPlugin('nldates-obsidian').parseDate(tp.file.title).moment;
window.fileDate = window.fileDate.isValid() ? window.fileDate : moment();
if ( [1,2,3,4,5].includes(fileDate.day()) ) { %>
Weekday
<%* } else if( [0,6].includes(fileDate.day())) { %>
Weekend
<%* } %>
@TfTHacker
TfTHacker / dayofweek
Created October 17, 2021 08:06
Day of Week with templater
<%*
window.fileDate = app.plugins.getPlugin('nldates-obsidian').parseDate(tp.file.title).moment;
window.fileDate = window.fileDate.isValid() ? window.fileDate : moment();
if(fileDate.day()==0) { %>
Sunday
<%* } else if(fileDate.day()==1) { %>- <%'['%> ]
Monday
<%* } else if(fileDate.day()==2) { %>- <%'['%> ]
Tuesday
<%* } else if(fileDate.day()==3) { %>- <%'['%> ]