Created
December 12, 2016 17:48
-
-
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
This file contains 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
; $ 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