Skip to content

Instantly share code, notes, and snippets.

View TfTHacker's full-sized avatar

TfTHacker

View GitHub Profile
@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 / Hypothesidian.js
Last active January 16, 2024 20:52
Hypothes.is - retrieve your annotations into Obsidian (for templater plugin)
<%*
/*
# Hypothes.idian a templater script for retrieving annotations from Hypothes.is
Dev: TfTHacker https://twitter.com/TfTHacker
# Prerequisites:
+ Templater plugin by https://github.com/SilentVoid13/Templater
+ Free Hypothes.is developer token from: https://hypothes.is/account/developer
+ This script will prompt you for his token and save it to a file called "hypothesis config.md"
+ This file store your configuration and can be located any where in your vault.
```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;
}
@TfTHacker
TfTHacker / ArchiveAndProcessNextFile.js
Last active December 4, 2023 19:17
Obsidian: Archive current file and then open next file in folder (Templater script)
<%*
/*
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
@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 / 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;
// Roam42 is a prerequisite for this code, as it uses Roam42 libraries
// Install & Config:
// Add the code from this gist to a roam/js block in your roam graph and enable it
// If you prefer foreign day names, modify the english in the Javascript below
// CSS can be customized using #roam-title-day-banner CSS selector. Example:
// .roam-title-day-banner {
// color:silver;
// }
// to exclude sidebars, change 'var includeSidebars = true;' in the code o
// var includeSidebars = false;
/* 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