- Determine your states
- Determine your events
- Determine your side effects (resulting changes in state)
You can store information in two ways:
- State nodes (each state node can have one value)
- Context (can hold arbitrary values because js object)
| require "pathname" | |
| IGNORED_FILES = ['.DS_Store'] | |
| def recurse(directory) | |
| current_dir = Pathname.new(directory) | |
| populate_index(current_dir) | |
| current_dir.children.each do |dir| | |
| recurse(dir) if dir.directory? |
| require "yaml" | |
| class LocalStorage | |
| class DocumentIdAlreadyExists < StandardError; end | |
| class DocumentKeyAlreadyExists < StandardError; end | |
| # YAML format per-environment | |
| # env: { | |
| # corrected_doc_ids: [], | |
| # corrected_doc_keys: [], | |
| # destroyable_doc_keys:[] |
| module Api | |
| module V2 | |
| module Investments | |
| class ProcessesController < Api::V2::BaseController | |
| include InvestmentScoped | |
| def index | |
| end | |
| def show |
| # pseudocode | |
| # assuming message is set by the teacher, and isn't stored on a 1-1 message/parent basis | |
| # but a 1 message - many parents basis | |
| class Message < ActiveRecord::Base | |
| has_many :translations | |
| def translated_message(language_code='en') | |
| translation = translations.where(language_code: language_code).first | |
| if translation |
| # from http://blog.rubyroidlabs.com/2016/04/web-scraping-2/ | |
| def strip_bad_chars(text) | |
| text.gsub!(/"/, "'"); | |
| text.gsub!(/\u2018/, "'"); | |
| text.gsub!(/[”“]/, '"'); | |
| text.gsub!(/’/, "'"); | |
| text | |
| end |
| class @RealtimeForm | |
| constructor: (form) -> | |
| @form = $(form) | |
| @behavior = @form.data("realtime") | |
| @monitorInputs() | |
| monitorInputs: => | |
| @radio_inputs = new RadioGroupInput @form.find(":radio"), @behavior | |
| @inputs = $.map @form.find(":input").not(":input[type=submit]").not(":input[type=radio]"), (input, i) => | |
| new TextyInput(input, @behavior) |
| class WeightFormatter | |
| PROCESSABLE_WEIGHT_UNITS = ["grams", "ounces"] | |
| def self.call(weight_unit, weight) | |
| unless PROCESSABLE_WEIGHT_TYPES.include?(weight_unit) | |
| return "#{weight} #{weight_unit}" | |
| end | |
| send("process_#{weight_unit.downcase}", weight) | |
| end | |