Fork me on GitHub
#clojure
<
2016-03-13
>
futuro00:03:21

I have a key/value pair and I'm trying to see if the value is one of :foo :bar or :baz; does anyone know of a concise way of doing this, or will I need to use a bunch of condp/if statements?

bwstearns00:03:17

@futuro: you have like (def baz {:foo 1 :bar 2}) and you want to see if value v is equal to the value for either :foo or :bar?

bwstearns01:03:43

(contains? baz :foo)

bwstearns01:03:56

or like (contains? (into [] (keys baz)) 1)

futuro01:03:38

@bwstearns: ah, contains is partially it

futuro01:03:58

I have a function that gets passed in a map and I want to see if the map has a particular value at the same key

futuro01:03:35

so it could be {:event :foo} or {:event :bar} or {:event :baz}, and I want to do something if the value for :event is either :foo or :bar

bwstearns01:03:49

@futuro: oh ok, so like (fn [my-map] contains? #{:foo :bar} (get my-map :event))

futuro01:03:51

That makes so much sense now that I see it; thank you.

bwstearns03:03:50

If anyone can help me out I posted a question over in beginners https://clojurians.slack.com/archives/beginners/p1457840985000009

vmarcinko12:03:27

hey guys, just wondering - is new REPL server available in clojure 1.8 practically built-in equivalent for nREPL?

danielstockton14:03:26

@stuartsierra How does one make sure it doesn't affect tests or get loaded in production?

danielstockton14:03:32

Presumably lein uberjar would be OK, if i specify the right :main namespace. Still struggling with getting lein test to find my tests.

danielstockton14:03:53

lein test -> lein test user - 0 tests found, 0 tests run

weavejester15:03:20

danielstockton: Are you using .cljc tests with an older version of Lein?

danielstockton15:03:51

Nope, plain .clj and lein should be the latest

weavejester15:03:41

And your test files are in the “test” directory? You haven’t changed the test-paths in Lein?

danielstockton15:03:00

nope, where they got generated

danielstockton15:03:24

only difference is adding /dev to source paths on the :dev profile and creating a user.clj user namespace

sveri21:03:55

Hi, I am using joplin for database migrations (which relies on ragtime IIRC). Now I am trying to migrate a postgres table. My up.sql file also contains an additional INSERT statement for some base data. So far everything is working. But when I try to insert a statement into that table I get an error about a duplicate primary key. After some research I figured out that joplin somehow does not set the primary key counter after the insert statement for some reason. I am not sure about the internals, but when I execute: SELECT setval('answer_id_seq', 1); on the table I can perfectly insert afterwards. Now I wanted to execute SELECT setval('answer_id_seq', 1); as part of the migration, but that is not working either, throwing another pgsqlException: Statement returned a result, but none was expected. Any ideas how to fix that?

talios22:03:35

cky: fancy finding you here simple_smile

cky22:03:20

@talios: Yeah, I decided to learn ClojureScript because of all the awesome React-based frameworks (I ended up choosing Reagent+re-frame, with no regrets).

cky22:03:44

@talios: But, good to see you here finally! You should liven up #C0FCN8L1Y; it’s kind of quiet in there. 😛

talios22:03:05

Nice. Seems our webguys are still considering Om-next and whatnot.

talios22:03:37

@cky: well I heard people were talking about me in here so I thought I just HAD to grace my fans with a visit 😜

cky22:03:50

Yes, I was one of those people talking about you, lol. 😛

talios22:03:32

“I knew him before he was famous” simple_smile I could say the same of you 😜 hah

cky22:03:02

Well, that’s easy to say, since I’m not famous. 😛

talios22:03:29

Your stack overflow/quora presence says otherwise

cky22:03:45

Hahahaha. Well, thanks. simple_smile

bpicolo22:03:38

Anybody know some good guides/tutorials on best-practices for clojure for a newbie

cky22:03:06

Did someone just C-C-C-Combo-Break a conversation between two old acquaintances? 😛

cky22:03:05

@bpicolo: There are lots of awesome books on Clojure. One of my favourites is the Joy of Clojure. Can’t say anything about how well it works for newbies.

cky22:03:22

@talios: I can’t remember now, but did you work at SMX? Do you still work there now? I guess you have many fingers in many pies.

cky22:03:48

(In theory, I could just Google that information, but I’m in my own way trying to test my memory skills.)

talios22:03:25

@cky: surprisingly STILL at SMX.

talios22:03:42

I think this is now coming up 8 years? Maybe it’s time I bailed simple_smile

cky22:03:49

Hahahaha, nice.

cky22:03:23

I had a short stint at Stack Overflow last year, but this year I’m deciding to do my own thing. I hope it works out. We’ll see. simple_smile

talios22:03:29

But that’s quite scary - since I’ve only been in Auckland 20 years, so that’s almost half my Auckland life. here.

cky22:03:38

Wow, yeah, that’s a long time, for sure.

talios22:03:31

I’m working out my mid-life crisis being a rock concert photographer again tho - something I’ve done off and on over the last 15 odd years, but never to this level.

cky22:03:11

Oooh, life is definitely too short not to follow your dreams, so if you can do it in any way, now’s definitely a good time to do it. simple_smile

talios22:03:00

Yep - I got to shoot Madonna last week for her first ever NZ performance!

cky22:03:16

Oh wow, that’s very awesome. So do you sell the pictures, or how do you commercialise your work? Or is this more of a hobby?

cky22:03:10

This was the closest I ever got to “shooting” at a concert: https://www.instagram.com/p/lxF923kEJO/

cky22:03:32

I should move the convo to #C03RZGPG3. Oops.

bpicolo22:03:48

don't worry, taytay is always relevant

bpicolo22:03:02

I got to admit guys, Clojure is trying to dismantle everything I hold sacred

cky22:03:32

@bpicolo: And what are those sacred cows?

bpicolo22:03:54

I'm not even sure anymore. Clojure is actually pretty difficult to get used to coming from a heavy python webdev background

bpicolo22:03:56

but I am trying

cky22:03:21

Do blog about your current struggles. It will help other newcomers to functional programming and Clojure. simple_smile

bpicolo22:03:27

hah, perhaps

bpicolo22:03:35

I'm using primarily clojurescript

bpicolo22:03:53

Decided to do the backend in python for now primarily because I wanted at least something in my stack to not feel like a blocker : P

cky22:03:58

I got into Scheme back in 2002, and have been hugely into FP since then. It was only more recently that I started playing around with Clojure and ClojureScript, though. simple_smile

bpicolo22:03:08

also because I wasn't super satisfied with the database libs for clojure

cky22:03:22

Clojure + database = Datomic. 😛

bpicolo22:03:38

nah, sql is life

cky22:03:51

No, seriously, when I attended one of Cognitect (back then Relevance)’s talks on Datomic, I really, really loved it.

cky22:03:24

I have done a lot of SQL, and I still found Datomic’s concept out-of-the-world amazing.

cky22:03:24

Still, I’m not trying to convert you. I can understand how the SQL options for Clojure could be more limited when you compare with the likes of SQLAlchemy (I have not used it, but I have heard about it; also have not played with SQL libraries for Clojure so can’t say how well they do or not).

bpicolo22:03:37

Yeah. Sqlalchemy is fantastic

cky22:03:10

The closest thing to SQLAlchemy I’ve played with is Sequel (for Ruby), and I don’t know how the two compare.

bpicolo22:03:58

When working on semi-serious startupy things I try not to go toooo crazy with the stack, for obvious reasons haha

bpicolo22:03:12

I'll try datomic when I have a messaround thing : P

talios22:03:12

@cky: http://www.chaliceofblood.net/blog/2016/3/6/madonnas-rebel-heart-at-vector-arena - sadly no sales. and we don’t get paid either - do get free tickets to shows tho.

cky23:03:04

@talios: Nice, free tickets to Madonna is definitely worth it. simple_smile (Me, as a Taylor Swift fan (as you might have seen in the scrollback), wouldn’t mind a free ticket to Taylor Swift either. ;-)) I hope your love of concern photography does become something you can do full-time and make a living from.

talios23:03:30

Hah. Sadly no free ticket. We escorted in for the allotted 3 song shoot then escorted back to the doors of Vector. Most shows we we get to stay for the whole thing but Vector don't often give comps

cky23:03:15

Stingy bastards. 😛

talios23:03:59

Thankfully coding funds the camera habbit (mostly) but no one really pays for music photos. Musicians are hip like sports people. Tho it does open me up to other possible shoots

cky23:03:49

Hehehe re “mostly”. Well, hopefully you’ll find some awesome mixture of coding and photography that pays well and fuels your passion. 😄

cky23:03:16

I’m in the process of creating a platform for doing coding tutoring. I love coding and I love teaching, so that’s my way of blending the two. 😛

talios23:03:23

And doesnt kill me in the process. Shooting hard core punk is.... Dangerous

talios23:03:08

http://libel.co.nz/blog_posts/8698-gbh_photos that was a fun gig last week, but GBH isn't Grevious Bodily Harm for no reason!

talios23:03:47

Must publish the full set of those pics actually

cky23:03:53

Nice. simple_smile At least in New Zealand, you have ACC, so hopefully you’re covered on the grievous bodily harm front, lol.

cky23:03:05

Here in the US, there’s nothing like that. 😛

talios23:03:25

Where are you based these days?

cky23:03:32

I live in Raleigh, NC.

cky23:03:40

It’s actually right next to Durham, where Cognitect is based.

cky23:03:51

so there’s a healthy amount of Clojure meetups in this area.