<commit_before>require 'irb/completion'
require 'pp'
require 'dalli'

IRB.conf[:EVAL_HISTORY] = 1000
IRB.conf[:SAVE_HISTORY] = 1000
IRB.conf[:AUTO_INDENT] = true

def mem(host,user,pass)
  return Dalli::Client.new(host, :username => user, :password => <PASSWORD>)
end

def pp_stats(stats)
  stats.sort.map do |k,v|
    puts "## #{k}"
    v.sort.map do |k2, v2|
      puts "#{k2} => #{v2}"
    end
  end

  return nil
end

def pp_items(stats)
  stats.sort.map do |k,v|
    # extract slab numbers
    slabs = []
    v.map do |k2,v2|
      slabs << k2[/\d+/].to_i
    end
    slabs = slabs.uniq.sort

    puts "## #{k}"
    puts "Slab, Chuck Size, Number, Evicted, Evicted-NZ, OOM"
    slabs.each do |i|
      s  = v["items:#{i}:chunk_size"]
      n  = v["items:#{i}:number"]
      e  = v["items:#{i}:evicted"]
      ez = v["items:#{i}:evicted_nonzero"]
      o  = v["items:#{i}:outofmemory"]
      puts "#{i}, #{s}, #{n}, #{e}, #{ez}, #{o}"
    end
  end
end

def pp_key(stats, key)
  stats.sort.map do |k,v|
    puts "#{k} => #{v[key]}"
  end
end
<commit_msg>Better irb settings.<commit_after>require 'irb/completion'
require 'irb/ext/save-history'

ARGV.concat [ "--readline",
              "--prompt-mode",
              "simple" ]

IRB.conf[:EVAL_HISTORY] = 1000
IRB.conf[:SAVE_HISTORY] = 1000
IRB.conf[:AUTO_INDENT] = true
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-history"

begin
  require 'pp'
  require 'dalli'

  def mem(host,user,pass)
    return Dalli::Client.new(host, :username => user, :password => <PASSWORD>)
  end

  def pp_stats(stats)
    stats.sort.map do |k,v|
      puts "## #{k}"
      v.sort.map do |k2, v2|
        puts "#{k2} => #{v2}"
      end
    end

    return nil
  end

  def pp_items(stats)
    stats.sort.map do |k,v|
      # extract slab numbers
      slabs = []
      v.map do |k2,v2|
        slabs << k2[/\d+/].to_i
      end
      slabs = slabs.uniq.sort

      puts "## #{k}"
      puts "Slab, Chuck Size, Number, Evicted, Evicted-NZ, OOM"
      slabs.each do |i|
        s  = v["items:#{i}:chunk_size"]
        n  = v["items:#{i}:number"]
        e  = v["items:#{i}:evicted"]
        ez = v["items:#{i}:evicted_nonzero"]
        o  = v["items:#{i}:outofmemory"]
        puts "#{i}, #{s}, #{n}, #{e}, #{ez}, #{o}"
      end
    end
  end

  def pp_key(stats, key)
    stats.sort.map do |k,v|
      puts "#{k} => #{v[key]}"
    end
  end
rescue
  print "Dalli not installed... no memcache shortcuts"
end
{'fraction_non_alphanumeric': 0.19222903885480572, 'fraction_numerical': 0.012269938650306749, 'mean_word_length': 2.5552325581395348, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '3235369', 'n_tokens_mistral': 1030, 'n_tokens_neox': 1003, 'n_words': 222}