This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "uri" | |
require "json" | |
require "net/http" | |
def recursive_fetch(url) | |
url = URI(url) | |
https = Net::HTTP.new(url.host, url.port) | |
https.use_ssl = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# open AvatarUploader and re-define the filename method dynamically- because ewe can't deploy this code, | |
# it doesn't work for new records as the processing happens async and can't gauarentee that model.id exists, so we | |
# should run it only after the record is created. | |
AvatarUploader.class_eval do | |
def filename | |
token = OpenSSL::HMAC.hexdigest('SHA256', ENV['AWS_SECRET'], model.id.to_s) | |
"#{token}.#{file.extension}" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#csv is the wave 1-5 files for centers. | |
childcare = Childcare.first | |
CSV.parse(csv, headers: true).each_with_index do |row, index| | |
center_kindercare_id = row['Location ID'] | |
region_id = row['Location Region'].to_i | |
district_id = row['Location District'].to_i | |
label = construct_region_label(region_id: region_id, district_id: district_id) | |
region = Region.where(label: label).first_or_create! do |r| | |
r.childcare_id = childcare.id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
visit https://kafka.apache.org/downloads | |
download 0.8.0 Release (Binary Download) | |
cd /tmp | |
cp ~/Downloads/kafka_2.8.0-0.8.0.tar.gz . | |
tar -zxvf kafka_2.8.0-0.8.0.tar.gz -C /usr/local/ | |
sbt update | |
sbt package | |
cd /usr/local/kafka_2.8.0-0.8.0 | |
bin/zookeeper-server-start.sh config/zookeeper.properties | |
bin/kafka-server-start.sh config/server.properties |