Skip to content

Instantly share code, notes, and snippets.

Avatar

TfTHacker

View GitHub Profile
@TfTHacker
TfTHacker / open-file-from-ribbon-commandpalette.js
Last active Sep 26, 2022
Adds command to ribbon and command palette to open a given file
View open-file-from-ribbon-commandpalette.js
<%*
//
// 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 Sep 24, 2022
Create Ribbon and Command Palette commands to open Visual Studio Code
View vs-code-open-current-file.js
<%*
//
// 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 Apr 17, 2022
Launch web resources via command palette
View launch-resources-via-command-palette.js
<%*
/*
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 Feb 20, 2022
Creates a list of all plugins installed in an Obsidian vault
View FastStart-GenerateListOfInstalledPlugins.js
<% Object.values(app.plugins.manifests).map(p=>p.id).sort((a,b)=>a.localeCompare(b)).join('\n') %>
@TfTHacker
TfTHacker / FastStart-StartupScript.js
Last active Sep 12, 2022
FastStart Script for Obsidian - makes it easy to delay the startup of plugins
View FastStart-StartupScript.js
<%*
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 Nov 28, 2021
Scriptable - Readwise random highlights
View ScriptableReadwiseRandomHighlight.js
// 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 Oct 17, 2021
Weekday/Weekend for templater
View WeekdayWeekendForTemplater
<%*
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 Oct 17, 2021
Day of Week with templater
View dayofweek
<%*
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) { %>- <%'['%> ]
@TfTHacker
TfTHacker / ArchiveAndProcessNextFile.js
Last active Sep 20, 2022
Obsidian: Archive current file and then open next file in folder (Templater script)
View ArchiveAndProcessNextFile.js
<%*
/*
Updated: 9/20/2022
Author: TfTHacker
Gist: https://gist.github.com/TfTHacker
Twitter: https://twitter.com/TfTHacker
Requirements: Templater Plugin for Obsidian
Description: This script performs the following actions:
1. Moves current file to the archive folder (defined in the variable archivePath)
if archivePath is null, a folders in the vault will be presented for selection
View Tasks by Date - for Obsidian and Dataview.js
```dataviewjs
// find dates based on format [[YYYY-MM-DD]]
const findDated = (task)=>{
if( !task.completed ) {
task.link = " " + "[[" + task.path + "|*]]";
task.date="";
const found = task.text.match(/\[\[([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))\]\]/);
if(found) task.date = moment(found[1]);
return true;
}