Fork me on GitHub
#clojure-uk
<
2017-01-26
>
agile_geek07:01:45

@bronsa remind me at the weekend to ping Andy (that guy who co-authored the compilers). Bit busy during week.

peterwestmacott08:01:40

Does anyone know if there’s a macro out there that throws an ex-info with all the local bindings in its ex-data map?

dominicm09:01:44

Shift+AltGr (linux)

mccraigmccraig09:01:49

nope @thomas i've got a UK mbp keyboard with a US mapping so i get a sensible #

dominicm09:01:05

Shift+AltGr followed by oa does it.

dominicm09:01:41

@mccraigmccraig are those custom or default mappings?

mccraigmccraig09:01:07

@dominicm default on osx i think

mccraigmccraig09:01:04

i lived in norway for a while and have a son in bergen, so i get to type norwegian which has those three extra letters in the alphabet

dominicm09:01:20

I'll admit I find them a little jarring as far as mappings go.

dominicm09:01:50

Although, OSX has already 2 modifiers, so I suppose that is entirely negated.

mccraigmccraig09:01:35

the alt-k thing applies the superior circle to ånẙ o̊f the̊ le̊tte̊rs ẘhich tåke̊ it

mccraigmccraig09:01:24

the ø and æ are just separate chars

yogidevbear10:01:31

I know how you all love to talk politics so I'm (to use a term @agile_geek said yesterday) throwing a grenade into the room... https://antidotezine.com/2017/01/22/trump-knows-you/

thomas10:01:37

scary indeed....

thomas10:01:59

so software developers have now become the makers of nuclear bombs

otfrom11:01:59

I am become Thoth. The weigher of hearts.

otfrom14:01:21

:clapping_hieroglyph:

mattford14:01:50

hey there all 🙂 more n00b questions. I'm pulling in libraries but they frequently seem to have dependencies on previous versions of clojure (at least that what Cider is telling me).

mattford14:01:17

[[clojure-term-colors "0.1.0-20140207.035954-1"]]
Dependencies not loaded due to conflict with previous jars :
[[org.clojure/clojure "1.5.1"]]
WARN: org.clojure/clojure version 1.1.0 requested, but 1.8.0 already on classpath.
Loaded dependencies:
[[clansi "1.0.0"]]
Dependencies not loaded due to conflict with previous jars :
[[org.clojure/clojure "1.1.0"]]

mattford14:01:36

Is that sort of thing safe to ignore?

mattford14:01:31

Is clojure version compatibility good enough.

agile_geek14:01:05

Generally Clojure versions are backwardly compatible but you might want to exclude clojure from the dependencies that are warning you so that the higher version is used.

mccraigmccraig14:01:02

@mattford i generally have a top-level :exclusions [org.clojure/clojure] in my project.clj, and explicitly include the version i want in deps

mattford14:01:00

Hi this works for me (run! println (line-seq stream)) but when I try to do this (run! (partial printlncolor "red") (line-seq stream)) where

(defn printlncolor [color string]
  println (style string (keyword color)))
it doesn't.

mattford14:01:19

@mccraigmccraig thanks i'll do that.

mccraigmccraig14:01:21

@mattford also useful is :pedantic? :abort which won't automatically choose from conflicting versions - it requires you to specify :exclusions

glenjamin14:01:56

I didn’t know you could do a top-level :exclusions, neat

mccraigmccraig14:01:44

it's worth spending a few mins looking at https://github.com/technomancy/leiningen/blob/master/sample.project.clj - i discovered a few useful things there

mattford15:01:59

ah the above was a bug in my func definition.

mattford15:01:10

missing brackets

mattford15:01:12

Can we pass keywords around as symbols?

otfrom15:01:17

mattford yeah (IIUC)

mccraigmccraig15:01:36

@mattford :keywords and 'symbols are different things - both can be passed around

mattford15:01:16

(defn test [color string]
  (println (style string color)))
(test :red "boo")

mattford15:01:38

ah test was a reserved word

mattford15:01:16

works with testa

mattford15:01:19

live and learn

glenjamin15:01:30

it shouldn’t be a reserved word afaik

mccraigmccraig15:01:48

it's not a reserved word - but there is a fn clojure.core/test

bronsa15:01:53

there's very few symbols that can be considered "reserved words" in clojure and test is not one of them

mattford15:01:35

ah perhaps my cider skills letting me down

mattford15:01:41

works as test

mattford15:01:15

So my learning is very messy at the mo.

glenjamin15:01:24

the best kind 🙂

mattford15:01:33

How can I clean up the repl?

mattford15:01:40

get rid of all my junk

mattford15:01:44

is it a restart?

mccraigmccraig15:01:41

(remove-ns 'user) might work ... mostly i have tools.namespace as a project dep and use https://github.com/clojure/tools.namespace#reloading-code-usage to reload everything

mattford15:01:18

This looks kinda odd to me

{:alsmp  {:color :red    :ips ["10.206.6.145"]}
 :alsapi {:color :green  :ips ["10.206.6.245" "10.206.6.42"]}
is it something I'll get used to?

otfrom15:01:29

mattford I generally use the metasyntactic variables in the repl and only name things well when I copy them into a source file in a proper namespace, but then I remember the bad old days before tools.namespace being good

otfrom15:01:40

(and it forces me to refactor at least once)

otfrom15:01:18

I'll rarely do a defn in the repl. Just lets until I know what I want and the refactor to a function in the source file

otfrom15:01:30

with some tests based on what I did in the repl that I liked

mattford15:01:44

hmmm interesting

mattford15:01:06

"repl driven development"

mccraigmccraig15:01:53

@mattford the indenting / spacing looks kinda odd in that paste

otfrom15:01:59

yeah, we've had some good discussions on that here and on the ldnclj mailing list

mattford15:01:21

I fixed it up.

mccraigmccraig15:01:35

{:alsmp  {:color :red
          :ips ["10.206.6.145"]}
 :alsapi {:color :green
          :ips ["10.206.6.245" "10.206.6.42"]}

mattford15:01:37

But it's keyword as value to a keyword that looks odd at the mo.

otfrom15:01:13

keywords as values get used as they are handy

otfrom15:01:27

I might go for namespaced keywords lie ::alsmp

otfrom15:01:36

that will play better with spec

otfrom15:01:41

(when you get to that)

mattford15:01:14

Right cool. Found them useful already - got rid of my string to keyword conversion stuff.

mccraigmccraig15:01:23

@mattford keywords can be used as fns too, so you can do things like :

mattford15:01:52

so as a function it will return the keywords value in the hash it's passed.

mattford15:01:05

so value lookup?

mccraigmccraig15:01:58

yes, or presence with a set

mattford15:01:59

What's preferred?

({:a 1 :b 2} :a)
or
(:a {:a 1 :b 2})

mattford15:01:27

I naturally used the first in my code it seems

otfrom15:01:16

1st most of the time, but not always

mccraigmccraig15:01:23

it depends on context. (:a {:a 1 :b 2}) has the advantage that it won't throw if the map is nil

otfrom15:01:26

or rather, more commmon

peterwestmacott15:01:24

yes, put whichever is most likely to be nil second

peterwestmacott15:01:33

I think they can both take a default value as well

mattford15:01:21

In the first form what's happening?

mattford15:01:31

The hash is a function somehow?

peterwestmacott15:01:48

both maps and keywords (and also sets) are functions

mccraigmccraig15:01:27

basically anything can implement the clojure.lang.IFn interface or cljs.core/IFn protocol and behave like a fn @mattford

peterwestmacott15:01:32

😞 vector doesn’t take a default value

mattford15:01:58

Interesting stuff.

otfrom15:01:50

vectors are just maps where the keys are the index (he said unhelpfully)

mattford15:01:50

Thanks for the insights 🙂

mccraigmccraig15:01:06

@otfrom "my own private pinewood taj mahal, except for the shape and the size"

mattford15:01:01

is that an offset error above?

mccraigmccraig15:01:42

@mattford yes - the vector only has indexes 0 and 1

mattford15:01:19

Only two hard things in comp sci etc etc 😁

mattford15:01:12

Grin looks angry to me

otfrom16:01:36

([1 2] 0)
1

otfrom16:01:58

mattford yes to the offset error

mccraigmccraig16:01:18

anyone got a decent solution to adding lein deps to a docker image ? currently i've got a custom .m2 dir in git, which i can add to the docker image, which avoids having to pull all (or any) deps on every build, so builds are quick - but now my git repo is massive

otfrom16:01:30

mccraigmccraig why not an uberjar?

mccraigmccraig16:01:03

@otfrom ah, not for distribution - i use uberjars for that - this is for build and test. i'm building and running module tests within a docker composition

wamaral16:01:20

@mccraigmccraig maybe copy the project.clj, run lein, then copy the app files. That should cache .m2 unless you change your project.clj

glenjamin16:01:17

what does the docker image get you beyond just straight-up lein? Specific JVM version?

mccraigmccraig16:01:42

@wamaral i tried that but abandoned it late at night - can't remember exactly why now. maybe i should try it again

wamaral16:01:54

@mccraigmccraig maybe some weird deps between project.clj and your app code? Dunno, it usually works for me

mccraigmccraig16:01:56

@glenjamin location independence - i need to run tests against a cassandra, so one lein image docker-composed with a cassandra image, all run on docker cloud or codefresh, or whever

mccraigmccraig16:01:41

think i'll give that another go @wamaral

paulspencerwilliams18:01:49

I'm embarrassed to admit I didn't know about Docker cloud. We're all about DO but I really like the idea of Node as a service rather than being responsible for provisioning nodes.

paulspencerwilliams18:01:22

I've been meaning to play with AWS's docker service but time..

glenjamin18:01:57

I’ve had a bunch of second-hand reports on container service on AWS - they pretty much all say it’s not magic enough

mccraigmccraig18:01:12

@paulspencerwilliams i trialled docker-cloud and codefresh as a CI+CD solution - both worked similarly, but codefresh currently performs a load better (costs more tho, cos docker-cloud is in a free beta phase)