Skip to content

Instantly share code, notes, and snippets.

Avatar

TfTHacker

View GitHub Profile
@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 8, 2021
Obsidian: Archive current file and then open next file in folder (Templater script)
View ArchiveAndProcessNextFile.js
<%*
/*
Updated: 8/6/2021
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;
}
@TfTHacker
TfTHacker / Hypothesidian.js
Last active Dec 1, 2021
Hypothes.is - retrieve your annotations into Obsidian (for templater plugin)
View Hypothesidian.js
<%*
/*
# Hypothes.idian a templater script for retrieving annotations from Hypothes.is
Dev: RoamHacker https://twitter.com/roamhacker
# 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.
View Show day of week under page titles (ex: Daily Notes & Sidebar)
// 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;
View iPad - Emulate ESCAPE key
// 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
// You can change the custom keys where it says Mousetrap.bind('ctrl+e)
// See for more keyboard options: https://craig.is/killing/mice
// I am on European SmartKeyboard & assigned §, which is where ESC is on most keyboards
setTimeout(()=>{
Mousetrap.bind('ctrl+e', function(event, handler) {
event.preventDefault()
@TfTHacker
TfTHacker / Customize Help menu shortcut
Created Sep 16, 2020
Help menu custom key assignment
View Customize Help menu shortcut
setTimeout(()=>{
hotkeys('ctrl+shift+6', function(event, handler) {
event.preventDefault()
displayHelp(20000)
});
},15000)
View Insert custom text with a keyboard shortcut
// Roam42 is a prerequisite for this code, as it uses Roam42 libraries
// Install & Config:
// Add the code in this gist to a roam/js block in your roam graph and enable it
// change the text between quotes "" where it says let txt = "....."
// You can change the custom keys where it says hotkeys('ctrl+shift+7)
// this uses the hotkeys library, so explore more key combinations at: https://wangchujiang.com/hotkeys/
// after changing the text below, you may have to refresh Roam for it to take effect.
setTimeout(()=>{
Mousetrap.unbind('ctrl+shift+7')