This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-05
Channels
- # beginners (29)
- # boot (29)
- # cider (54)
- # cljs-dev (99)
- # cljsjs (31)
- # cljsrn (39)
- # clojars (32)
- # clojure (171)
- # clojure-austin (2)
- # clojure-berlin (5)
- # clojure-brasil (3)
- # clojure-greece (2)
- # clojure-italy (1)
- # clojure-korea (11)
- # clojure-spec (202)
- # clojure-uk (166)
- # clojurescript (130)
- # cursive (54)
- # datomic (99)
- # dirac (18)
- # figwheel (6)
- # hoplon (23)
- # lambdaisland (3)
- # leiningen (8)
- # luminus (14)
- # off-topic (11)
- # om (3)
- # om-next (24)
- # onyx (59)
- # planck (25)
- # protorepl (10)
- # re-frame (49)
- # reagent (14)
- # ring-swagger (2)
- # rum (46)
- # schema (1)
- # slack-help (6)
- # specter (7)
- # testing (7)
- # untangled (115)
- # yada (1)
what is the mechanics behind the #'handler trick in reloading handlers w/ o restarting the webserver?
if you invoke a var, it automatically derefs itself and attempts to call its value as a function
https://github.com/ring-clojure/ring/search?utf8=%E2%9C%93&q=wrap-ring-handler <-- where do I get wrap-ring-handler from?
google finds https://github.com/ztellman/aleph/issues/14 which leads me to believe it is part of aleph, for making ring handlers work with aleph
@hiredman: I found it in some gist, (similar, but not this exact one): https://gist.github.com/ibdknox/665304/8a8a276444e217ab429c26b9372e6ae345b1d10e#file-alephpost-clj-L15 removing it works, so I'll just not use it
map
calls seq
on its argument so you don't need to.
(and you wouldn't use map
with println
-- I assume that's just by way of example?)
I probably wouldn't bother creating a function for it, I'd just do (map (partial map some-func) my-collection)
Does that help @neupsh ?
@seancorfield yes, println is just a quick function i tried in repl 🙂, i actually have some other stuff to do beside just 'nested-mapping' to arguments,
Does anyone have a guide on setting up clojure on AWS? I can run everything fine locally, but I'm not having a nice time dealing with AWS, and I feel like some poor clojure soul has already dealt with this problem.
AWS is pretty huge, you'll probably need to be more detailed.
But in general I normally install java, and then upload a uberjar to AWS.
AWS EC2 that is.
@tbaldridge: Agreed. Upon further reflection, my real issue is at the "persisting clojure data structures to database" layer, not so much with AWS. I have no problem setting up EC2 or AuroraDB. My issue is "how do I store my server side stuff to AuroraDB", which is really a "Clojure <-> DB" issue, and not so much an EC2 issue.
@qqq Isn't Aurora a MySQL clone? So regular clojure.java.jdbc
should do the trick there. Or you could use DynamoDB (and Faraday, the Clojure library)?
@qqq you might need to look at your security groups setup on AWS
@pesterhazy thanks :) do you have a particular use case in mind for supdate?
Although I'm not too sure if that matters for an app sitting inside the same network as the DB, but you might need to add you EC2 instance's IP to your security group for the DB to allow communications
@qqq: Yeah, Aurora has both MySQL and PostGres layers. However, I was mostly focused on client side, and did not think out my server side at all before trying to upload to EC2.
@yogidevbear: As it turns out, I was using Lightsail, which was in it's own "shadow VPS" not visible to the rest of AWS without lots of heavy reconfig. I have since decided to not use AWS.
Ok cool
Glad you figured out the issue
@val_waeselynck , one example would be an etl job where data types need to be coerced for some attributes
@pesterhazy I see. You should probably also consider Schema for this particular use case
Sure :)
What is your use case?
Even just updating only if the key exists is useful enough
I call that update-some in my code
in my case, it's mostly involved in the process of transforming Datomic entities into data structures (pull doesn't quite work for what my client expects).
It's similar to coercion yeah
optional nested update is useful too
I need that too
So you start from a pull result and transform into the output format?
no i start with entities
I guess pull is a drop in replacement for entities
If you know ahead of time what you need
not really. In my view when you pull, you need to know everything you need to pull, whereas with entities you can split the work
yeah exactly
Ya I really like entities too
I mostly use those for my business logic
Is there a more up to date take on http://clojure-doc.org/articles/tutorials/basic_web_development.html ? (something to just walk through setting up web servers properly -- everything I have done so far has been very adhoc)
is there a filter fn for maps that would that take a map and a predicate and returns a map with keys for which the values that satisfy the predicate? something like:
(filter-map {:a 1 :b 2 :c -1} #(> % 0))
returning {:a 1 :b 2}
Almost everybody has some utility library around with that function. Medley, Useful, Potpuri, …. Specter can do it, too. Weird that Plumbing does not seem to have it.
@qqq consider using AWS Elastic Beanstalk … it’s AWS PaaS, aka version of Heroku
you can create a full stack with load balancer to EC2s, to an RDS instance with the correct security groups
You can follow AWS’s Java tutorial and simply provide the uberjar output from lein
I usually box up all of my deployment artifacts into Docker Images instead of installing stuff directly to EC2, and Elastic Beanstalk can do Docker as well … so you have that option too
@tankthinks https://github.com/weavejester/lein-beanstalk <-- have you used this? this is actually the optimal situation: 1. put aws keys in some config file; 2. run "lein deploy" 3. it works
@qqq A friend pointed me to https://www.skyliner.io/deploy/clojure , which looks good for easy and secure deploy of Clojure on AWS, and is apparently written in Clojure too,
@mchampine : looking into it now -- apparently lein-beanstalk hasn't been updated for 3 years,
@mchampine : wait what? this is a web service, not a lein plugin ?
so I need to sign up / create an account with them in order for me to efficiently deploy to aws ?
@qqq Yeah, but it seems to have enough value to be worth it. Free for personal projects. This seems to cover its main features. https://blog.skyliner.io/the-happy-genius-of-my-household-2f76efba535a#.e6k1gm3ix
@qqq I have not tried https://github.com/weavejester/lein-beanstalk
I have an unfortunate amount of experience with Elastic Beanstalk and AWS … I wrote a bash wrapper around AWS’s eb
command line tool to expose most of its configuration via command line flags so the user doesn’t need to learn Cloud Formation
we did this for work and were considering OSing it but weren’t sure if there was a need
@qqq in addtion, there’s Heroku itself, which has some good resources (warning: i wrote most of them) https://devcenter.heroku.com/articles/getting-started-with-clojure#introduction
if you want deployment with lein (as opposed to git push
) there’s https://github.com/heroku/lein-heroku
I’m running into a weird problem with cheshire and cljs-ajax
cheshire returns newlines in the string (not escaped) breaking the cljs-ajax
not sure what would be the appropriate fix here, making sure I escape the newlines before serialising?
e.g. I get a json like
{”string”: “foo
bar baz
“,
“field”: “value”}
which is not valid json from Cheshire
unicode thing maybe?
fixed it by setting :escape-non-ascii to true
Is there a way to pretty print (nested maps) with sorted keys to make it easier to visually scan?
@juliobarros there are number of ways to do that, depending on what result you want. maybe look at pprint
or print-table
?
can anyone give me some rough heuristics for collection size to justify using the reducers library?
by my understanding it returns ordered data, but the predicates need to be associative...i.e. not dependent on previous calculations, is that right?
i'm not certain yet if that'll work for me. i suppose that means anything involving convolution is off the table, which i think would likely account for most of my longer sequences in the case i'm considering
I'd say though that core.async's pipelines + transducers have replaced anything I would have used reducers for.
@tbaldridge ah, really? core.async is certainly more flexible, but reducers have the benefit of being able to easily swap out for sequential functions
Sounds like you're doing something like image processing/large matrices?
so generally i benefit from lazy-seqs, but wanted to experiment with a parallel implementation for some hpc people i have in mind to test it
i think i'm unlikely to use core.async, at least at the moment, due to the added complexity. plus having to make sure the output is ordered
but i think a decent amount of the functions could be broken up and parallelized if there turn out to be use cases that require very long sequences to be output at once
yeah, I don't recommend core.async in your case, I spoke before I asked what you were working on.
@sophiago: this might be a heretical, but if you want automatic differentiation, checkout python/tensorflow, the whole speech there is: 1. you write the forward pass 2. tensorflow automatically calcualtes the backward pass 3. it even takes care of the GPU for you clojure, at the moment, really lacks anything comparable
because generally the use case is: 1) you define the model (like some neural network) by writing the forward pass; 2) then you want to train the parameters on some data set -- which you do via stochastic gradient descent + back propagation (which is what requires the derivatives); the closest libraries I have found in clojure are deeplearning4j and https://github.com/uncomplicate/neanderthal but imho, none even comes close to tensorflow
@tankthinks @codefinger : thanks for the insights on (1) AWS Beanstalk and (2) Heroku. I've actually decided to go with Google Cloud Platform / Go. Upon further reflection, I actually want the server side to be dead simple and lightweight (in fact, it should do nothing more than (1) routing websockets and (2) checking permissions before hitting the database).
@qqq … do you just want couchdb then?
In core async/take!, why does the doc say “Asynchronously takes a val”, when the default is to run take! on the current thread?
@dottedmag, that function is to coerce the given value to java’s number(https://docs.oracle.com/javase/8/docs/api/java/lang/Number.html)
@rgorrepati because it doesn't actually return anything...it may choose to call your callback later on a different thread
@rgorrepati it's an optimization that you can turn off via a flag to that function
@rgorrepati I can't find a case when the return value is different from the passed. Either I get a ClassCastException or the same value back.
@tbaldridge ok.. was a little confused. Thanks..
@rgorrepati I have looked at the implementation, and it's just a cast, so it does not produce anything useful.
It's a cast from a primitive to a non-primitive type.
or to a wrapped type, and it also inlines, so there's that, but since the compiler does most conversion automatically for you, it's mostly non-useful.
@tbaldridge So it's useful if you've got a function with a primitive number type hint, and still would like to call some Number method, correct?
Bonsoir!
Is there any guide on how to use time macro? Or a guide for benching sql-related and arbitrary code mix?
I'm trying to bench a piece consisting of sql query and simple munging. time
says that munging takes 90% of the time (like 1200ms), but if I call my-munge
function on prepared data it takes just 9ms.
Hi, trying to find out the idiomatic way to point projects at dependencies you're not sure you're going to keep. Lets say you forked an OSS project and need to point at your forked branch on github until merged. Is there a "The way" people would do that in leiningen? Should the fork be listed on clojars if temporary like this?
@ognivo are you sure your SQL code isn't returning lazy results?
the proper way is to deloy your fork to clojars under the org.clojars.mj_langford
group (or whatever your clojars id is)
@tbaldridge suspecting that actually.
try wrapping your sql results in (vec)
or something
Thanks @tcrawley, I didn't want to do that if temporary forks were considered pollution or something like that
really helps
@tbaldridge I'll try that, thanks!
btw, if anyone is deploying on a new mac and can't figure out why gpg won't sign your key for the clojars deploy to work, to get rid of the completely usless misleading "Inappropriate ioctl for device" error, you have to: export GPG_TTY=$(tty)
How do I get rid of a reflection warning in a gen-class when calling the superclass’s method which has been renamed locally by exposes-methods?
Example: https://www.dropbox.com/s/59bkl4m9pvi8xni/Screenshot%202017-01-05%2022.44.38.png?dl=0
(defn game-tree [game]
(if-not (g/game-over? game)
(into [game] (mapv game-tree (successors game)))
game))
the complex part looks like the mapv, which you would need to unroll using a stack to keep track of the 'unexectued parts'
in your loop/recur, you'd push :a 😛 :c :d :e onto a stack, then pop them off and exec them one at a time
I can’t think of a way to get the same output using recur
that isn’t a complete nightmare
@schmee is regular recursion giving you stack errors?
joshjones {:board [:- :- :- :- :- :- :- :- :-], :player :o}
, I’m using regular tic tac toe to try out the algorithms
gfredericks no, but I’m trying to implement the negamax algorithm so I need to pass context down the call stack
ttt.negamax=> (pprint (advances ttt/new-game))
[{:board [:o :- :- :- :- :- :- :- :-], :player :x}
{:board [:- :- :- :- :- :- :- :o :-], :player :x}
{:board [:- :o :- :- :- :- :- :- :-], :player :x}
{:board [:- :- :- :- :o :- :- :- :-], :player :x}
{:board [:- :- :- :- :- :- :o :- :-], :player :x}
{:board [:- :- :- :o :- :- :- :- :-], :player :x}
{:board [:- :- :o :- :- :- :- :- :-], :player :x}
{:board [:- :- :- :- :- :o :- :- :-], :player :x}
{:board [:- :- :- :- :- :- :- :- :o], :player :x}]
@schmee "pass context down the call stack" meaning something that will get modified and passed back up?
gfredericks yes, I need to keep track of two ints that will get updated as I visit each node
@schmee so you don't really need to produce the tree structure as the end result of the computation?
this algorithm is super easy to implement with mutable data, but I’m trying to do it The Functional Way™
tree-seq
might be helpful
in that case my only idea is zippers