This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-04-27
Channels
- # aleph (1)
- # aws (2)
- # beginners (69)
- # boot (79)
- # braid-chat (1)
- # cider (221)
- # clara (13)
- # cljs-dev (9)
- # cljs-edn (1)
- # cljsrn (7)
- # clojure (128)
- # clojure-chicago (1)
- # clojure-russia (196)
- # clojure-sanfrancisco (1)
- # clojure-uk (13)
- # clojurescript (166)
- # community-development (2)
- # css (2)
- # cursive (8)
- # datomic (4)
- # emacs (11)
- # hoplon (54)
- # instaparse (2)
- # jobs (16)
- # jobs-discuss (54)
- # jobs-rus (7)
- # luminus (4)
- # off-topic (33)
- # om (37)
- # onyx (8)
- # proton (10)
- # quil (8)
- # re-frame (29)
- # reagent (7)
- # remote-jobs (2)
- # untangled (140)
- # yada (1)
Hey, is there a function that checks for the truthiness of a function and when falsey it sets the result to nil
?
@urbanslug: Can you make an example? A function is always truthy. Or do you mean the result of a call? when
does return nil for falsey.
@urbanslug: I'd say that's as short as it gets and it's very idiomatic. At least I can't think of anything shorter.
Slightly off topic but need recommendations for a good book to learn Java. Something modern/new and not for first time programmers. The only decent recommendation I've gotten so far is Thinking in Java (4ed) which was released quite a long back.
@urbanslug: how about or
?
Not sure where to ask this but .. I was just wondering, I’m used to the Apache/PHP mix where you’ve a public_html dir and something in Apache will call the index.php to kick things off - is there an equivalent in Clojure? I’ve seen httpkit/jetty are these meant to be the http server replacements for apache?
nowadays, it is common to have an embedded server like jetty or netty(httpkit) in the application
@bones I deploy an uber jar with an embedded jetty that runs via a systemd startup script and is fronted by nginx for SSL/TLS. The luminus deploy docs actually give several good examples of deployment options: http://www.luminusweb.net/docs/deployment.md
That's what I do, as well.
Digital ocean has nice step by step instructions at https://www.digitalocean.com/community/tutorials/how-to-deploy-a-clojure-web-application-on-ubuntu-14-04
For example, when a piece matches a
:waypoint
the next piece need to be added as a new key :airway
for all waypoints until the next match@audaxion: could you give a small example of input and desired output data?
@codonnell: with the first snippet i uploaded as inputs, this is what i’d expect the output to look like
so if the waypoint string shows up in your list at the bottom, you add the key :airway with value equal to the string following it?
but then there is some special behavior for the ...'s?
the .. indicates the next string is another waypoint name, instead of an airway name
The first thing to do in my opinion is to convert your string into a better data structure.
I'm not sure exactly how your ...'s behave, but for the waypoint : airway pairs, it seems natural to store them in a map
for example, the first few would be {"MMMX" "PTJ5A", "PTJ5A" "PTJ", ...}
that way given a waypoint, you have an efficient way of finding its airway
something wrong with grimoire? can I run it in an offline mode?
Hi everyone. I'm working through the Getting Started chapter in Brave Clojure (http://www.braveclojure.com/getting-started/) and I'm getting an error when trying to run the jar file created from the lein uberjar
command:
Exception in thread "main" java.lang.NoClassDefFoundError: clojure/lang/Var
at clojure_noob.core.<clinit>(Unknown Source)
Caused by: java.lang.ClassNotFoundException: clojure.lang.Var
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Any ideas what could be causing the issue? (Not sure if I asked this last time I was working through this chapter)@codonnell: how would you recommend i go about splitting up the string to create the map?
@audaxion: (apply hash-map (.split (str (clojure.string/replace myinput ".." " none ") " none") " "))
(also a beginner, seeing this as a good exercise, let me know if I'm doing this clumsily)
@yogidevbear It looks like you are not running the -standalone.jar file
I think there needs to be a (partition 2 1 coll)
in there somewhere
and another split
For example, you want to split "A B C..D"
first into ["A B C", "D"]
Then you want to get all of the pairs out of "A B C"
, so you want to turn that into [["A" "B"], ["B" "C"]]
And the hash-map
function will convert that seq into a hash map.
Try to focus on doing each of those steps individually, then figure out how to string them together.
You should need string/split
, partition
, mapcat
, and hash-map
.
@curtis.summers: Thank you. I didn't notice on first glance that two jars were created. :thumbsup:
thanks @codonnell i’ll see what i can come up with
No problem. If you have more questions, feel free to ping me.
@yogidevbear: Yes, it's gotten me many times before. I don't think I've ever used the other jar it creates. I wonder if there's a way to prevent it from creating both to begin with.
@curtis.summers: it uses the foo.jar as an input to the process that makes foo-standalone.jar
I mean you could change it so it just creates foo.jar in memory, or puts it in a tmp file or whatever
Great thanks @roberto @curtis.summers @codonnell
@roberto, @curtis.summers so instead of “deploying” your PHP files to a folder where the Apache can run them, when you say “embed” a server into your app, when you deploy, you’re deploying the whole thing web server and all?
If you want multiple applications on the same box how do they not all fight over port 80?
No, nginx handles port 80 and 443, and my virtual host for http://mywebsite.com uses a proxy to my jetty process running on a localhost port.
Similar to this: http://www.luminusweb.net/docs/deployment.md#fronting_with_nginx
Ah! so it does a DNS-like thing and you tell it what local ports your apps are living on and what requests get forwarded to them?
Yes, that's basically it. It's very common to let nginx or Apache handle the virtual host, port 80, and TLS/SSL.