This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-12-20
Channels
- # adventofcode (140)
- # beginners (107)
- # boot (120)
- # boot-dev (1)
- # clara (13)
- # cljs-dev (9)
- # clojure (107)
- # clojure-argentina (5)
- # clojure-art (16)
- # clojure-dev (23)
- # clojure-greece (19)
- # clojure-italy (5)
- # clojure-russia (2)
- # clojure-serbia (3)
- # clojure-spec (27)
- # clojure-sweden (1)
- # clojure-uk (15)
- # clojurescript (134)
- # cursive (5)
- # data-science (10)
- # datomic (23)
- # duct (28)
- # fulcro (48)
- # garden (5)
- # hoplon (2)
- # instaparse (1)
- # klipse (7)
- # leiningen (8)
- # lumo (36)
- # off-topic (72)
- # om (4)
- # onyx (37)
- # perun (4)
- # re-frame (64)
- # reagent (86)
- # remote-jobs (1)
- # shadow-cljs (59)
- # spacemacs (16)
- # sql (1)
- # uncomplicate (6)
- # unrepl (90)
quick question when I connect to an aws db do I need access keys? or can I just connect with user and pass?
You just need the username and password. You can build a JDBC URL based off of that and create a connection just like connecting to any other DB
@admay It's better to use :dbtype
and :dbname
with :user
and :password
rather than trying to build the JDBC URL yourself.
clojure.java.jdbc
tries to make connecting easier by figuring out the URL for you.
@josh_tackett Which AWS DB are you using? I haven't tried it myself but clojure.java.jdbc
should have no problem connecting to their MySQL-variant and at least one person has used it with RedShift (it's given as one of the examples in the README for clojure.java.jdbc
). If you have problems, head over to #sql and ask as I'm more likely to see it there.
@seancorfield No worries it was just an inbound configuration issue. FYI Amazon sets the default inbound rule for mysql to your IP address used when setting up the RDS instance
Is there a way to dump all data of JVM to start new JVM instances with the same initial data (state)?
I don’t think so
maybe you can run the JVM in a container/VM and save and reload the container
yeah I dont think it can be done, but it looks interesting. What are some use cases where this might be needed/useful?
@pcbalodi First use case is troubleshooting of a rare bug.
Depending on the type of the bug, you can take a heap dump and try analysing it
@vijaykiran In gdb
? It's C, not Java.
hmm - I thought you were talking about JVM
that would be super complicated given all the file descriptors and other OS resources the JVM would have
People have actually been working on this for years - they used to be called Isolates but I think they have a new name now
I tried seesaw with a hello world app, and though it is simple to use I didn’t like the start-up time of the app. Is there some library which can create a GUI that starts up instantly, like say electron apps do?
How are you starting your app?
While clojure startup time isn’t anything to brag about generally, tools like lein
add meaningfully to the startup time. You probably want to build an uberjar and run it via java directly, as well as choose your jvm-opts judiciously.
@donaldball yes I did lein run. I’ll try the uberjar method and see. I also couldn’t figure out why a java app called ‘main’ starts up before my app. Actually I am a C/C++ person, and am not aware of Java’s quirks
the “java app” is your process - clojure is a java library that generates and runs byte code in the jvm. “main” is a default name because neither you nor seesaw changed the default.
leiningen is a shell script which in your case runs java in order to calculate a classpath, then runs a second java process with that classpath in order to run your clojure program
@noisesmith thanks a lot. Your explanations are very helpful.
I've got an error compiling cljs with node dependencies: node_modules/firebaseui/dist/firebaseui.css: Unexpected token, expected ( (1:8) Anybody knows what to do with this?
How much loc your productivity daily avg? and avg. how much loc one project in Clojure? (eg. with/out macros)
git deltas on last 3 days:
3 files changed, 105 insertions(+), 41 deletions(-)
9 files changed, 63 insertions(+), 60 deletions(-)
2 files changed, 33 insertions(+), 36
some of those lines required multiple hrs of research and/or testing :)
Thanks @alexmiller !!
on a good day I can add 5 new features while reducing line count by about 300 lines
but “line” and “feature” are both kind of fuzzy metrics
Yeah, I generally consider it a very productive day if I've added functionality and reduced the overall number of lines!
@sb I'm always happy to share our code base stats:
Clojure build/config 43 files 2150 total loc
Clojure source 243 files 56183 total loc,
3099 fns, 710 of which are private,
372 vars, 41 macros, 47 atoms,
440 specs, 11 function specs.
Clojure tests 145 files 19484 total loc,
23 specs, 1 function specs.
daily what is the optimal at different levels? eg. beginner, senior? (eg. reagent/re-frame/sente application)
I don't think the LOC metric is at all useful (other than a vague measure of overall code base size). A daily metric is just nonsense.
"daily productivity" is a terrible concept in general, to be honest.
In some ways, with Clojure, I might expect a senior developer to produce more functionality with fewer lines of code than a beginner -- because a senior dev will often write more concise, more idiomatic code.
Also, Clojure emphasizes "hammock time" -- thinking carefully about a problem, exploring code via the REPL, and only then writing the actual production code.
If your team is Agile and doing some sort of story point estimation -- and is good at estimation (which most teams aren't!) -- then you could compare productivity in terms of story points completed. But even then I'd consider it a suspect metric.
You'll probably find, at first, that you're very slow to write Clojure code -- unless you have an FP background it is very alien.
Over time, you'll find yourself solving problems faster -- but probably with less code 🙂
We actually track those stats I posted, updating a file in git every Monday. A quick scan of diffs suggests that two senior Clojure devs are usually producing about 300 lines of Clojure source a week and about 100 lines of Clojure tests.
That said, there are weeks where our source lines went up by 1,000 and other weeks where it went down by 300!
The build/config
stuff is our build.boot
file and all our EDN config files (which control a lot of app behavior, as well as specifying each subproject's dependencies).
@seancorfield thanks!!
so i've got this list of objects, that I want to map to a hash of {:(.getKeyword object) (.getText object)}
, should I be looking at juxt or is there an easier / more idiomatic way of doing this
I assume the :
in your example is illustrative - does that mean you need the string to be converted to a keyword?
the simplest thing is going to be (fn [o] {(keyword (.getKeyword o)) (.getText o)})
juxt
would still require fn wrappers around the methods and then into
to create a hash-map
you could do something like (apply keyword ((juxt :keyword :text) (bean o)))
if you’re looking to impress your friends rather than make it readable :)
aieeee, I always struggle with java interop. Dear clojurist friends, I have a really stupid question: I'm trying to import this java class. https://jsoup.org/apidocs/index.html?org/jsoup/examples/HtmlToPlainText.html
i have no problem importing and using the normal Jsoup class, but I can't seem to figure out the right ns form to import the examples.HtmlToPlainText class. I've tried
(:import [org.jsoup Jsoup HtmlToPlainText])
and I've tried
(:import [org.jsoup Jsoup]
[org.jsoup.examples HtmlToPlainText])
but in both cases the compiler throws ClassNotFoundException
. Does anyone feel like cluing me in?@gowder how are you pulling in the jsoup dep for your project?
also - is that :import inside your ns form or stand alone?
because I would expect that error if using the keyword outside the ns
@noisesmith off maven, via lein [org.jsoup/jsoup "1.11.2"]
--- and yes, in my ns form.
then you are doing something else wrong - those are the two likely issues
are you sure you restarted since editing your deps?
because I tried to pull in another subpackage and it didn't throw
(ns cleanup-case.core
(:import [org.jsoup Jsoup]
[org.jsoup.helper StringUtil]
[org.jsoup.examples HtmlToPlainText])
(:gen-class))
the helper one didn't blow up...you could look inside the jar - the classpath will show where the jar is on your file system
Hmm, I am having trouble filtering/mapping with a static method. (ChunkHelper/isText (first chunks))
works fine, but (filter ChunkHelper/isText chunks)
errors with CompilerException java.lang.RuntimeException: Unable to find static field: isText in class ar.com.hjg.pngj.chunks.ChunkHelper,
@slack1478 static methods are not first class, you can’t put them on the stack so you can’t pass them as an argument to filter
you need to create a function that calls the static method
thanks @noisesmith
oooh. that is indeed the problem (and now I just learned how to look in a jar file... cool)
thanks @noisesmith
@gowder yeah they are zip files, even emacs and vim can open and peek inside 😄
hmm. I wonder what will happen if I just compile jsoup myself and then stick that example class on the classpath. terrible things, probably...
@gowder you can build and install to your local cache using maven, right? but if you are collaborating with others you probably want a private repo you can deploy to
or just use an artifact that exists
Thanks for all your help @noisesmith @alexmiller and @tsulej - i made this little module for reading and writing png metadata
(I especially think that these lines can be improved https://github.com/jedahan/metapng/blob/master/src/metapng/core.clj#L13-L24 )
from the perspective of someone new to clojure, its looks nice and clear to me! that’s a fun project
@slack1478 a couple of small things - line 22/23 you can replace (map …) (flatten) with (mapcat …)
mapcat is like map but concatenates all the results into a sequence - it’s less aggressive than flatten and preferable when it works
or, instead of mapcat or flatten, you can use (into {})
instead of (apply hash-map)
its kinda crazy I had to use pngj for reading metadata supposedly because I didn't understand how IIOImage works... and honestly I'm not sure if I should be using javax/iioimage, pngj, or apache commons imaging
as a very minor detail, on line 52 you don’t need to call vec on the metadata - reduce can use any collection directly that vec works on
@slack1478 two points from my side: 1) you read file twice, for image and for metadata - can be optimized to read once; 2) metadata is hash-map, you don't need to convert it to vec and operate on pairs (I think)
you would need to do that if you want keywords though
(regarding point 2)