<commit_before>require 'sinatra'
require 'json'
require 'bigdecimal'
require 'csv'
require 'open-uri'
require 'nokogiri'
require 'poseidon'
require 'pry'

$kafka = Poseidon::Producer.new([ENV['KAFKA_HOST']], "finance-demo")

class DataGrid
 
  def initialize
    @auth = 'Authorization: Basic Z<KEY>'
    @url = "http://ec2-54-68-56-201.us-west-2.compute.amazonaws.com:8080/rest/default/{{replace}}"
    @read_curl = "curl -H '#{@auth}' -X GET #{@url}"
    @write_curl = "curl -H '#{@auth}' -X PUT #{@url} -H 'Content-type: text/plain' -d '{{value}}'"
  end

  def get(key:)
    cmdline = @read_curl.gsub("{{replace}}", key)
    `#{cmdline}`
  end

  def put(key:, value:)
    cmdline = @write_curl.gsub("{{replace}}", key)
    cmdline.gsub!("{{value}}", value.to_s)
    `#{cmdline}`
  end

  def import(ticker:)
    name = ticker_to_name(ticker: ticker)
    today = "&d=6&e=25&f=2015"
    yahoo_url = "http://ichart.finance.yahoo.com/table.csv?s=#{ticker}"
    #yahoo_url = "http://ichart.finance.yahoo.com/table.csv?s=#{ticker}#{today}&g=d&a=3&b=12&c=2005&ignore=.csv"
    puts yahoo_url<commit_msg>env things<commit_after>require 'sinatra'
require 'json'
require 'bigdecimal'
require 'csv'
require 'open-uri'
require 'nokogiri'
require 'poseidon'
require 'pry'

$kafka = Poseidon::Producer.new([ENV['KAFKA_HOST']], "finance-demo")

class DataGrid
 
  def initialize
    @auth = ENV['DATAGRID_AUTH']
    @url = "#{ENV['DATAGRID_HOST']}/rest/default/{{replace}}"
    @read_curl = "curl -H '#{@auth}' -X GET #{@url}"
    @write_curl = "curl -H '#{@auth}' -X PUT #{@url} -H 'Content-type: text/plain' -d '{{value}}'"
  end

  def get(key:)
    cmdline = @read_curl.gsub("{{replace}}", key)
    `#{cmdline}`
  end

  def put(key:, value:)
    cmdline = @write_curl.gsub("{{replace}}", key)
    cmdline.gsub!("{{value}}", value.to_s)
    `#{cmdline}`
  end

  def import(ticker:)
    name = ticker_to_name(ticker: ticker)
    today = "&d=6&e=25&f=2015"
    yahoo_url = "http://ichart.finance.yahoo.com/table.csv?s=#{ticker}"
    #yahoo_url = "http://ichart.finance.yahoo.com/table.csv?s=#{ticker}#{today}&g=d&a=3&b=12&c=2005&ignore=.csv"
    puts yahoo_url
{'fraction_non_alphanumeric': 0.21086855550394798, 'fraction_numerical': 0.019972131908964234, 'mean_word_length': 4.253658536585366, 'pattern_counts': {'":': 0, '<': 4, '<?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': '3731228', 'n_tokens_mistral': 944, 'n_tokens_neox': 893, 'n_words': 156}