Organizing 2016
with Forth

January 23, 2016

Brad Nelson / @flagxor

Systems of Organization

  • Calendar
  • Diary
  • Ledger
  • Encyclopedia
  • Commonplace Book

Tickler File

  • 43 sections
    • 12 months
    • 31 days

Franklin Planner

  • Daily Page
    • Hourly appointment schedule
    • Prioritized daily task list
    • Daily notes
  • Monthly calendars

Commonplace Book

  • Fragments of text, often borrowed
  • Indexing scheme
    • Locke's Letter-Volume scheme

Locke's Index

Xa
e
i
o
u

Locke's Index

AFMS
BGNT
C [K]HOU [V,W]
DI [J,Y]PX
ELRZ / Qu

Locke's Index

Astronomy → Aa

Geology → Ge

Stars → Sa

Quasars → Qu [Zu]

Task Lists

  • Simple TODO
  • Urgent / Important (Eisenhower)

Gantt Chart

  • Bar chart of project schedule
  • Show dependencies
  • Find critical path

Gantt Chart

Iambically

  • Make entering notes quick
  • Desktop, laptop, phone
  • A quick sketch
  • Use Forth to remind, search, summarize, plan

Iambically

  • Web App + Install to Home Screen
  • Cache local state for offline
  • Sync to a shared database

Iambically

  • Client [JavaScript + Forth]
  • Server [Go (AppEngine)]

Server Storage

  • AppEngine Datastore
  • Entities
    • Lookup by Key
    • Lookup by Index

Structure of an Entry (server)

  • Committed Timestamp
  • Blob of content bytes
    • Modified Timestamp
    • Optional Image (base64)
    • Plaintext

Client Storage

  • IndexedDB
  • Entities
    • Lookup by Key
    • Lookup by Index

Structure of an Entry (client)

  • Committed Timestamp
  • Modified Timestamp
  • Optional Image (base64)
  • Plaintext
  • Server Key
  • Local Key
  • Pending Flag

Synchronization

  • Writes
    • Upload pending items
    • Include server key if any
    • Store server key if new
    • Unmark
  • Reads
    • Find newest local item
    • Fetch server items new than that
    • Assign local key

Drawing

  • Mimic Pastels
  • Blending, smearing, mixing
  • Use the touch screen
  • Provide a handful of "brushes"

Color Mixing

  • RGB
  • HSV
  • Kubelka-Munk (1931)
  • FiftyThree's Paper

Additive Color

Subtractive Color

Primary Colors of Paint

RGB/CYMK Mixing

RGB/CYMK Mixing

RGB/CYMK Mixing

RYB → RGB

R = 1 - b/2

G = (1 - r/2) * (1 - b/4)

B = (1 - r/2) * (1 - y)

RYBK → RGB

R = (1 - k) * (1 - b/2)

G = (1 - k) * (1 - r/2) * (1 - b/4)

B = (1 - k) * (1 - r/2) * (1 - y)

PromiseForth

  • Use JavaScript Promises implement interpreter
  • Expose JavaScript types
  • Expose words idiomatic to JavaScript
  • Scan entries for escaped code
  • ColorForth like marked words
  • Order doesn't matter
  • Run words with "special" prefixes over all the data

PromiseForth

  • foo: → defining word
  • foo → compiled word
  • 'foo → compile xt of word
  • "foo bar baz" → string
  • js"foo bar baz" → inline JavaScript
  • unknown → inline JavaScript value

PromiseForth

  • [cond] [xt] if
  • [times] [xt] repeat

PromiseForth

  • +: js"var x = dstack.pop(); var y = dstack.pop(); dstack.push(y + x);"
  • 2dup: over over
  • pow2: 1 over '2* repeat

JavaScript Promises

  • Promise to do something asynchronously
  • Chain dependent events
  • Looks more like blocking code

Create a Promise


new Promise(function(resolve, reject) {
  var foo = new Operation();
  foo.onsuccess = function() {
    resolve(result);
  };
  foo.onerror = function() {
    reject(error);
  };
});
          

Using Promises


return promise1.then(function(result) {
  // do something on success
}).catch(function(error) {
  // do something on error
});
          

Chaining Promises


return promise1.then(function() {
  // do something then promise a result
}).then(function(result1) {
  // do something then promise a result
}).then(function(result2) {
  // do something then promise a result
}).then(function(result3) {
  // do more
}).catch(function(error) {
  // handle error
});
          

Sweeping

  • Gather information from entries
  • Summarize with alerts
  • Select search results

Prefixes

  • start-* → Run before sweep
  • each-* → Run per entry
  • finish-* → Run after sweep

Inputs

  • query
  • content
  • modify date
  • images

Outputs

  • alerts
  • entries

Status

  • Distributed Entry
  • Pastels
  • Basic PromiseForth
  • Offline Use

TODO

  • Offline Load
  • Better handling of dates
  • Interesting reports
  • Notifications
  • Encryption?
  • Scale?
  • Use and iterate

Source and slides at:
github.com/flagxor

Thank you