Last active
March 16, 2020 09:02
-
-
Save fxn/80b25d3aeee7b5ff4dece7e2161cfdad to your computer and use it in GitHub Desktop.
Revisions
-
fxn renamed this gist
Mar 16, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
fxn revised this gist
Mar 16, 2020 . 2 changed files with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ <div class="card"><div class="content">{{Back}}</div></div> 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ <div class="card"><div class="content">{{Front}}</div></div> -
fxn created this gist
Mar 16, 2020 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ #!/usr/bin/env ruby require 'find' require 'yaml' require 'csv' require 'erb' all = ARGV[0] == "all" def process_card(card) ERB::Util.h(card.strip).gsub(/\\n/, '<br>') end root = File.expand_path('..', __dir__) Find.find(root) do |file| Find.prune if File.basename(file) == 'bin' next unless file.end_with?('.yml') deck = file.sub(/\.yml\z/, '.csv') if all || (!File.exist?(deck) || File.mtime(file) > File.mtime(deck)) deck_name = deck.sub(%r(.*?/decks/), '').gsub('/', '::').sub(/\.csv\z/, '') puts "generating #{deck_name}" CSV.open(deck, 'w', col_sep: "\t", force_quotes: true) do |csv| cards = YAML.load_file(file) cards.each do |card| question = process_card(card['q']) answer = process_card(card['a']) csv << [question, answer] end end 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ .card { font-family: Menlo; font-size: 22px; font-weight: bold; text-align: center; } .content { white-space: pre; text-align: left; display: inline-block; } .replaybutton { display: none; }