Skip to content

Instantly share code, notes, and snippets.

@sigaloid
sigaloid / wordcount.js
Last active May 25, 2022 08:23
Trilium frontend JS that displays word count, char count, sentence count, reading and speaking time, unique word count, and hand-writing time (more soon?)
/*
* This defines a custom widget which displays number of words and characters in a current text note.
* To be activated for a given note, add label 'wordCount' to the note, you can also make it inheritable and thus activate it for the whole subtree.
*
* See it in action in "Books" and its subtree.
*/
const TPL = `<div style="contain: none; padding: 10px; border-top: 1px solid var(--main-border-color);">
<i>Word count: </i>
<strong><span class="word-count"></span></strong>
@sigaloid
sigaloid / wordcount.js
Last active January 14, 2022 01:53
Trilium frontend JS that displays word count, char count, sentence count, reading and speaking time, unique word count, hand-writing time, and now dale-chall readability formula
/*
* This defines a custom widget which displays number of words and characters in a current text note.
* To be activated for a given note, add label 'wordCount' to the note, you can also make it inheritable and thus activate it for the whole subtree.
*
* See it in action in "Books" and its subtree.
*/
const TPL = `<div style="padding: 10px; border-top: 1px solid var(--main-border-color); contain: none;">
<i>Word count: </i>
<strong><span class="word-count"></span></strong>
@sigaloid
sigaloid / css.css
Last active January 10, 2022 16:13
Custom share js + css
/* Parts taken from SPCSS
License: Copyright (c) 2020-2021 Susam Pal
https://github.com/susam/spcss/blob/master/LICENSE.md
*/
#menu {
border-right: 8px dashed;
border-radius: 10px;
border-image: linear-gradient(45deg, red, blue) 1;
width: 10px;
margin-right: 25px;
@sigaloid
sigaloid / main.rs
Created January 20, 2024 01:30
Example async
use futures_util::StreamExt;
use tokio_tungstenite::{connect_async, tungstenite::client::IntoClientRequest};
use url::Url;
#[tokio::main]
async fn main() {
// Include file servers.txt from current directory
let urls = include_str!("servers.txt")
.split("\n")
.filter(|s| !s.is_empty())