Fork me on GitHub
#clojure-uk
<
2016-05-06
>
glenjamin07:05:50

> There was a young person in london > whose programs contained mostly functions > they wanted to know > the types that did flow > but in clojure it's all just assumption

glenjamin08:05:49

some poetic license with the first rhyme, but it works in my accent at least

dharrigan08:05:15

first pull request into a clojure library

otfrom09:05:47

dharrigan: cool. link? 😄

otfrom09:05:15

glad to see more going into buddy

dharrigan09:05:57

Could have added in the rest of the RIPEMD digests, but will see how this one goes first simple_smile

dharrigan09:05:11

What do people normally do for properties that are exterrnalised, but need to be "injected" at runtime? e.g., changing a URL from a development URL to a production URL?

benedek09:05:35

but i seen something like

(def some-url
  (if porduction?
     “prod-url”
     “dev-url”))
as well.

dharrigan09:05:56

Environ looks good (and simple!)

glenjamin09:05:47

i usually hide it behind a config namespace, just so I don’t have env var lookups all over the place

dharrigan10:05:09

that's a nice approach

dharrigan10:05:38

so like .... config/url and config/username where config is a namespace that pulls in the env stuff?

yogidevbear10:05:42

@glenjamin: Can you give an example?

glenjamin10:05:40

I do something like:

(ns myapp.config
    (:require [environ.core :refer [env]]))

(def config {:url1 (get env "URL" "default")
             :url2 (get-or-throw env "URL2")})

glenjamin10:05:13

and variations on that theme

glenjamin10:05:29

i think often I end up wrapping it in a delay so it’s not executed on startup

benedek10:05:45

can you elaborate on the delay? why do you need to do that?

glenjamin10:05:22

otherwise that code gets executed when you do lein compile or lein uberjar

glenjamin10:05:35

and because I like to hard-fail on startup when vital config is missing, it breaks

benedek10:05:47

ah right I see. the “hard-fail” was missing 😉

thomas12:05:05

The python community seems to be working on typed python: http://mypy-lang.blogspot.co.uk/2016/05/mypy-04-released.html

dharrigan14:05:35

Does anyone here use cheshire and clj-http (or a.n.other http client)?

dharrigan14:05:51

I was wondering, I'm coercing the response into a json map, and wondering if this is idomatic?

dharrigan14:05:00

(defn- coerce-response
  [response]
  (parse-string (:body response) #(keyword %)))

dharrigan14:05:30

the response is a json structure, but at that stage, just a string in the response from the server.

benedek14:05:57

i think you can just (parse-string “some-json-string” true) for keywords

dharrigan14:05:15

(I guess because that's a very common operation)

dharrigan14:05:26

bah, it's right there on the home page doc

benedek14:05:45

snake case vs dashed case (lisp case?!) is an interesting question too. you might want to banish snake case from the insides of your clojure application

dharrigan14:05:32

I don't have any snakes simple_smile

dharrigan14:05:47

I started writing camelCase, then that looked wrong simple_smile

dharrigan14:05:04

somehow, and don't get me wrong, dashed case reminds me of my cobol days simple_smile

otfrom14:05:31

CamelCase (but not camelCase) gets used for defining things like plumatic/schema things

minimal14:05:34

you can also do it all in clj-http (client/get "" {:as :json}) if you want

dharrigan14:05:02

even better if I can cut down on an operation

minimal14:05:28

still uses cheshire, so still fast

agile_geek15:05:36

CamelCase is used for defrecord and deftype too as they end up being Java classes or Javascript objects.

dharrigan15:05:12

@mccraigmccraig: I have a question following on from your presentation this week.

dharrigan15:05:21

Would you have a moment or two to talk at some point?

mccraigmccraig15:05:40

pm me, or in here is fine if you think others might be interested

dharrigan15:05:16

I'll dm you first, then once I've settled it in my mind, I can paste here simple_smile

dharrigan15:05:51

beer o'clock?

thomas15:05:33

just finished Clojure O’Clock…. and almost beer O’Clock!!!

thomas15:05:54

@agile_geek: my condolences… pom files suck big time IMHO.

thomas15:05:54

never had the opportunity to use Gradle… but it sounds like it is a very sensible thing to use.

agile_geek16:05:57

mixture of pom.xml hacks and groovy script/Jenkins DSL. Hugely complicated!

agile_geek16:05:35

mind it's better than being unable to touch any code except for gerrit reviewing for 10 months out of last 14!

dharrigan16:05:05

Oooh, I wouldn't say it's complicated. But surely, Maven is the pits of hell.

agile_geek16:05:33

No it's a very complex build pipeline that I've been changing and the dependencies in the pom's needed changing for over 30 projects none of which I have any knowledge of... just my lot atm.

dharrigan16:05:24

ah, it's maven that's complicated, gotcha

dharrigan16:05:54

I don't think I've ever succeeded in doing a build using maven that didn't fail at least once the first time it's run.

agile_geek16:05:09

I have but I start with very small project and first thing I do is build. Then I layer on complexity. It always breaks at some point of course.

agile_geek16:05:37

Issue is my current role means I don't get involved in the code but I get called in when something breaks or some complex re-engineering is required. This is the pits cos I never have context, and usually there's not even any tests to guide me.

agile_geek16:05:06

I just hope nobody on this channel banks with the bank I'm currently working for!

agile_geek18:05:22

Watching @dnolen presenting about Om.next on train atm https://www.youtube.com/watch?v=MDZpSIngwm4 second time I've watched this but few months in between and I'm beginning to see the advantages of the architectural approach.

djanus18:05:25

I used to work for a bank and think the same thing, now I wonder if it’s the same bank...

agile_geek19:05:03

@djanus: I suspect they are all the same!