diff options
| author | Paul Buetow <paul@buetow.org> | 2025-10-02 11:31:39 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-10-02 11:31:39 +0300 |
| commit | 100c1e6fd4661293333b689b75b364fc07dc2bf4 (patch) | |
| tree | 701de616919066d71c664409f50589f8d2e1c936 /gemfeed/examples/conf/dotfiles/scripts/randomnote.rb | |
| parent | 2b034797107660d4d83f8a7acdc55d32db785b82 (diff) | |
Update content for md
Diffstat (limited to 'gemfeed/examples/conf/dotfiles/scripts/randomnote.rb')
| -rw-r--r-- | gemfeed/examples/conf/dotfiles/scripts/randomnote.rb | 30 |
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 |
