<commit_before># cdn related tasks
#
desc 'pre-stage assets on cdn'
task 'assets:prestage' => :environment do |t|
  require "net/https"
  require "uri"

  config = YAML::load(File.open("#{Rails.root}/config/cdn.yml"))

  # pre-stage css/js only for now
  a = Dir.glob("#{Rails.root}/public/assets/*").map do |f|
    if f =~ /[a-f0-9]{16}\.(css|js)$/
      "/assets/#{f.split('/')[-1]}"
    end
  end.compact

  puts "pre staging: #{a.join(' ')}"
  start = Time.now

  uri = URI.parse("https://client.cdn77.com/api/prefetch")
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE<commit_msg>pre-stage our locales as well<commit_after># cdn related tasks
#
desc 'pre-stage assets on cdn'
task 'assets:prestage' => :environment do |t|
  require "net/https"
  require "uri"

  def get_assets(path)
    a = Dir.glob("#{Rails.root}/public/assets/#{path}*").map do |f|
      if f =~ /[a-f0-9]{16}\.(css|js)$/
        "/assets/#{path}#{f.split('/')[-1]}"
      end
    end.compact
  end
  
  # pre-stage css/js only for now
  a = get_assets("locales/") + get_assets("")
  puts "pre staging: #{a.join(' ')}"

  # makes testing simpler leaving this here
  config = YAML::load(File.open("#{Rails.root}/config/cdn.yml"))

  start = Time.now

  uri = URI.parse("https://client.cdn77.com/api/prefetch")
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
{'fraction_non_alphanumeric': 0.19821673525377229, 'fraction_numerical': 0.009602194787379973, 'mean_word_length': 3.40785498489426, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2084672', 'n_tokens_mistral': 580, 'n_tokens_neox': 560, 'n_words': 115}