summaryrefslogtreecommitdiff
path: root/gemfeed/examples/conf/dotfiles/scripts/randomnote.rb
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-10-02 11:31:39 +0300
committerPaul Buetow <paul@buetow.org>2025-10-02 11:31:39 +0300
commit100c1e6fd4661293333b689b75b364fc07dc2bf4 (patch)
tree701de616919066d71c664409f50589f8d2e1c936 /gemfeed/examples/conf/dotfiles/scripts/randomnote.rb
parent2b034797107660d4d83f8a7acdc55d32db785b82 (diff)
Update content for md
Diffstat (limited to 'gemfeed/examples/conf/dotfiles/scripts/randomnote.rb')
-rw-r--r--gemfeed/examples/conf/dotfiles/scripts/randomnote.rb30
1 files changed, 0 insertions, 30 deletions
diff --git a/gemfeed/examples/conf/dotfiles/scripts/randomnote.rb b/gemfeed/examples/conf/dotfiles/scripts/randomnote.rb
deleted file mode 100644
index b0c1b490..00000000
--- a/gemfeed/examples/conf/dotfiles/scripts/randomnote.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/env ruby
-
-NOTES_DIR = "#{ENV['HOME']}/git/foo.zone-content/gemtext/notes"
-BOOK_PATH = "#{ENV['HOME']}/Buecher/Diverse/Search-Inside-Yourself.txt"
-MIN_PERCENTAGE = 80
-MIN_LENGTH = 10
-
-class String
- CLEAN_PATTERN = [
- /\d\d\d-\d\d-\d\d/, /[^A-Za-z0-9!.;,?'" @]/,
- /http.?:\/\/\S+/, /\S+\.gmi/, /^\./, /^\d/,
- ]
- def clean
- CLEAN_PATTERN.each {|p| gsub! p, '' }
- gsub(/\s+/, ' ').strip
- end
- def letter_percentage?(threshold) = threshold <= (100 * count("A-Za-z")) / length
-end
-
-begin
- srand Random.new_seed
- puts File.read((Dir["#{NOTES_DIR}/*.gmi"] + [BOOK_PATH]).shuffle.sample)
- .split("\n")
- .map(&:clean)
- .select{ |l| l.length >= MIN_LENGTH }
- .reject{ |l| l.match?(/(Published at|EMail your comments)/) }
- .reject{ |l| l.match?(/'|book notes/) }
- .select{ |l| l.letter_percentage?(MIN_PERCENTAGE) }
- .shuffle.sample
-end