2023-04-24

going constraint crazy

constrain-zy?

An idea for a hotel theme api:

var bat_theme_rules = [
        {path_opts: [ELEVATOR, BAT, {skip_tile=BAT_BOXES, width=2}]}
        ]
  • Defining a path in the world, from any elevator to any bat
  • Then, an options map for the tile gen algorithm
  • skip_tile means don't use this tile, please tile along this path.
  • width means the skip-bat-box path we defined here should be at least 2 tiles wide the whole way, so we can go ahead an use a window of that size to carve it

Definitely data-driven!

A bit nicer in clojure:

(def bat_theme_rules [
  {:label     "Start to Bat, Box-free Path Rule"
   :path_opts [:elevator :bat {:skip_tile :bat_boxes :width 2}]}
  {:label     "Post-Boss Battle Lost-Bat Elevator Walk"
   :path_opts [:boss-room :elevator {:skip_tile :bat_boxes :width 2}]}])

Added a label and another rule idea. On a path-constraint streak, it seems.

lil org-roam merge-nodes helpers

in clojure via repl

NOTE this is a WIP version of this script, it needs a bit more love!

(defn merge-org-roam-files [{:keys [old-id new-id dry-run]}]
  (println "\n\n\tFind-replacing across your org files!!")
  (if dry-run (println "\tDRY RUN!") (println "\tBOMBS AWAY!"))

  (let [files
        (concat
          (fs/list-dir (fs/expand-home "~/todo/garden") "*.org")
          (fs/list-dir (fs/expand-home "~/todo/daily") "*.org")
          (fs/list-dir (fs/expand-home "~/todo/garden/workspaces") "*.org"))]
    (->> files
         #_(take 50)
         (map (fn [file]
                (let [lm           (fs/last-modified-time file)
                      any-changes? (atom false)
                      res
                      (cond->> (slurp (str file))
                        true (string/split-lines)
                        true
                        (map
                          (fn [line]
                            (if (string/includes? line old-id)
                              (do
                                (when dry-run
                                  (println "\n\t" (fs/file-name file)
                                           "\nwould replace" line
                                           "\nwith" (string/replace line old-id new-id)))

                                (when-not @any-changes?
                                  (reset! any-changes? true))

                                (when-not dry-run
                                  (println "\n\t updating" (fs/file-name file) "\n" line))

                                (if dry-run
                                  line (string/replace line old-id new-id)))
                              line)))
                        true                (string/join "\n")
                        (and (not dry-run)
                             @any-changes?) (spit (str file)))]
                  (fs/set-last-modified-time file lm)
                  res)))
         (remove nil?)
         count)))

(comment
  (merge-org-roam-files
    {:old-id  "id:f617ee24-cfad-4c6e-8dff-227ae56c22e5"
     :new-id  "id:f617ee24-cfad-4c6e-8dff-227ae56c22e5"
     :dry-run true}))
cider output from a dry-run of my dangerously cheesy find-replace helper

cider output from a dry-run of my dangerously cheesy find-replace helper

I'm sure this is just sed or something... but i still like it.

chasing an emacs snippet, turns out it shells out

I wonder when i buried this work-around...

;;;###autoload
(defun russ/last-screenshot ()
  (let ((filename (shell-command-to-string "ls ~/Screenshots | sort -V | tail -n 1")))
    (s-trim filename)))

Following the blame, this is only one step removed from the original snippet:

# key: scr
# name: screenshot
# --
`(shell-command-to-string "ls ~/Screenshots | sort -V | tail -n 1")`
magit shows February 2019

magit shows February 2019

Not the best of commit messages

hot damn!

hot damn!

screenshot snippet finally working again

Took about as long to fix it as it took to figure out how to reload the function, yas-snippet, org-mode, etc. But we're back!

finished moving all workspace notes into the garden!

Some org-crud helpers to make things a bit easier, and maybe grow into a more sensible helper going forward.

Still quite a bit of gardening mess around, but this was a good step to push through.

test list of reses, only tagged as such

with a link to the repo: https://github.com/russmatney/clawe

my fancy db/query tool vs. my rudimentary blog.db filter

Loving the datalog stuff lately, but halfway through debugging this, i realized my simple parse and filter api is actually alot less code, b/c i don't have to worry about the joining.

I'm probably sacrificing performance and query flexibility/simplicity... tho I'd argue the filter and just-code impl is alot easier to read when you don't have much datalog experience.

(defn resource-notes []
  (->>
    (db/query
      '[:find (pull ?note [*])
        :where
        [?note :doctor/type :type/note]
        [?note :org/name-string ?name]
        (or
          [?note :org/tags "resources"]
          [(clojure.string/includes? ?name "resources")])])
    (map first)
    (garden.db/join-children)
    (map (fn [db-note]
           (let [found-note (some-> db-note :org/id blog.db/id->note)]
             (if found-note
               (merge db-note found-note)
               ;; TODO support looking up note in blog.db without :org/id
               ;; probably similarly via :org/fallback-id
               db-note))))))

(defn resource-notes-from-blog-db []
  (->>
    (blog.db/all-notes)
    (filter (fn [note]
              (or
                (-> note :org/name-string (string/includes? "resources"))
                (-> note :org/tags (#(% "resources"))))))))

These are almost the same, except the first one has a problem where notes/children without uuids get lost.

(comment
  (count (resource-notes))
  (count (resource-notes-from-blog-db))

  (->>
    (resource-notes)
    (filter (comp seq :org/items)))

  (->>
    #_(resource-notes)
    (resource-notes-from-blog-db)
    first
    org-crud/nested-item->flattened-items)

  (->>
    (db/query
      '[:find (pull ?note [*])
        :where
        [?note :doctor/type :type/note]
        [?note :org/parent-name ?pname]
        [(clojure.string/includes? ?pname "mac osx customization")]
        [?note :org/name-string ?name]
        [(clojure.string/includes? ?name "resources")]])
    (map first)
    (garden.db/join-children))

  (db/query '[:find (pull ?c [*])
              :in $ ?db-id
              :where [?c :org/parents ?db-id]]
            19429))

Some comments I wrote while working with these, for posterity.

clawe overview video

I want to make highest-leve clawe overview video.

I want to plan a stream to create the recording

and edit the recording into a reasonable youtube video

I'm hoping it can be short, but i also want it to be thorough.

draft of this is done! https://danger.russmatney.com/note/clawe_overview_video.html

filter-grouper (doctor feature) should be datascript -integrated

  • the presets
  • the queries

maybe use-filter should take a datalog query and the connection

ideally it could also ping the backend for stats/missing data

IN PROGRESS filter-grouper should derive presets from items

derive filters/presets from the content itself

(or define them via database indexes)

e.g. sort-bys, filter-bys, group-bys

e.g. preset for grouping by top 5 most common tags

e.g. preset for sorting by any dates found

e.g. paging on presets means show-more, i.e. got to 10 most-common-tags

IN PROGRESS filter-grouper should attach suggestions on items

i.e. some of these items had tag 'clawe': do _you_ want tag 'clawe'? then include those in an items's :actions/suggested list and mix them into the card ui

IN PROGRESS filter-grouper suggests :add-tag, todo/card shows :add-tag suggestions on hover

show suggested tags on hover, click to add

starting a streaming schedule, finally

Hopefully I can keep this up to date, and that I don't mix it up with the content calendar

Will try to assign some dates via Twitch