This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-10-30
Channels
- # admin-announcements (11)
- # announcements (1)
- # beginners (1)
- # boot (247)
- # cider (15)
- # clara (16)
- # cljs-dev (14)
- # clojure (118)
- # clojure-czech (10)
- # clojure-ecuador (1)
- # clojure-japan (1)
- # clojure-russia (22)
- # clojurescript (57)
- # data-science (12)
- # datomic (2)
- # devcards (1)
- # editors-rus (2)
- # emacs (1)
- # events (2)
- # funcool (1)
- # hoplon (37)
- # juxt (1)
- # ldnclj (2)
- # leiningen (1)
- # nginx (12)
- # off-topic (16)
- # om (361)
- # onyx (34)
- # re-frame (3)
- # spacemacs (9)
- # yada (43)
@bradford: If the keys weren’t nested then you’d use select-keys
. I’ve run into this from time to time, https://groups.google.com/forum/#!topic/clojure/gGigc9BWzNw and https://gist.github.com/cgrand/2823916 are on the right track. Thinking about it now, I wonder if Spectre could help, I haven’t looked into it much
also https://crossclj.info/ns/im.chit/iroh/0.1.11/iroh.common.html#_select-keys-nested
@danielcompton: Thanks! I’ve looked at most of those and they’re on the right path (the iroh.common code doesn’t seem to …work), but nothing’s really hitting me yet. Will keep kicking it.
Why do you need to filter the map keys in the first place?
I mean, what’s the use case for needing to pick some of them out? Can they get filtered elsewhere?
the other option would be to do select-keys on all of the level one keys, then a get
+ select-keys
on all of the two level keys, e.t.c.
They’re in a JSON blob read from a S3 file, and then I’m transforming that map to write to BigQuery (a database)
So… no logic, really. Just need to filter out the KVs in S3 that aren’t columns in BigQuery. A pretty common use case in my day-to-day.
With SQL selects, I want rows in vectors, not maps. How to do this? (FWIW I'm using yesql.)
sounds like something nathanmarz/specter
could handle. I haven’t used it before but I’ve been trying to find a good excuse to
Yeah, I was hoping to just be lazy. Unfortunately, yesql removed support for :as-arrays?
at some point... https://github.com/krisajenkins/yesql/pull/116/files
Is there a way to test if a value is a thing I can map over, as in, vector, list, set, etc?
dot_treo: seq? is false for vectors.
you really want seqable? (although that doesn't actually exist in core)
there is a version in core.incubator
alexmiller: thanks.
I have this pattern of a function that I want to take one value or a sequence of values and do an operation to each of them. Is this anti-idiomatic?
@bradford: you wrote: https://clojurians.slack.com/archives/clojure/p1446158343003081 You might try https://github.com/nathanmarz/specter ? it's amazing for transforming nested data structures
roberto: no, but there are a few interesting things. Fn-fx https://github.com/halgari/fn-fx
Ok Clojurians. Lets talk vars.
(def revenue.system {})
=> #'revenue.main/revenue.system
(def test-conn
(get-in var-get(#'revenue.system) [:datomic :conn]))
CompilerException clojure.lang.ArityException: Wrong number of args (0) passed to: PersistentArrayMap, compiling:(form-init3451962995536705092.clj:2:18)
(var-get #'revenue.system)
=> {}
(get-in (var-get #'revenue.system) [:datomic])
=> nil
Using var-get within the def I get an error every time. Same call outside the def magic. What gives?
ghadi: !! My brotha!
Wow I'm a dink
I just realized what I did there. Ha.
if you're trying to remember a part of a map, make a handle for it in a var, and keep it updated you can't - soorrry
I'm only using a var in this case because I'm doing setup/teardown in a fixture so I was unable to get a handle on the map (value of this var) in the tests. Hopefully nobody will change this under my feet
(defn fresh-db-seeded [f]
(let [sys (start-system! #'revenue.system test-system)]
(fixtures/transact-all (test-conn) (fixtures/resource "fixtures.edn"))
(f)
(d/delete-database (memdb sys))
(stop-system! #'revenue.system)))
Ideally we could pass the system to (f) which in this case ends up being a test
(use-fixtures :each fresh-db-seeded)
Because of the def? I'm working on removing it from the def now
(def test-conn
(get-in (var-get #'revenue.system) [:datomic :conn]))
1) this def for test-conn
is evaluated immediately - var-get or not. it's going to be a value (the datomic connection)
Cool cool I see that playing around in the REPL. I didn't realize the var would be eval'd passing to get-in etc
My two cents, you can wrap it in a delay that you can then deeref at the initialization phase
tim.linquist: if the compiler sees a symbol it will try to resolve to a let binding, var, or java Class
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java#L7027-L7071
the main one should not be
there is a classifier version that does
getting an error trace like this intermittently:
Caused by: java.lang.RuntimeException: Unable to resolve symbol: init in this context, compiling:(clojure/tools/reader/impl/ExceptionInfo.clj:1:1)
at clojure.lang.Compiler.analyze(Compiler.java:6543)
at clojure.lang.Compiler.analyze(Compiler.java:6485)
at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3791)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6725)
at clojure.lang.Compiler.analyze(Compiler.java:6524)
at clojure.lang.Compiler.analyze(Compiler.java:6485)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5861)
at clojure.lang.Compiler$TryExpr$Parser.parse(Compiler.java:2261)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6723)
at clojure.lang.Compiler.analyze(Compiler.java:6524)
at clojure.lang.Compiler.analyze(Compiler.java:6485)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5861)
I don't see anything like that in either the main tools.reader jar or the aot-ed classifier variant
I know that there is some weird stuff going on in there to support older clj versions though
can you do a lein deps :tree ?
@alexmiller: this is a maven project, I'll paste the dependencies
[INFO] +- org.clojure:clojure:jar:1.7.0:compile
[INFO] +- prismatic:schema:jar:0.4.3:compile
[INFO] +- org.clojure:tools.nrepl:jar:0.2.6:compile
[INFO] +- clj-time:clj-time:jar:0.9.0:compile
[INFO] | \- joda-time:joda-time:jar:2.9:compile
[INFO] +- org.clojure:java.jdbc:jar:0.3.7:compile
[INFO] +- cheshire:cheshire:jar:5.2.0:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-core:jar:2.2.1:compile
[INFO] | +- com.fasterxml.jackson.dataformat:jackson-dataformat-smile:jar:2.2.1:compile
[INFO] | \- tigris:tigris:jar:0.1.1:compile
[INFO] +- clojurewerkz:elastisch:jar:2.2.0-beta4:compile
[INFO] | +- clojurewerkz:support:jar:1.1.0:compile
[INFO] | \- org.elasticsearch:elasticsearch:jar:1.7.2:compile
[INFO] | +- org.apache.lucene:lucene-core:jar:4.10.4:compile
[INFO] | +- org.apache.lucene:lucene-analyzers-common:jar:4.10.4:compile
[INFO] | +- org.apache.lucene:lucene-queries:jar:4.10.4:compile
[INFO] | +- org.apache.lucene:lucene-memory:jar:4.10.4:compile
[INFO] | +- org.apache.lucene:lucene-highlighter:jar:4.10.4:compile
[INFO] | +- org.apache.lucene:lucene-queryparser:jar:4.10.4:compile
[INFO] | +- org.apache.lucene:lucene-sandbox:jar:4.10.4:compile
[INFO] | +- org.apache.lucene:lucene-suggest:jar:4.10.4:compile
[INFO] | +- org.apache.lucene:lucene-misc:jar:4.10.4:compile
[INFO] | +- org.apache.lucene:lucene-join:jar:4.10.4:compile
[INFO] | +- org.apache.lucene:lucene-grouping:jar:4.10.4:compile
[INFO] | +- org.apache.lucene:lucene-spatial:jar:4.10.4:compile
[INFO] | | \- com.spatial4j:spatial4j:jar:0.4.1:compile
[INFO] | \- org.yaml:snakeyaml:jar:1.12:compile
[INFO] +- com.stuartsierra:dependency:jar:0.1.1:compile
[INFO] +- org.clojure:tools.logging:jar:0.3.1:compile
[INFO] +- clj-antlr:clj-antlr:jar:0.2.2:compile
[INFO] | +- org.antlr:antlr4-runtime:jar:4.2.2:compile
[INFO] | | +- org.abego.treelayout:org.abego.treelayout.core:jar:1.0.1:compile
[INFO] | | \- org.antlr:antlr4-annotations:jar:4.2.2:compile
[INFO] | \- org.antlr:antlr4:jar:4.2.2:compile
[INFO] | +- org.antlr:antlr-runtime:jar:3.5.2:compile
[INFO] | \- org.antlr:ST4:jar:4.0.8:compile
[INFO] +- fast-zip:fast-zip:jar:0.7.0:compile
[INFO] +- fast-zip-visit:fast-zip-visit:jar:1.0.2:compile
[INFO] +- org.clojure:core.match:jar:0.3.0-alpha4:compile
[INFO] | \- org.clojure:tools.analyzer.jvm:jar:0.6.5:compile
[INFO] | +- org.clojure:tools.analyzer:jar:0.6.4:compile
[INFO] | +- org.ow2.asm:asm-all:jar:4.2:compile
[INFO] | \- org.clojure:tools.reader:jar:0.8.12:compile
[INFO] \- org.clojure:core.memoize:jar:0.5.6:compile
[INFO] \- org.clojure:core.cache:jar:0.6.3:compile
[INFO] \- org.clojure:data.priority-map:jar:0.0.2:compile
I think the older versions of tools.reader don't exclude class-files: https://github.com/clojure/tools.reader/blob/tools.reader-0.8.12/pom.xml#L29
yeah, that looks like a pretty old version
might ask @bronsa about that stuff, I don't know the history of the tools reader version of ExceptionInfo
it was 1.3 compatibility, removed in 0.10.0, my fear is breaking core.match or tools.analyzer.jvm, but I haven't tried yet, just tried to understand what could be breaking things.
I suspect you're prob fine with tools.analyzer.jvm and core.match
the next version of tajvm will bump up the reader dep
it may be worth releasing a new version of core.match that merely bumped those older deps, not sure
I think that would be helpful, I'm using the latest, which is an alpha anyway, relying on these old deps.
Is the 'right' (only?) way to get a compojure/ring web server (running from an uberjar) to serve static files from the local file system, to use routes/files explicitly instead of routes/resources? There's wrap-files as well, but not sure how that composes with route/* stuff. This scenario needs to change a couple things in a js file from the 'defaults' in the version in the jar. So, it creates an 'installation' in a local directory and extracts the resources from the jar into that local directory, then makes the tweak change to the js file. Currently it uses route/resources to set root for this, but that always uses the version in the jar - even if I use -cp ... when running it. Thanks in advance for any info!
[:db/add #db/id[:db.part/user] :db/ident :state/AL] [:db/add #db/id[:db.part/user] :db/ident :state/AK] [:db/add #db/id[:db.part/user] :db/ident :state/AZ] [:db/add #db/id[:db.part/user] :db/ident :state/AR]
(datomic.api/q '[:find [?name-str ...] :where [?e :db/ident ?ident] [?ident :db/ident ?name-keyword] [(name ?name) ?name-str] [ (count ?name-str) ?len] [(= 2 ?len)] ] (bonfire.api.data.core/db))
You could look for idents that start with :state (e.g. using Java String’s startsWith method)
(datomic.api/q '[:find [?name-str ...] :where [?e :db/ident ?ident] [?ident :db/ident ?name-keyword] [(name ?name-keyword) ?name-str] [(namespace ?name-keyword) ?ns] [(= "state" ?ns)] ] (bonfire.api.data.core/db))
even better
Sorry if this is borderline spammy, but I wanted to drop a note in here for anyone interested that I created a #C08TC9JCS channel. For folks who don't know what Clara is: https://github.com/rbrush/clara-rules
(hello) ?
Ah, it's ok, this will do the trick! https://github.com/weavejester/lein-ring/blob/17cd6cb3b0cce6b842da1623bb2023326906cbb3/src/leiningen/ring/util.clj#L19
@phil here is the working example, in case you haven't seen this way of doing it ((find-var x) inc [1 2 3])
gives (2 3 4)