This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-04-28
Channels
- # aws-lambda (2)
- # beginners (49)
- # boot (49)
- # cider (7)
- # clara (1)
- # cljsrn (4)
- # clojure (199)
- # clojure-android (49)
- # clojure-dev (1)
- # clojure-greece (4)
- # clojure-italy (3)
- # clojure-nl (4)
- # clojure-norway (5)
- # clojure-russia (78)
- # clojure-spec (22)
- # clojure-uk (18)
- # clojurebridge (2)
- # clojurescript (252)
- # core-typed (2)
- # cursive (11)
- # data-science (1)
- # datascript (2)
- # datomic (38)
- # devcards (1)
- # flambo (3)
- # hoplon (10)
- # immutant (2)
- # jobs (3)
- # luminus (1)
- # lumo (2)
- # off-topic (8)
- # om (3)
- # onyx (29)
- # parinfer (1)
- # pedestal (4)
- # portkey (13)
- # re-frame (13)
- # reagent (6)
- # ring (3)
- # ring-swagger (15)
- # schema (2)
- # spacemacs (4)
- # test-check (4)
- # untangled (46)
- # yada (2)
run!
is probably what you want there
https://github.com/clojure/clojure/blob/clojure-1.9.0-alpha14/src/clj/clojure/core.clj#L7585
I'm using clojure/java.jdb quite a lot and I'm pondering how to cancel abandoned requests. I don't see a place to do this, or a way to extract the jdbc statement to do it directly, anyone know if this is something that already exists? Of if there is somewhere else I should be asking about this?
I'm sure there is a better way to achieve that, someone has an idea ?
(def pos ["zero" "one" "two"])
(for [i (range (count pos))] (print i " - " (get pos i)))
I don't like to call get each time
Vectors are associative, so this works:
(reduce-kv
(fn [_ k v]
(println k " - " v))
nil
pos)
@tbaldridge and if I want to return something instead, for example a map {:i k 😛 v}, reduce isn't helpful here ?
a reduce can return any type you like
yes, reduce can do that
+user=> (reduce-kv (fn [acc k v] (conj acc {:i k :p v})) [] ["zero" "one" "two"])
[{:i 0, :p "zero"} {:i 1, :p "one"} {:i 2, :p "two"}]
Is WhaleSong the only Racket -> JS compiler, or is Carmark using something else to do Racket -> JS ?
Just getting started with Apache Spark. I'm wondering if there's a best™ library to interact with it?
https://github.com/yieldbot/flambo, https://github.com/gorillalabs/sparkling and https://github.com/HCADatalab/powderkeg, of which the last one is really interesting 🙂
Do we have anyone here who’s using Clojure and AWS Lambdas in production? Opinions on it?
@looveh @mhjort (of https://github.com/mhjort/clj-lambda-utils) can likely answer your questions
but the really neat thing is this: https://github.com/cgrand/portkey
just picked my jaw up off the table.
How should I name: - A function that finds the closest date of a given weekday in the past or today - A function that finds the closest date of a given weekday in the future or today ?
@not-raspberry last-weekday-date
?
given it's impure, better start with a verb https://stuartsierra.com/2016/01/09/how-to-name-clojure-functions
It doesn't need to be impure, it can accept now
as an argument.
The actual problem is that while 'last' may imply that today is accepted, 'next' doesn't.
so next-weekday-date
is an iffy name
how about most-recent-weekday-date
?
Thanks.
I changed the code to assume a week range from the current week, so I don't need those functions 🙂
Developing code intended to be primarily used from the REPL exhibits an interesting conflict between user-friendliness and consistency.
Clojure 1.9 / clojure.spec split https://groups.google.com/forum/#!msg/clojure/10dbF7w2IQo/ec37TzP5AQAJ
@coltonoscopy I used play-clj to produce a commercial point-and-click adventure (tick’s tales)
Hi, I have immutant in project as a dependency which adds wunderboss-core as dependency which comes with a logback-default.xml in its jar. When starting my server the logback-default.xml takes precedence over my own log4j.xml that I have in my resources folder. The same happens when creating an uberjar. Is there a way to configure the priority of the log configurations?
@jcrossley3 Thanks, I will be trying this, should have checked the docs first
@coltonoscopy @brycecovert I'm taking the freedom to link @brycecoverts dev blog: http://www.tickstales.com/dev-blog/ It's pretty awesome!
@curlyfry - thanks! wow! Blogging is really hard, it means a ton to have someone say it’s insightful!
and I hope you like the game! Probably more relevant to folks here might be my talk at clojurewest last year: https://www.youtube.com/watch?v=lql2yFXzKUs
Is there a good/common way to (centrally) throttle/rate limit outgoing http requests? I need to call an API many times (from different parts of my app) but am being rate limited on their end and want to control my request rate. Thanks.
@juliobarros core.async is good for doing this, essentially you can use pipeline-async
or pipeline-blocking
to explicitly set you parallelism.
You can complement this by implementing exponential backoff, which again is fairly easy to implement with core.async
Thanks @val_waeselynck do you know of a gist, example or library that takes care of all the details? Btw, you are vvvvalvalval aren’t you? Great name 🙂 and I’ve used your libraries! Thanks.
wow thanks 🙂
yes that's me
exponential backoff:
Beware that the parallelism at least for pipeline-async
(not sure about pipeline-blocking
) is not precise. See https://dev.clojure.org/jira/browse/ASYNC-163 for some details.
is there a style preference for t/testing
macros? I feel like writing a bunch of prose is appropriate but Clojure doesn’t really have an applicable multiline string literal, right
@juliobarros as for http req throttling, here's the basic idea:
Thanks @val_waeselynck I’ll check out the gists.
> Clojure doesn’t really have an applicable multiline string literal
@lvh What do you mean? What's wrong with clj string literals ?
@lvh yes there is, unless we don't talk about the same thing
;; this is valid clojure "a multi line string"
there’s a subtle difference there; Python’s docstrings (not strings in genearl) don’t carry that formatting data around with them, and IIRC cljfmt doesn’t really like what clojure-mode does with filling those by default (except for docstrings): the indendation matches the (t/testing ...)
baseline, not testing + 2 or the opening quote for the string
not that I know of
Maybe you should write a (multiline s1 s2 s3 ...)
macro 🙂
that sounds like it’d make editor integration a lot worse than just fixing string-literal-with-newlines-in-it
yeah you're right
didn't think it through
as clojure is homoiconic, just wondering if there's any cool code refactoring library out there, I might not know how to google for that, or, nothing I found on my own looks quite stellar
e.g. I'm manually replacing one library with another across my source files in one project, and in a different universe I'd write a program that does it for me (go through all sources, find and replace under ns
definitions in this one case, maybe make a backup.
I'm sure to write this one day, just wondering if there's already something out, possibly covering more useful concerns than I am thinking of
@matan I’ve written a program that did some complex searching for certain patterns in a clojure program using slamhound’s asplode (https://github.com/technomancy/slamhound) - may be helpful
I didn’t use it to manipulate any code, only to find certain patterns, but it seems like that might be half the problem for you
aspload? https://github.com/technomancy/slamhound/blob/master/src/slam/hound/asplode.clj
It worked great for my use case; specifically finding all string arguments to any usage of a few functions within my program
@brycecovert i watched your talk several weeks back and was inspired by the way you did your cutscenes 🙂
coltonoscopy: adding it to my watch list... curious what libraries were used there (e.g.. om
and such). I was thinking of using om.next
next week (pun not intended lol)
i recommend it! he uses core.async
for the cutscene stuff. im not super familiar with clojure just yet but core.async
looks like an extremely powerful lib
yes I guess it is the natural choice. om
is a fullstack/UI library btw, based on it I think
hmm ill have to check it out, im actually not too familiar with it 🙂 he also uses play-clj
, which is a wrapper around libGDX
, a great Java game framework
libGDX is great. I had performance problems when trying to use play-clj but it might be time for me to revisit that
interesting, what kind of work were you doing?
nothing terribly formal but it was around rending large amounts of sprites. It didnt seem to be batching in a way id expect it to, i had run the same kind of simple game in games where i had rolled my own game loop in java with libGDX with orders of magnitude higher amounts of things going on. Solid chance i was just doing something wrong though.
why are some sample games libGDX here on this video https://libgdx.badlogicgames.com/ using pixels the size of cherries though? 🙂
hm thats interesting. would be curious to see the cause, though im inclined to believe it wasnt an issue with the library, maybe just an incorrect paradigmatic usage, or something different you have to do in clojure like you suspect 🙂
@matan talking about delver? 🙂 welcome to retro art!
ive used fairly high res textures with little issue (in java though that shouldnt have a bearing on resolution rendering power). its not pure c++ levels of performance but its not bad
setting up texture loading managers and pooling is as fun as it is in any language of course
yeah high res textures shouldnt be a problem, i feel thats more dependent on your GPU than the framework, since its effectively just a wrapper around OpenGL
i would say pooling is a little easier than say C++ 🙂
although SFML makes texture loading not too bad
not just the gpu, the way you do things with the shaders and interact with opengl can certainly screw it up but libgdx thankfully abstracts that away to a reasonable level.
i guess, but shaders run on the GPU too 🙂 not sure what you're referring to
and yeah if you do C++ game dev, SFML is great
they do but i guess im saying the code can screw that up pretty easily. i find the state machine that is opengl highly fragile but maybe im just really good at screwing it up. Obviously the actual code runs on the graphics card but i tend to think of it more as coding to opengl as a "machine" than the graphics card
but i learned opengl on the pipelining method not shaders so those characterizations arent as applicable if they ever even where
lol 😛 well opengl isnt particularly easy to program in. i much prefer using something higher-level
@brycecovert would that happen to be public code?
brycecovert: how are these things typically done in slack these days? private channels?
@coltonoscopy thanks!
A very fun problem, cutscenes. I’d be interested in taking it further, which I’ve been experimenting with, lately 🙂
dominicm: thanks, this looks like something kind of generic that many people have invested into
I try to avoid those, and either way the editor agnostic code (refactor nrepl) should be the best
@brycecovert yes and anything asynchronous, it applies well to turn-based games like the kinds i enjoy/want to write 🙂 (say, you want a character to walk to a tile in the battle grid, then cast a spell, etc.)
to get it as concise as you did takes a lot of work though
@coltonoscopy absolutely. There are many different approaches to those problems, like finite state machines, building your own scripting language, etc. core.async was a great answer - you get to write your game scripts in clojure, and it looks synchronous!
awesome, thanks! 🙂
Are there opinions on ease of implementing component vs. integrant? I have a Ring app I need to iterate on and I'm too impatient to restart my REPL 😉
@bradford you’ve probably spent more time than you’ll likely save by not just grabbing one and starting 🙂
@robert-stuttaford hahah story of my life
i like the look of integrant, personally, although i’ve never directly used either
I used component a few years ago. Although my current design pattern is 'atoms errywhere'
There are probably more resources for Component, but I think they generally apply to Integrant as well
I could use some feedback on something I'm puzzling over. I'm building a HTTP proxy that needs to have a weird architecture. The client hits a /upload endpoint which takes a multipart-form and content-type. It then transforms that to a Ring-based HTTP response with the proper content-type. This works fine for text content. But binary content isn't quite right. An image/jpeg is corrupted, with the browser seeing it as a text blob with size
of 0. I feel I'm not "casting" the data correctly, but I'm not sure how to fix it. Just setting the Response content = the content of the multipart-form isn't right.
how are you specifying it now? file or input-stream should work
and anything that comes from a reader (like slurp) is likely broken
how do grownups merge maps of arbitrary depths?
(merge-with
(partial merge-with merge)
{:a {:b 1}
:c 2}
{:a {:d 3}})
=> {:a {:b 1, :d 3}, :c 2}
looks too specific: works for 2 levels onlyThere's about 10 different ways to merge keys that collide during a deep merge
So either you can write custom merge logic, or switch to a structure that doesn't require you to merge nested maps.
One of those two is what I normally end up doing ^^
thanks @tbaldridge, that's what I expected.
with transit-clj, when reading multiple records from an InputStream, what’s the best way to detect the InputStream has no more records to read? (ie, the client can send a variable number of records, then close the socket) i see that when (transit/read)
is called when there is nothing to read, a RuntimeException is thrown, but that’s not the normal use case, is it?
Whats the idiomatic way to make a list of a finite length which expels elements by fifo?
@laujensen if you’re trying to make a FIFO cache, then yeah. If you want a generic coll for that, you could probably use https://github.com/amalloy/ring-buffer , if you were trying to make a core.async buffer, you can use https://clojuredocs.org/clojure.core.async/sliding-buffer
Thanks @tanzoniteblack , I'll checm 'em out
Im just trying to make a really slim login-attempt logger which checks for high frequency attempts
yeah, a ring-buffer sounds great for that (but a loop with a clojure.lang.PersistentQueue that does a pop and a conj on each iteration works too and doesn’t require a dep)
Just looking through ring-buffer it looks as lean as it gets, but thanks for the example
you can use /clj
Has anyone found a way to calculate the size of an object? I know its possible on .net now
structural sharing makes that ambiguous no?
a big percentage of live data in my app shares data with some other object also live in the app, it just has a few keys updated
just measuring its size as a tree would be misleading about its actual heap usage
Well, actually you were right, it would be ambigious, but then its also a choice you have to make, regarding how you weigh the shared data. But in most cases, I figure you want the whole deal. But check out the efforts on .net
yourkit lets you see the total size of referenced data in an object
but my experience was that so much of the data was shared between multiple hash-maps and lazy-seqs and vectors that I still had to do a lot of work to know what the real memory culprits were
one thing I found very useful was creating defrecords to replace hash-maps, just so the profiler would be able to look them up and summarize them quickly by name
but not defining any keys or methods, just a defrecord used like a map
Anyone want to give any software talk recommendations?
@laujensen nope! Just looking for what someone else finds interesting.
great thanks!