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
# SolidusImporter::Row now has a `entity_id` field. | |
# It helps aggregate rows that belong to the same "entity" (Order for now) so we can process them together. | |
# With this, there's no need to maintain a huge context inside the `ProcessRow` job any longer. | |
# So how might we? | |
# lib/solidus_importer/process_row.rb | |
# 1. Associate the Row with an `Identifier` we an use to group related rows together | |
def prepare_rows(data) | |
messages = check_data(data) |
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
# GET file from Importer url on dashboard | |
url = '' | |
file_data = Net::HTTP.get URI(url) | |
csv = CSV.parse( | |
file_data, | |
headers: true, | |
encoding: 'UTF-8', | |
header_converters: ->(h) { h.strip } |
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
# GET file from Importer url on dashboard | |
url = '' | |
file_data = Net::HTTP.get URI(url) | |
csv = CSV.parse( | |
file_data, | |
headers: true, | |
encoding: 'UTF-8', | |
header_converters: ->(h) { h.strip } |
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
Dir.glob('*').each do |file| | |
content = File.read(file) | |
parsed_content = content.split("\n")[2].sub('BODY;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:', '') | |
.unpack('M').first.encode('utf-8', 'iso-8859-1') | |
IO.binwrite(file.gsub('vnt', 'txt'), parsed_content) | |
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
string = '1,2,3,4,5,6' | |
number = true | |
string.chars.each do |char| | |
if number && char.number? # pseudo-code | |
number = false | |
continue | |
else | |
if char.comma? |
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
$ irb -r ./select_server | |
>> client.puts "hi" | |
=> nil | |
>> client.puts "bye" | |
=> nil | |
>> client.close | |
=> nil | |
>> exit |
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
results = ActiveRecord::Base.connection.execute(sql) | |
CSV.open('csv.csv', 'w+') do |f| | |
f << results[0].keys | |
results.each do |r| | |
f << r.values | |
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
# note: this assumes the order never gets recalculated | |
csv = CSV.read('maker-orders.csv', headers: true) | |
orders = [] | |
csv.each do |context| | |
order = Spree::Order.find_by_number(context['Name']) | |
next if order.nil? | |
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
corrected = [] | |
File.open('original.txt', 'r').each_line do |date| | |
new_date = Time.parse(date, '%Y-%m-%d %H%M%S') | |
if new_date.month == 6 && new_date.year == 2021 | |
corrected << new_date.next_month.beginning_of_month | |
next | |
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
# https://github.com/ddollar/forego | |
ASSET_HOST=localhost:3000 | |
APPLICATION_HOST=localhost:3000 | |
BCRYPT_COST=12 | |
PORT=3000 | |
RACK_ENV=development | |
RACK_MINI_PROFILER=0 | |
SECRET_KEY_BASE=development_secret | |
EXECJS_RUNTIME=Node |
NewerOlder