<commit_before>require 'rubygems'
require 'bundler'

Bundler.require

def param_with_default(key, default)
  params[key] ? params[key] : default
end

def fixnum_param_with_default(key, default)
  param_with_default(key, default).to_i
end


get '/' do
  redirect to('https://github.com/afeld/sparkle')
end

get '/api/v1.png' do
  values = params[:values].split(',').map(&:to_f)

  # http://bit.ly/1qnR55Y
  blob = Sparklines.plot(values,
    dot_size: fixnum_param_with_default(:dot_size, 4),
    height: fixnum_param_with_default(:height, 30),
    line_color: param_with_default(:line_color, '#4A8FED'),
    step: fixnum_param_with_default(:step, 30)
  )

  content_type :png
  blob
end
<commit_msg>exclude the hash from the color hex str<commit_after>require 'rubygems'
require 'bundler'

Bundler.require

def param_with_default(key, default)
  params[key] ? params[key] : default
end

def fixnum_param_with_default(key, default)
  param_with_default(key, default).to_i
end


get '/' do
  redirect to('https://github.com/afeld/sparkle')
end

get '/api/v1.png' do
  values = params[:values].split(',').map(&:to_f)
  line_color = param_with_default(:line_color, '4A8FED')

  # http://bit.ly/1qnR55Y
  blob = Sparklines.plot(values,
    dot_size: fixnum_param_with_default(:dot_size, 4),
    height: fixnum_param_with_default(:height, 30),
    line_color: "##{line_color}",
    step: fixnum_param_with_default(:step, 30)
  )

  content_type :png
  blob
end

{'fraction_non_alphanumeric': 0.13470790378006872, 'fraction_numerical': 0.015120274914089347, 'mean_word_length': 5.04149377593361, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '2577425', 'n_tokens_mistral': 572, 'n_tokens_neox': 546, 'n_words': 103}