This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-02-12
Channels
- # aatree (9)
- # admin-announcements (2)
- # alda (4)
- # announcements (2)
- # beginners (87)
- # boot (218)
- # braid-chat (14)
- # cbus (2)
- # cider (19)
- # cljs-dev (17)
- # cljsjs (1)
- # cljsrn (5)
- # clojure (84)
- # clojure-android (1)
- # clojure-czech (8)
- # clojure-ireland (3)
- # clojure-madison (20)
- # clojure-poland (22)
- # clojure-russia (54)
- # clojure-sanfrancisco (1)
- # clojurescript (81)
- # clojurewest (4)
- # community-development (94)
- # conf-proposals (5)
- # core-async (199)
- # css (3)
- # cursive (68)
- # datavis (2)
- # datomic (23)
- # dysphemism (138)
- # editors (7)
- # hoplon (8)
- # jobs (8)
- # jobs-discuss (7)
- # ldnclj (2)
- # liberator (6)
- # off-topic (32)
- # om (200)
- # omnext (2)
- # onyx (88)
- # proton (58)
- # re-frame (14)
- # reagent (1)
- # ring-swagger (26)
- # yada (14)
When I was first going through those, I followed some folks and tried to learn from the solutions
But it seems that a lot of folks try for very, very terse answers (some kind of code golf, maybe?) which are hard to learn from
@bridget: I felt the same way when I tried to do those. Didn't get very far because of that.
And not to say there isn't any value in the terse answers. There are things you can pick up from those, too
Don't look too closely at any of my github history. I like to just dive in and create a big mess that barely works and then rework it over and over and over and, oh my why can't I wake up just once without realizing my code still sucks until I finally just give up and declare it good enough.
I'm so glad Slack lets you edit recent posts. So many typos! Can't type for shit half the time. 😉
@drewverlee: follow chouser
Darn his are good
@alexmiller, thanks I'll be sure to follow him!! Someone should make a opinionated list of ppl to follow for beginners.
i struggling with raw sql queries in Korma
i do appreciate any help
@olegakbarov: Might not be helpful, but is there a particular reason to use Korma over just doing the raw query using clojure.java.jdbc?
i don’t know actually
i was working with korma and stumbled this problem with upsert
i think i’ll give a try clojure.java.jdbc
if nothing will work with korma
I'm sure korma has areas where it really shines (I've not tried it), but when I want to do raw queries I've found clojure.java.jdbc to be really solid. I've tried a bunch of the other SQL libraries and not found one I like better for raw sql.
excuse me (complete noob in both Clojure and SQL) but what method might for my case?
insert!
is what you want
There's an example of using it on https://github.com/clojure/java.jdbc
thank you, i’ll give it a try
Your query should be something like this
(jdbc/insert! db-spec ["INSERT INTO events ?, VALUES ? ON CONFLICT (id) DO UPDATE SET title = EXCLUDED.title" events values] )
I think
thank you! 🙌
jdbc/insert!
takes hashmaps to insert which represent rows; jdbc/execute!
will accept SQL for arbitrary updates.
Community-maintained docs for java.jdbc are here http://clojure-doc.org/articles/ecosystem/java_jdbc/home.html#manipulating-data-with-sql
(disclaimer: I maintain clojure.java.jdbc and so far I’ve been the main contributor to the community docs as well)
i was using pmap
to make applying a function to a collection parallel which is really handy
(defn boolseq-> [boolseq things]
(->> (map (fn [b r] (when b r)) boolseq things)
(filter identity)))
(defn ->boolseq [coll things]
(map (fn [n] (some #(= (nth things n) %) coll))
(range (count things))))
There must be a cleaner way to do this...(defn ->boolseq [coll things]
(map (fn [t] (some #(= t %) coll)) things))
This works, apparentlyWhat exactly is it trying to do @polymeris ?
convert from a seq like [true true false false true]
to ["a" "b" "e"]
, given a list of things ["a" "b" "c" "d" "e"]
@chadhs: pmap
is a bit of a sledgehammer — it doesn’t give you any knobs to control the behavior. You need to drop down to lower-level (Java) stuff to really control the threads I think…? Maybe fold
in the reducers library provides more control… trying to think…
@polymeris: So the seq of booleans and the things collection are the same length?
@seancorfield: perhaps a better way to ask my question is… is there a simple way to n operations x at a time?
@seancorfield: Thanks for clojure.java.jdbc btw, I really like it
maybe I should convert the coll into a set first, then use contains?
instead of some
@chadhs: not really a simple way, no…
@polymeris: Is the seq of things always a unique collection (i.e., every item different)?
@seancorfield: do i need to think about my approach perhaps and looking at core.async and maybe putting commands on channels
Have a look at http://clojure.github.io/clojure/clojure.core-api.html#clojure.core.reducers/fold @chadhs and see if reducers would help you...
That at least lets you specify your partition size...
@polymeris: I think my gut would be to zip the two collection and then run keep
over the result to ensure they matched up positionally… (keep (fn [[yes? value]] (when yes? value)) (map vector coll things))
maybe?
Hi everyone! I’m fairly new to Clojure and brand new to the Clojure community. In particular, I’ve been dipping a toe into Clojurescript and Om Next (I’ve got a lot of experience with vanilla React). Is this a good place to ask fairly beginner questions? (I’m making a leap based on the channel name.)
Not quite, it keeps a sequence that is the result of applying the predicate, not the elements of the original sequence.
But (filter identity (map #(when %1 %2) coll things))
would also work I believe?
i.e., make the map
produce either nil
or the corresponding value from things
@adampash: Welcome!!
Yep, beginner questions are welcome here and there are also #C03S1L9DN and #C0DT1AZD3 channels too.
Oh cool. My questions are mostly focused on using cljsjs packages in om next—does that seem better suited for #C0DT1AZD3?
thanks @seancorfield
@adampash: Sorry, had to step away. I looked in #C0DT1AZD3 (I’m not a member) and it looks like #C06DT2YSY is actually where all Om / Om Next chatter happens (I’m not a member of #C06DT2YSY either).
I haven’t touched ClojureScript for about a year at this point and it’s a space that moves pretty fast — and although we built a p.o.c. with Om at work, we then rebuilt it with Reagent, even tho’ we eventually abandoned that project altogether — so I think all my cljs knowledge is way out of date at this point 😞
I'm building a fairly basic web scraper, my first. I'm trying to figure out how to submit cookies properly, so I'm authenticated. The Ring resources I found address how to set cookies for users, not so much how to get and send cookies. I copied the cookie from my browser and tried to encode it as a header, but no love. Any ideas?
For instance, this didn't work:
(add-query-params ""
{:throw-exceptions true
:headers {"Cookie" "cookie-from-browser-here"}})
Ring is library for helping build web servers. A web scraper requires the services of a web client. If you’re using clj-http, as is the most common choice, you’ll want to look at: https://github.com/dakrone/clj-http#cookies
@donaldball: thanks! i saw clj-http but not the cookies section - I'll give that a shot