Skip to content

Instantly share code, notes, and snippets.

@joewalker
Created December 12, 2016 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joewalker/969451e631c40173f81a21cf6a9b1aad to your computer and use it in GitHub Desktop.
Save joewalker/969451e631c40173f81a21cf6a9b1aad to your computer and use it in GitHub Desktop.
Get a repl that allows you to use your tofino profile to practice your datascript
; $ cd .../datomish
; lein repl
(require '[datomish.api :as d])
(require '[datomish.sqlite])
(require '[datomish.jdbc-sqlite])
(require '[clojure.core.async :as async])
; You'll need to replace $HOME with whatever $HOME is, and if not on a mac, do something AppData like
(d/<connect "file:///{$HOME}/Library/Application%20Support/tofino/browser-datomish.db")
(def thedb (first *1))
; This is a handy helper function, which saves your console back-scroll and works around #datomish/131
(defn qq [q] (async/<!! (d/<q (d/db thedb) q {:limit 1023})))
; Lookup all the pages in your history that include the phrase "amazon"
; i.e. the pages_matching_string function
(qq {
:find '[?url ?title]
:in '[$]
:where [
[ (list 'fulltext '$ #{:page/url :page/title} "amazon") '[[?page]] ]
'[(get-else $ ?page :page/url "") ?url]
'[(get-else $ ?page :page/title "") ?title]
]
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment