This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-22
Channels
- # announcements (2)
- # beginners (42)
- # calva (2)
- # cider (13)
- # clara (2)
- # cljdoc (1)
- # cljs-dev (8)
- # clojure (118)
- # clojure-australia (1)
- # clojure-europe (3)
- # clojure-finland (2)
- # clojure-italy (42)
- # clojure-japan (1)
- # clojure-nl (2)
- # clojure-spec (26)
- # clojure-uk (58)
- # clojurescript (83)
- # cursive (6)
- # data-science (2)
- # datomic (13)
- # devcards (2)
- # duct (9)
- # figwheel-main (4)
- # fulcro (11)
- # graphql (51)
- # jobs (1)
- # juxt (14)
- # kaocha (1)
- # off-topic (24)
- # re-frame (65)
- # reagent (4)
- # reitit (19)
- # remote-jobs (8)
- # shadow-cljs (50)
- # specter (3)
- # speculative (1)
- # vim (5)
- # yada (50)
How do you save and read sorted maps to a file in ClojureScript? ClojureScript:
=> (binding [*print-dup* true]
(prn (sorted-map :foo 1)))
{:foo 1}
Clojure:
(binding [*print-dup* true]
(prn (sorted-map :foo 1)))
; #=(clojure.lang.PersistentTreeMap/create {:foo 1})
https://stackoverflow.com/questions/17347836/savingreading-sorted-maps-to-a-file-in-clojureWhy does (def blah [range 10]) have a length of 1 and (defn blah (range 10)) gives you 10 values? I understand that range is a lazy seq so it’s only going to give you what’s necessary. Just wondering it wouldn’t give you the full range in a vector…
[range 10]
is a literal vector with the function range
and the number 10 (should have a count of 2)
if you want a vector with the contents of the range, you could do (vec (range 10))
Inspired by yesterday’s discussion about str/join, I wrote a spec for it: https://github.com/borkdude/speculative/blob/master/src/speculative/string.cljc#L8
cljs.user=> (require '[clojure.pprint :refer [pprint]])
nil
cljs.user=> (with-out-str (pprint {:a {:b {:c 1}}}))
"{:a {:b {:c 1}}}\n"
cljs.user=> (with-out-str (pprint (range 100)))
"(0\n 1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n 10\n 11\n 12\n 13\n 14\n 15\n 16\n 17\n 18\n 19\n 20\n 21\n 22\n 23\n 24\n 25\n 26\n 27\n 28\n 29\n 30\n 31\n 32\n 33\n 34\n 35\n 36\n 37\n 38\n 39\n 40\n 41\n 42\n 43\n 44\n 45\n 46\n 47\n 48\n 49\n 50\n 51\n 52\n 53\n 54\n 55\n 56\n 57\n 58\n 59\n 60\n 61\n 62\n 63\n 64\n 65\n 66\n 67\n 68\n 69\n 70\n 71\n 72\n 73\n 74\n 75\n 76\n 77 \n 78 \n 79 \n 80 \n 81 \n 82 \n 83 \n 84 \n 85 \n 86 \n 87 \n 88 \n 89 \n 90 \n 91 \n 92 \n 93 \n 94 \n 95 \n 96 \n 97 \n 98 \n 99)\n"
Hello!
are there any blogs/resources for working with huge files of different types?
I am getting byteArrayInputStream
and need to convert it to /tmp
and i use
for that.
But when files get bigger that function is stuck until file is processed i tried future
and (.start (Thread. #(io/copy..)))
but without luck
i was also thinking about implementing atom which will hold if io/copy
is done.
I need anything to just deal and work with files that are not edn/string based cause that's all i am finding on google
do you need the whole file to exist on disk? if you use a thread or future you shouldn't end up blocking the parent thread unless you attempt to deref or join
you can use realized?
to check if a future has completed
@U051SS2EU sorry maybe i should've explained myself bit more
i will receive reference to ByteArrayInputStream
and my job is to save it to a disk using as minimal amount of RAM/heap as possible.
Those input streams might be few GBs big and they can't be realized or fully in memory.
Is there a way to process this stream (or any kind of stream) 'lazily' (for the lack of better word) or in cunks.
I want first 50mb > save to disk >
second 50mb > save to disk
until stream is empty
This way i would use 50mb of ram per 'save'
a read/write loop would do this, but that is what io/copy should be doing internally
I have some source code examples with a deps.edn
file in the root. IJ Idea can't import it. What do I need to do? Convert it to a Leiningen project somehow?
Hey all, is there an intuitive formatting that you guys use?
ps I know SPC m f b
in Spacemacs formats the code, but I find the format hard to read
@ali.ebadian What do you find hard to read about that default formatting? And what would make it more readable for you?
Most people (and most tooling) follows this community style guide https://github.com/bbatsov/clojure-style-guide
hi all, quick question: i’m going through Lacinia’s tutorial (for working with graphQL), and I came across this let
structure that’s a bit confusing:
(defn resolver-map
[]
(let [cgg-data (-> (io/resource "cgg-data.edn")
slurp
edn/read-string)
games-map (->> cgg-data
:games
(reduce #(assoc %1 (:id %2) %2) {}))]
{:query/game-by-id (partial resolve-game-by-id games-map)}))
the part i’m confused by is the map that’s returned: i’m 90% sure the goal is to define a function in the :query
namespace, but why would that be done inside a map?
instead of, say, (defn :query/game-by-id (...))
that's an illegal defn
The hash map is a key and a value, where the value is a function. If new functions are created / looked up at app runtime, it's appropriate to use a hash for lookup instead of creating new defs at runtime
it's not defining a function in a namespace. its returning a map with the key :query/game-by-id
whose value is a function
oh right duh
thanks
so that hash map would be defined “globally” i.e. outside the let, right?
it's returned by the resolver-map function, it doesn't create anything at global or even namespace scope
ok, got it
thank you
hah thanks… i’ve been using it since i was like 13 playing counterstrike, which is embarrassing for all kinds of reasons