<commit_before>#!/lounge/bin/janosh -f

function write_history(key, operation, value)
   if key:find("source$") and operation == 'W' then
      fp = io.open('/lounge/history.log', 'a')
      fp:write(os.time(), '|', value, '\n')
      fp:close()
   end
end

Janosh:subscribe("/playlist/items", write_history)
while true do
  Janosh:sleep(1000000) -- milliseconds
end

<commit_msg>enable history logging to ipfs<commit_after>#!/lounge/bin/janosh -f

function add(key, operation, value)
  sum = Janosh:capture("echo \"" .. value .. "\" | md5sum");  
  name = tostring(Janosh:epoch()) .. "-" .. sum;
  Janosh:system("echo \"" .. value .. "\" > /ipns/local/" .. name)
  print("Added " .. value)
end

Janosh:subscribe("historyAdd", add)
while true do
  Janosh:sleep(1000000) -- milliseconds
end


{'fraction_non_alphanumeric': 0.18836915297092288, 'fraction_numerical': 0.018963337547408345, 'mean_word_length': 3.578034682080925, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4302691', 'n_tokens_mistral': 291, 'n_tokens_neox': 276, 'n_words': 61}