workspace
stringclasses 4
values | channel
stringclasses 4
values | text
stringlengths 1
3.93k
| ts
stringlengths 26
26
| user
stringlengths 2
11
|
---|---|---|---|---|
clojurians
|
clojure
|
why is there no pop-n! and peek-n (for pop! peek associated with vector)
|
2017-12-21T07:38:11.000026
|
Berry
|
clojurians
|
clojure
|
<@Jodie> if by versioned we mean versioning the install script itself, seems that it already is at <https://clojure.org/guides/getting_started>, but maybe I'm missing your point
|
2017-12-21T08:06:10.000102
|
Joette
|
clojurians
|
clojure
|
I mean is it in a version controlled repo
|
2017-12-21T08:07:08.000154
|
Jodie
|
clojurians
|
clojure
|
<@Jodie> it seems (at least from this cursory check) to live in the <https://github.com/clojure/brew-install> repo under `src/main/resources/linux-install.sh` and be versioned using the script under `<https://github.com/clojure/brew-install/blob/master/script/package.sh>`, which on the last line says:
```
aws s3 cp --only-show-errors "target/classes/linux-install.sh" "$S3_BUCKET/install/linux-install-$version.sh"
```
|
2017-12-21T08:19:12.000200
|
Joette
|
clojurians
|
clojure
|
where on the `1.9.0` branch in that git repo, the maven pom.xml says `<version>1.9.0.275</version>` and looking at git history we can see that the version was changed to 275 from 273 on dec 8 and 273 is what we see on the site
|
2017-12-21T08:22:26.000226
|
Joette
|
clojurians
|
clojure
|
is there a shorter way to write:
```
(fn [stack & lst]
(reduce #(%2 %1) stack lst))
```
|
2017-12-21T08:25:36.000023
|
Berry
|
clojurians
|
clojure
|
not 100% sure what it’s supposed to do, but `((apply comp lst) stack)`?
|
2017-12-21T08:28:21.000051
|
Xavier
|
clojurians
|
clojure
|
or `((apply comp (reverse lst)) stack)` I suppose
|
2017-12-21T08:29:03.000048
|
Xavier
|
clojurians
|
clojure
|
<@Berry> what is that function supposed to do? if the incoming stack is in fact a list that we are just treating like a stack and all you are doing is adding all the elements from one list to another (the stack) then you could as well just return `lst` or potentially `(reverse lst)`. But I get the feeling we are missing your point
|
2017-12-21T08:37:53.000319
|
Joette
|
clojurians
|
clojure
|
Great find :+1: Thanks. Looks like the two are versioned together.
|
2017-12-21T08:42:20.000033
|
Jodie
|
clojurians
|
clojure
|
oh sorry, let me rewrite that as
|
2017-12-21T08:44:58.000225
|
Berry
|
clojurians
|
clojure
|
```
(fn [obj & list-of-fns]
(reduce #(%2 %1) obj list-of-fns))
```
|
2017-12-21T08:45:20.000164
|
Berry
|
clojurians
|
clojure
|
so there is an object, there is a list of functions, we want to apply it one by one, so
(magic obj f1 f2 f3 f4 f5) --> (f5 (f4 (f3 (f2 (f1 obj)))))
|
2017-12-21T08:45:45.000222
|
Berry
|
clojurians
|
clojure
|
I'm writing a simple forth interpreter
|
2017-12-21T08:45:57.000050
|
Berry
|
clojurians
|
clojure
|
the object here = stack, and the list-of-fns = words
|
2017-12-21T08:46:06.000371
|
Berry
|
clojurians
|
clojure
|
<http://clojuredocs.org/clojure.core/comp>
|
2017-12-21T08:50:20.000366
|
Xavier
|
clojurians
|
clojure
|
<@Xavier> :slightly_smiling_face:
|
2017-12-21T08:50:59.000133
|
Joette
|
clojurians
|
clojure
|
wrt your question earlier
<https://clojurians.slack.com/archives/C03S1KBA2/p1513859891000026>
it’s highly inefficient since it involves copying
|
2017-12-21T08:51:55.000366
|
Xavier
|
clojurians
|
clojure
|
if possible, try to reframe the problem so that you can use first/last for vectors or first for lists
|
2017-12-21T08:52:57.000587
|
Xavier
|
clojurians
|
clojure
|
often, a hash-map is also a better choice
|
2017-12-21T08:53:10.000263
|
Xavier
|
clojurians
|
clojure
|
<@Berry> Oh now you’re making me jealous, I’ve always wanted to write my own Forth interpreter.
|
2017-12-21T08:56:37.000463
|
Marx
|
clojurians
|
clojure
|
Forth in Lisp. And Lisp in Forth.
|
2017-12-21T08:58:34.000507
|
Shantae
|
clojurians
|
clojure
|
> Forth: the original bare-metal REPL
|
2017-12-21T09:00:24.000729
|
Shantae
|
clojurians
|
clojure
|
I should never have sold my C64.
|
2017-12-21T09:08:12.000418
|
Marx
|
clojurians
|
clojure
|
<@Marx> I'm sure there's cycle accurate C64 emulator out there now :smile:
|
2017-12-21T11:12:31.000164
|
Sandy
|
clojurians
|
clojure
|
I’m trying to pretend I don’t know that. :wink:
|
2017-12-21T11:13:10.000449
|
Marx
|
clojurians
|
clojure
|
does anyone here have any experience using clj-http with cookies on an HTTP/POST? I’m trying to convert a request over from using [http.async.client “1.2.0”] to clj-http
|
2017-12-21T11:37:32.000599
|
Candace
|
clojurians
|
clojure
|
<@Candace> are you experiencing issues? what version of clj-http are you using (hopefully latest version: 3.7.0)?
|
2017-12-21T12:14:46.000402
|
Danielle
|
clojurians
|
clojure
|
<@Danielle> I just got it to work. I am on 3.7.0. I was trying to pass the cookies map the previous authentication request returned into the `:cookies` value of the POST map. For whatever reason it wasn’t worker. Passing the raw cookie string to the :headers map worked though
|
2017-12-21T12:57:26.000230
|
Candace
|
clojurians
|
clojure
|
I was under the impression you could pass the :cookies map around
|
2017-12-21T12:57:47.000156
|
Candace
|
clojurians
|
clojure
|
was just doing an auth, getting that cookies map and sending it in the subsequent POST
|
2017-12-21T12:58:16.000494
|
Candace
|
clojurians
|
clojure
|
<@Candace> you should be able to pass the `:cookies` map directly, I have some code around that does that
|
2017-12-21T13:14:34.000041
|
Noella
|
clojurians
|
clojure
|
Hi all :slightly_smiling_face:
|
2017-12-21T14:11:01.000078
|
Clara
|
clojurians
|
clojure
|
i need a bit of advice , i'm pretty sure someone has solved my issue already but i seem have trouble finding it. I need a persistent map that is stored on disk and doesn't require me to read it all into memory to read it.
|
2017-12-21T14:12:07.000193
|
Clara
|
clojurians
|
clojure
|
sure i could do all sorts of h2 or hsqldb sort of trickery but i really would rather not :disappointed:
|
2017-12-21T14:12:30.000685
|
Clara
|
clojurians
|
clojure
|
the reason why i don't want to read all into memory at once is that it just won't fit, amount of data is way bigger than the ram that i have available
|
2017-12-21T14:13:17.000081
|
Clara
|
clojurians
|
clojure
|
Maybe use Datomic Free version? (Or the free Datomic Pro?)
|
2017-12-21T14:17:33.000202
|
Heide
|
clojurians
|
clojure
|
datomic seems pretty complex for my needs :slightly_smiling_face:
|
2017-12-21T14:21:24.000119
|
Clara
|
clojurians
|
clojure
|
isn’t what you need just a database?
|
2017-12-21T14:22:04.000278
|
Margaret
|
clojurians
|
clojure
|
yes but the definition of a database is a rather wide one
|
2017-12-21T14:22:52.000063
|
Clara
|
clojurians
|
clojure
|
maybe just sqlite or something? Sounds like that might be adequate, depending on just how big we’re talking here
|
2017-12-21T14:23:11.000281
|
Marx
|
clojurians
|
clojure
|
OK just saying what you describe so far is something any database worthy of the name does
|
2017-12-21T14:23:16.000273
|
Margaret
|
clojurians
|
clojure
|
i manage apps that run on postgresql clusters of hundreds of gigabytes every day at work , and yeah sure that's all fine and i know how they work ... but my needs here are way different
|
2017-12-21T14:23:25.000246
|
Clara
|
clojurians
|
clojure
|
Well…. that depends on the keys <@Clara> is using: could be objects, vectors, etc.
|
2017-12-21T14:23:43.000224
|
Heide
|
clojurians
|
clojure
|
OK no database (or nearly none) supports all the types clojure allows in hash map keys
|
2017-12-21T14:24:06.000553
|
Margaret
|
clojurians
|
clojure
|
You'll have to write it starting from those examples:
<http://vanillajava.blogspot.com/2011/12/using-memory-mapped-file-for-huge.html>
<https://github.com/ashkrit/blog/tree/master/src/main/java/bigarraylist>
|
2017-12-21T14:24:12.000413
|
Heriberto
|
clojurians
|
clojure
|
if you have a decade to spare you could make a new database sure
|
2017-12-21T14:24:38.000530
|
Margaret
|
clojurians
|
clojure
|
i usually despise orms and simplifications but this time it is exactly what i'm looking for, just a memory optimized storage for hash maps , which in turn have just lists of strings as values and strings as keys
|
2017-12-21T14:24:44.000506
|
Clara
|
clojurians
|
clojure
|
something in the berkeleydb or mapdb territory
|
2017-12-21T14:24:57.000252
|
Clara
|
clojurians
|
clojure
|
Why database? Most likely only one map type is needed.
|
2017-12-21T14:25:08.000610
|
Heriberto
|
clojurians
|
clojure
|
mapdb seems to be the way to go
|
2017-12-21T14:25:52.000238
|
Heriberto
|
clojurians
|
clojure
|
<@Clara> Maybe you van use the H2 MVStore? <http://www.h2database.com/html/mvstore.html>
|
2017-12-21T14:25:56.000513
|
Daine
|
clojurians
|
clojure
|
<@Heriberto> because most people want insertion to be reliable and persistent and failures to be handled in a sane manner and multiple clients to be able to access it without breaking everything etc. and before you know it either you have something that doesn’t work at all, or a database
|
2017-12-21T14:26:07.000044
|
Margaret
|
clojurians
|
clojure
|
I’m not talking about query models or relations or anything here - you don’t need those to be a db
|
2017-12-21T14:27:17.000343
|
Margaret
|
clojurians
|
clojure
|
MVStore is easy to use, but I moved to Redis, since I needed access from multiple jvm's. Also easy, but needs a separate process.
|
2017-12-21T14:30:17.000291
|
Daine
|
clojurians
|
clojure
|
but wasn't the case with redis that whatever you store there, even if backed on disk, needs to fit in ram ?
|
2017-12-21T14:31:49.000011
|
Clara
|
clojurians
|
clojure
|
h2 is a strong candidate on my checklist so far though
|
2017-12-21T14:32:21.000431
|
Clara
|
clojurians
|
clojure
|
Yes, that's true, so for this case it doesn't work
|
2017-12-21T14:33:01.000167
|
Daine
|
clojurians
|
clojure
|
thanks for the suggestions, i will break my thumbs a little bit on testing approaches out
|
2017-12-21T14:36:00.000144
|
Clara
|
clojurians
|
clojure
|
<@Marx> <@Berry> this is my favorite lisp/forth story: <http://www.flownet.com/gat/jpl-lisp.html> (starting with “Also in 1993 I used MCL to help generate a code patch for the Gallileo magnetometer…“)
|
2017-12-21T14:44:42.000195
|
Alline
|
clojurians
|
clojure
|
Nice :wink:
|
2017-12-21T14:45:37.000016
|
Marx
|
clojurians
|
clojure
|
more detail at <https://news.ycombinator.com/item?id=12037548>
|
2017-12-21T14:46:47.000646
|
Alline
|
clojurians
|
clojure
|
```
(try
(throw
(ex-info "foo" {:bar "barrr"}))
(catch Exception e
(ex-data e)))
```
vs
```
(try
(throw
(ex-info "foo" {:bar "barrr"} {:baz "baaz"}))
(catch Exception e
(ex-data e)))
```
Second example return nil.
First example is `clojure.lang.ExceptionInfo` while second is `java.lang.ClassCastException`.
How do you read Expection in consistent way to get always `([msg map cause]` from `ex-info`?
On the end i need it to create `fingerprint` for sentry, which is unique data to identify group of errors.
```
(when (or error-message (force msg_))
(->> [?ns-str error-message (force msg_)]
(remove #(= "" %))
(remove nil?)))
```
So i want add here additional `cause` to make smaller group of errors to easier debug issues.
So on the end i want call:
```
(throw
(ex-info "service X API" {:error-info "bla bla" {:cause {:timeout :foo}}))
```
^ or maybe last param could be a vector [:timeout :foo]
or just in some cases
```
(throw
(ex-info "service X API" {:error-info "bla bla"))
```
In logs i want make from that right `fingerprint` for sentry to group this errors.
How to get `ex-data` and `cause` from `ex-info`. When third parameter `cause` is present in `ex-info` it returns different instance and it doesn’t work so simple.
|
2017-12-21T15:12:02.000166
|
Gladys
|
clojurians
|
clojure
|
wooo… too long. sorry, but wanted well describe it
|
2017-12-21T15:12:17.000403
|
Gladys
|
clojurians
|
clojure
|
PS `[?ns-str error-message (force msg_)]` this part is from timbre envents
|
2017-12-21T15:13:52.000100
|
Gladys
|
clojurians
|
clojure
|
```(ins)user=> (ex-info "" {} {})
ClassCastException clojure.lang.PersistentArrayMap cannot be cast to java.lang.Throwable clojure.core/ex-info (core.clj:4739)``` the ClassCastException is because you used ex-info wrong, and you get the thrown ClassCastException instead of the other one you were catching
|
2017-12-21T15:14:46.000266
|
Margaret
|
clojurians
|
clojure
|
the third arg if present needs to be a throwable
|
2017-12-21T15:14:55.000149
|
Margaret
|
clojurians
|
clojure
|
it’s not that ex-info is returning a different type, it’s throwing instead of returning
|
2017-12-21T15:17:44.000604
|
Margaret
|
clojurians
|
clojure
|
oh…. thanks.
|
2017-12-21T15:17:52.000589
|
Gladys
|
clojurians
|
clojure
|
the design is that `cause` if present would be another exception (the one you caught originally in theory)
|
2017-12-21T15:18:25.000086
|
Margaret
|
clojurians
|
clojure
|
I throw this exceptions myself, so…. hmm maybe I shouldn’t use `cause` in that case.
|
2017-12-21T15:19:58.000053
|
Gladys
|
clojurians
|
clojure
|
Do you know some good practice how can i make `fingerprint` to group exceptions?
|
2017-12-21T15:20:29.000021
|
Gladys
|
clojurians
|
clojure
|
It would be grate to don’t have timeout issue from third part service etc. in the same group like others important errors
|
2017-12-21T15:21:14.000507
|
Gladys
|
clojurians
|
clojure
|
For now only one solution what i see is change `"service X API"` in `ex-info` but i don’t like it to much
```
(throw
(ex-info "service X API" error-info))
```
|
2017-12-21T15:23:16.000355
|
Gladys
|
clojurians
|
clojure
|
is there any plan to make `(> \b \a)` to ever return true ?
|
2017-12-21T15:23:49.000074
|
Berry
|
clojurians
|
clojure
|
```
(when sentry-dsn
(l/debug "sentry-dsn: " sentry-dsn)
(sentry/init! sentry-dsn)
(timbre/merge-config!
{:appenders
{:sentry
{:enabled? true
:async? true
:min-level :debug
:rate-limit nil
:output-fn :inherit
:fn (fn [{:keys [level ?err msg_ ?ns-str context]}]
(let [error-message (some-> ?err (.getLocalizedMessage))]
(sentry/send-event (merge sentry-base
{:level (get timbre->sentry-levels level)
:fingerprint (when (or error-message (force msg_))
(->> [?ns-str error-message (force msg_)]
(remove #(= "" %))
(remove nil?)))
:logger ?ns-str
:extra context
:message (not-empty (force msg_))
:throwable ?err}))))}}}))
```
^ here is the point how I use timbre events
|
2017-12-21T15:24:10.000384
|
Gladys
|
clojurians
|
clojure
|
<@Berry> by redefining clojure.core/> or shadowing it
|
2017-12-21T15:24:13.000209
|
Margaret
|
clojurians
|
clojure
|
ach it looks so ugly in thread
|
2017-12-21T15:24:20.000224
|
Gladys
|
clojurians
|
clojure
|
<https://pastebin.com/SEsWfji5>
|
2017-12-21T15:24:39.000126
|
Gladys
|
clojurians
|
clojure
|
oh sorry I misread - no, no plan for that
|
2017-12-21T15:25:29.000450
|
Margaret
|
clojurians
|
clojure
|
<@Berry> (clojure.core/compare \b \a) returns 1. That might be useful to you.
|
2017-12-21T15:25:32.000335
|
Micha
|
clojurians
|
clojure
|
<@Berry> the clojure numeric operators will not be made generic / extensible beyond working on `Number`
|
2017-12-21T15:26:09.000246
|
Margaret
|
clojurians
|
clojure
|
I currently have new functions `c>` and `c<` for char
|
2017-12-21T15:26:09.000377
|
Berry
|
clojurians
|
clojure
|
hmm alternatively I can use `:causes` from `ex-info` `map` always as some kind of agreement.
|
2017-12-21T15:30:02.000092
|
Gladys
|
clojurians
|
clojure
|
Here's a Joy DSL I'm working on. Feedback/criticism welcome:
```
(defn fnj-raw [args body] `(fn [ss#] (let [[ss# ~args] (vsr ss# ~(count args))]
(vrc ss# (do ~@body)))))
(defmacro fnj [args & body] (fnjp-raw args body))
(def joy (fn [stack & lst] (reduce #(%2 %1) stack lst)))
(def joy1 #(first (apply joy [%1] %2)))
(def jw (fn [& lst] #(apply joy % lst)))
(def jdup (fnj [x] [x x]))
(def j+ (fnj [x y] [(+ x y)]))
(def j- (fnj [x y] [(- x y)]))
(def j* (fnj [x y] [(* x y)]))
(def jp (fn [x] (fnj [] [x])))
(def jcct (ffnj [x y] [(concat x y)]))
(def js2 (jw jdup j*))
(def jfilter (fnj [lst ws] [(filter #(joy1 % ws) lst)]))
(def jmap (fnj [lst ws] [(map #(joy1 % ws) lst)]))
(def jc> (fnj [x y] [(c> x y)]))
(joy ["John Smith"] (jp [(jp \Z) jc>]) jfilter)
#_ (def ji (fn [lst] #(apply joy % lst)))
#_ (joy [1 2] (jp (ji [j+ (jp 20) j* (jp 10) (jp 4) j-])) ji)
(joy [2] js2)
(joy [] (jp 2) (jp 3) j+ jdup j*)
(joy [] (jp [1 2 3 4]) (jp [jdup j*]) jmap)
```
|
2017-12-21T15:46:46.000223
|
Berry
|
clojurians
|
clojure
|
<@Clara> a random idea that popped into my head: maybe <http://rocksdb.org/> + <https://github.com/ptaoussanis/nippy>?
|
2017-12-21T15:57:41.000251
|
Noella
|
clojurians
|
clojure
|
you don’t even need nippy for string/string right?
|
2017-12-21T16:04:53.000082
|
Margaret
|
clojurians
|
clojure
|
nope :slightly_smiling_face:
|
2017-12-21T16:13:16.000274
|
Noella
|
clojurians
|
clojure
|
is there a clojure data structure that gives amortized O(1) pop/peek, and O(1) concat ?
|
2017-12-21T17:12:52.000268
|
Berry
|
clojurians
|
clojure
|
<@Berry> If you don't need it to be eager, `concat` is already going to be O(1), right? :slightly_smiling_face:
|
2017-12-21T17:16:23.000029
|
Daniell
|
clojurians
|
clojure
|
So a list would be O(1) pop, peek, and (lazy) concat but you trade off O(n) on other operations...
|
2017-12-21T17:18:19.000251
|
Daniell
|
clojurians
|
clojure
|
If what you're `concat`ing is always small, a vector is going to be reasonable: O(1) for pop, peek (off the end) and `(into vec1 vec2)` will be O(n) for the size of `vec2`... and you still have O(1) access to other elements...
|
2017-12-21T17:20:26.000437
|
Daniell
|
clojurians
|
clojure
|
(I think -- happy for someone to confirm / deny my thinking there!)
|
2017-12-21T17:20:47.000172
|
Daniell
|
clojurians
|
clojure
|
<@Berry> RRB vectors gives amortized O(1) pop/peek, and O(log n) concat: <https://github.com/clojure/core.rrb-vector>
|
2017-12-21T17:29:28.000081
|
Micha
|
clojurians
|
clojure
|
or maybe it is O((log n)^2) concat -- been a while since I looked at the details. Anyway, significantly less than O(n)
|
2017-12-21T17:30:01.000002
|
Micha
|
clojurians
|
clojure
|
<@Daniell> <@Micha>: theXY problem is that I am implementing an 'instruction stack'
most of the time, it's just pop and peek, but occasionally, I need to push a buch of ops to the front of it
|
2017-12-21T17:39:08.000209
|
Berry
|
clojurians
|
clojure
|
sounds like you want `clojure.lang.PersistentQueue/EMPTY`
|
2017-12-21T17:39:47.000139
|
Margaret
|
clojurians
|
clojure
|
no, queue are fifo, I need lifo
|
2017-12-21T17:39:55.000281
|
Berry
|
clojurians
|
clojure
|
conj to the front peek/pop from back
|
2017-12-21T17:40:00.000057
|
Margaret
|
clojurians
|
clojure
|
OK
|
2017-12-21T17:40:03.000032
|
Margaret
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.