Skip to content

Instantly share code, notes, and snippets.

(require '[scicloj.metamorph.ml.rdatasets :as rdatasets])
(require '[tablecloth.api :as tc])
(require '[membrane.ui :as ui ])
(require '[membrane.component :refer [defeffect defui]])
(require '[wadogo.scale :as s])
(require '[membrane.skia.paragraph :as para])
(import 'com.github.davidmoten.rtree.RTree
'com.github.davidmoten.rtree.Entries
'com.github.davidmoten.rtree.geometry.Geometries)
;; {:deps {org.clojure/core.async {:mvn/version "1.9.808-alpha1"}}}
(defn parallel-proc
([] {:params {:n "level of parallelism"
:f "compute function"}
:ins {:in "Input channel"}
:outs {:out "Output channel"}})
([{:keys [n f]}]
(let [work-output-ch (async/chan n)
work-input-ch (async/chan n)]
;; {:deps {org.clojure/clojure {:mvn/version "1.12.1"}
;; com.github.seancorfield/next.jdbc {:mvn/version "1.3.1070"}
;; org.xerial/sqlite-jdbc {:mvn/version "3.47.1.0"}
;; com.github.seancorfield/honeysql {:mvn/version "2.7.1350"}}}
(ns com.phronemophobic.reagentdewey)
(require '[clojure.java.io :as io]
'[honey.sql :as sql]
'[next.jdbc :as jdbc])
@phronmophobic
phronmophobic / large-interface.edn
Created September 24, 2024 21:34
Large interface
[[:Struct_33023E32 [{:n-elems 1, :datatype :int32, :name :m} {:n-elems 1, :datatype :int32, :name :n_iter} {:n-elems 1, :datatype :int32, :name :max_linesearch} {:n-elems 1, :datatype :float32, :name :eps} {:n-elems 1, :datatype :float32, :name :ftol} {:n-elems 1, :datatype :float32, :name :wolfe} {:n-elems 1, :datatype :float32, :name :min_step} {:n-elems 1, :datatype :float32, :name :max_step} {:n-elems 1, :datatype :int32, :name :linesearch}]] [:ggml_scratch [{:n-elems 1, :datatype :int64, :name :offs} {:n-elems 1, :datatype :int64, :name :size} {:n-elems 1, :datatype :pointer, :name :data}]] [:ggml_cplan [{:n-elems 1, :datatype :int64, :name :work_size} {:n-elems 1, :datatype :pointer, :name :work_data} {:n-elems 1, :datatype :int32, :name :n_threads} {:n-elems 1, :datatype :pointer, :name :abort_callback} {:n-elems 1, :datatype :pointer, :name :abort_callback_data}]] [:Struct_B6B81675 [{:n-elems 1, :datatype :int32, :name :n_iter} {:n-elems 1, :datatype :float32, :name :sched} {:n-elems 1, :datatype :flo
> *e
#error {
:cause "Could not resolve symbol: clojure.stacktrace/print-cause-trace"
:data {:type :sci/error, :line 1, :column 2, :file nil, :phase "analysis"}
:via
[{:type clojure.lang.ExceptionInfo
:message "Could not resolve symbol: clojure.stacktrace/print-cause-trace"
:data {:type :sci/error, :line 1, :column 2, :file nil, :phase "analysis"}
:at [sci.impl.utils$throw_error_with_location invokeStatic "utils.cljc" 49]}]
:trace
{:via
[{:type clojure.lang.ExceptionInfo,
:message
"No implementation of method: :getName of protocol: #'sci.impl.vars/HasName found for class: nil",
:data
{:type :sci/error,
:line 1,
:column 1,
:message
"No implementation of method: :getName of protocol: #'sci.impl.vars/HasName found for class: nil",
@phronmophobic
phronmophobic / cli-experience-report.md
Last active March 11, 2021 20:45
CLI experience report

I started using clojure cli a few months ago and I'm already sold on switching all my projects to work with deps.edn.

It works really well for projects and tools that I write, but I struggle when trying to use the cli to run tools like depstar and deps-deploy.

My conceptual model for how to use clojure cli:

  1. specify the clojure environment (deps, java command flags, initial values)
  2. specify a clojure function to run
  3. specify arguments to pass to pass the #2

As a clojure cli user, is there a better conceptual model? I tend to struggle because the available clj command line options aren't organized into those 3 steps.

@phronmophobic
phronmophobic / gist:97ea46dfae51958e2e7686243ac27860
Last active March 11, 2021 18:54
Reorganized clojure cli help
Usage:
Start a REPL clj [clj-opt*] [-A:aliases] [init-opt*]
Exec function clojure [clj-opt*] -X[:aliases] [a/fn] [kpath v]*
Run main clojure [clj-opt*] -M[:aliases] [init-opt*] [main-opt] [arg*]
Prepare clojure [clj-opt*] -P [other exec opts]
clj-opts:
-Jopt Pass opt through in java_opts, ex: -J-Xmx512m
-Sdeps EDN Deps data to use as the last deps file to be merged
-Spath Compute classpath and echo to stdout only
;; Display a single todo item
(defui todo-item [ & {:keys [todo]}]
(horizontal-layout
(translate 5 5
(on
:mouse-down
(fn [[mx my]]
[[:delete $todo]])
(delete-X)))
(translate 10 4