<commit_before># -*- coding: utf-8 -*-

require 'pb'

module PBDB
  class Clipd
    class << self

      def run!
        @running = true

        Thread.start do
          begin
            while @running do
              clip!
              sleep 10
            end
            puts "has ended"
          rescue => e
            puts "#{e.message}\n#{e.backtrace.join("\n")}"
            exit!
          end
        end
      end

      def stop!
        @running = false
      end

      def clip!
        text = PB.read
        return if Clip.stored?(text, 60 * 60)
        Clip << text
        puts <<EOS
## clip -------
#{text}
## ------------
EOS
      end
    end
  end
end<commit_msg>set default values for clipd's config<commit_after># -*- coding: utf-8 -*-

require 'pb'

module PBDB
  class Clipd
    class << self
      attr_accessor :interval
      attr_accessor :ignore_duplication

      def run!
        @running = true
        interval ||= 2
        ignore_duplication ||= 60 * 60

        Thread.start do
          begin
            while @running do
              clip!
              sleep interval
            end
            puts "has ended"
          rescue => e
            puts "#{e.message}\n#{e.backtrace.join("\n")}"
            exit!
          end
        end
      end

      def stop!
        @running = false
      end

      def clip!
        text = PB.read
        return if Clip.stored?(text, ignore_duplication)
        Clip << text
        puts <<EOS
## clip -------
#{text}
------------
EOS
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.11503856041131105, 'fraction_numerical': 0.008354755784061696, 'mean_word_length': 1.1475862068965517, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 5, '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': '5065521', 'n_tokens_mistral': 470, 'n_tokens_neox': 457, 'n_words': 134}