This file contains hidden or 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
#!/usr/bin/env ruby | |
files_to_process = Dir.glob('**/*.html') | |
target_directory = '/home/masa331/code/html_js/masa331.github.io' | |
files_to_process.each do |file| | |
content = File.read(file) | |
modified = content.lines.map do |line| | |
if line.include? 'INSERT' |
This file contains hidden or 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
module ColorParser | |
def parse | |
source.select { |k, _| k == :color } | |
end | |
end | |
module BrandParser | |
def parse | |
source.select { |k, _| k == :brand } | |
end |
This file contains hidden or 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
module HashFlatten | |
refine Hash do | |
def squish_levels | |
each_with_object({}) do |(key, value), squished| | |
if value.is_a? Hash | |
value.squish_levels.each { |sub_key, sub_value| squished.store("#{key}.#{sub_key}", sub_value) } | |
else | |
squished.store(key.to_s, value) | |
end | |
end |
This file contains hidden or 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
var resp = []; | |
req = new XMLHttpRequest(); | |
req.open('GET', url, false); | |
req.setRequestHeader('Content-Type', 'application/json'); | |
req.onload = function (response) { | |
console.log('loaded'); | |
console.log(response); | |
resp = response; | |
}; |
This file contains hidden or 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
module StringApply | |
def apply(*funcs) | |
funcs.inject(self) { |product, func| func.call(product) } | |
end | |
end | |
module ArrayApply | |
def apply(*funcs) | |
# funcs.inject(self) { |product, func| func.call(product) } | |
map { |item| funcs.inject(item) { |product, func| func.call(product) } } |
This file contains hidden or 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
Roger MacBride Allen - Ztracená země | |
Robert Fabian - Carpe Diem | |
Robert Fabian - Sepmer Fi | |
Ian McDonald - Řeka Bohů | |
Robert Charles Wilson - Spin | |
Kevin J Anderson - Skrytá Říše | |
Bruce Sterling - Shismatrix Plus | |
Kurt Vonnegut - Jatka č. 5 | |
Frederik Pohl - Gateway | |
Douglas Adams - Sotpařův průvodce po galaxii |
This file contains hidden or 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 'nokogiri' | |
RSpec::Matchers.define :match_xsd do |schema_path| | |
match do |document| | |
schema = Nokogiri::XML::Schema(File.open(schema_path)) | |
errors = schema.validate(document) | |
errors.size == 0 | |
end |
This file contains hidden or 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
Eet::Message | |
#body | |
Element '{http://fs.mfcr.cz/eet/schema/v3}Hlavicka', attribute 'dat_odesl': '' is not a valid value of the atomic type '{http://fs.mfcr.cz/eet/schema/v3}dateTime'. | |
Element '{http://fs.mfcr.cz/eet/schema/v3}Data': The attribute 'dic_popl' is required but missing. | |
Element '{http://fs.mfcr.cz/eet/schema/v3}Data': The attribute 'id_provoz' is required but missing. | |
Element '{http://fs.mfcr.cz/eet/schema/v3}Data': The attribute 'id_pokl' is required but missing. | |
Element '{http://fs.mfcr.cz/eet/schema/v3}Data': The attribute 'porad_cis' is required but missing. | |
Element '{http://fs.mfcr.cz/eet/schema/v3}Data': The attribute 'dat_trzby' is required but missing. | |
Element '{http://fs.mfcr.cz/eet/schema/v3}Data': The attribute 'celk_trzba' is required but missing. | |
Element '{http://fs.mfcr.cz/eet/schema/v3}Data': The attribute 'rezim' is required but missing. |
This file contains hidden or 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 'spec_helper' | |
require 'nokogiri' | |
RSpec.describe Eet::Message do | |
describe '#body' do | |
it "is valid against it's xsd schema" do | |
message = Eet::Message.new() | |
schema = Nokogiri::XML::Schema(File.read('./spec/fixtures/EETXMLSchema.xsd')) | |
errors = schema.validate(message.body) |
This file contains hidden or 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 'nokogiri' | |
require 'securerandom' | |
module Eet | |
class Message | |
def body | |
Nokogiri::XML::Builder.new('encoding' => 'UTF-8') do |xml| | |
xml.Trzba(xmlns: 'http://fs.mfcr.cz/eet/schema/v3') do | |
xml.Hlavicka(dat_odesl: '1.1.2017 10:00', prvni_zaslani: true, uuid_zpravy: SecureRandom.uuid) |