Fork me on GitHub
#clojure
<
2018-10-02
>
rustin06:10:38

hey all! is there a place to post Clojure jobs in this workspace? I'm hiring 3 full-time, mid-level Clojure developers in Seattle.

manuel06:10:27

try #jobs and/or #remote-jobs

deliciousowl06:10:15

hey everyone, quick question. I'm going to be scraping social media for text (potentially images, but not yet) en masse. I expect there to be a LOT of data. I want to track the spread of things over time (so there will be time series involved). My question is, what kind of database would I use in production?

val_waeselynck09:10:34

Probably best to ask in #off-topic 🙂

schmee06:10:50

have you looked at Elasticsearch?

borkdude10:10:23

anyone got an example of how to embed png image in a mail with postal, using cid:… ?

timvisher13:10:42

@alexmiller et al: I would like to construct a dynamic deps.edn map without having to write multiple files. My first attempt was

clojure -Sdeps "{:deps {com.bhauman/rebel-readline {:mvn/version \"0.1.3\"}}}" -Sdeps '{:deps {clj-http {:mvn/version "3.9.1"}}}' -m rebel-readline.main
, thinking that -Sdeps would be additive, but instead it seems to be last-one-wins semantics.

timvisher13:10:24

This is for a simple lein-try replacement script, which reads:

rebl() {
    echo 'ALPHA' >&2
    clojure -Sdeps "{:deps {com.bhauman/rebel-readline {:mvn/version \"0.1.3\"}}}" "$@" -m rebel-readline.main
}

timvisher13:10:28

Any thoughts? 🙂

ninja16:10:43

Hi, is it possible to bundle multiple namespaces within a single one and require this bundle somewhere else in my code?

seancorfield16:10:36

@atwrdik require expects the namespace segments to map onto the file system so it won't be able to find the non-matching namespace in that file.

seancorfield16:10:17

You can just load the file itself and that will just compile all of the namespaces but I wouldn't recommend that.

ninja16:10:02

@seancorfield ok, I thought there was a mechanism to load everything from one namespace into another (as if it were defined there - compare to includes in C). But yeah this would probably lead to name clashes.

solf16:10:33

Is anybody aware of clojure (or clojurescript) project running on AWS lambda and with public sources?

solf16:10:46

thanks I'll check it out

timvisher16:10:36

@lilactown Oh that's brilliant. I don't know why it hadn't occurred to me to drop the expansion into the deps map itself.

timvisher16:10:51

I still think -Sdeps would be better with additive semantics but that can definitely by my workaround. 🙂

timvisher16:10:18

Additive semantics would also make it much easier to modify more of the map. 🙂

timvisher16:10:26

I wonder if a patch would be welcome there.

bfabry18:10:34

I have a intellij+gradle java8 project. what would be the easiest way for me to spin up clj repl with the same classpath?

bfabry18:10:44

would cursive work?

noisesmith18:10:27

easiest in the short term is add clojure as a dep and run clojure.main, most idiomatic is probably a new lein clojure project with your other project as a dep(?) - not sure of that though

noisesmith18:10:07

N.B. adding clojure and running clojure.main does literally what you ask, but not in the way that a normal clojure dev would do it

bfabry18:10:08

mm I can think how to set the cp up for the project in project.clj, but I can't think how to get all the project's dependencies on the cp without having to either re-specify everything in build.gradle, or fatjar the whole project

bfabry18:10:27

maybe I can make gradle emit a classpath and add clojure.jar to it

noisesmith18:10:49

clojure can be added as a dep in gradle though

noisesmith18:10:31

I think the normal path forward if you want it to be a clojure project is to switch over to lein for specifying deps (that part should be a rote transformation of your dep list) and using cursive to manage clojure tasks

noisesmith18:10:30

another option is if you can make a pom from the existing project, you can make that a dep in the lein project

bfabry18:10:02

I don't want it to be a clojure project. and I can't officially add clojure as a dependency (as in, to git). I want a repl to test/debug/explore this java project

bfabry18:10:11

a gradle init script with a global "clojureRepl" task might be the go

noisesmith18:10:26

you could add a standalone clojure jar to the classpath manually if you just want an ad hoc repl in a non-clojure project

noisesmith18:10:15

or ask gradle to output the classpath, and provide that as an arg to clj

bfabry18:10:57

yeah that was my original thought. I wish I actually knew gradle heh. I think a task created by an init script seems like the neatest atm

tengstrand18:10:41

Check out the new architecture that we have been working on the past two years: https://polylith.gitbook.io

👍 12
Tom19:10:22

I need a clojure ninja to help me solve a 'simple' problem/function: I have an instaparse tree, and I want to insert a keyword into the correct vector such that the key is in the 'right position' (splitting the text in the vector) for the given position in the original text. This would be easy enough if clojure wasn't using immutable datastructures and iteration was easy... so that's the challenge! How to do it given the Clojure way.

Tom19:10:48

splitting the text *if necessary

aengelberg19:10:07

Could you give a sample input/output?

Tom19:10:55

yep, just a second

joelsanchez19:10:40

tooling question. what do you do when you want to edit the code of a dependency with code reload? what I do is, remove the dependency, add its source folder in :source-paths, and add that source folder to the refresh-dirs of tools.namespace

noisesmith19:10:21

I typically use load-file to load the modified source, repl-integrated editors use a version of this adapted for nrepl usage

noisesmith19:10:48

(then after iterating, eventually cut a new version of the dep, of course)

joelsanchez20:10:53

yes yes of course. this is just for iterating, particularly when there's a lot of things to change

joelsanchez20:10:21

I will ask on the cursive channel on how to proceed, then. thanks!

joelsanchez19:10:58

of course, this is quite cumbersome, so I was wondering if it was a solved problem

Tom19:10:36

so say I had the tree: [:file [:forms [:form [:list "(" [:forms [:form [:part "1"] " "] [:form [:part "2"] " "] [:form [:part "3"]]] ")"]]]] and I wanted to put the key :cursor into position 2 I would have [:file [:forms [:form [:list "(" [:forms [:form [:part "1"] :cursor " "] [:form [:part "2"] " "] [:form [:part "3"]]] ")"]]]]

seancorfield19:10:38

@tom1vuu2011 Probably something in clojure.walk will help you here...?

Tom19:10:08

I think the problem is that I need to keep track of the length of the text so far in the tree, and I don't think walk helps with that

seancorfield19:10:38

@tom1vuu2011 you can use stateful closures to track state while you're walking the tree.

Tom19:10:57

would you be able to provide an example?

seancorfield19:10:28

Not while I'm on my phone. Will try to remember when I get back to my desk.

Tom19:10:50

in another function I have, I can just flatten, but here I want to preserve the structure of the tree

tristefigure19:10:40

(pointing directly to the code/doc since the README is still blank)

Tom19:10:24

hey, triste, this is for the Liquid Clojure Editor where I'm working on 'structural' clojure editing

Tom19:10:49

it looks like your work will probably be quite useful overall for this

Tom19:10:59

so you might want to participate directly

tristefigure19:10:22

a dance being a way to compose computation on trees à la prewalk

Tom19:10:04

if you could give the solution to the problem directly that would automatically make what you're doing useful

tristefigure19:10:26

... processing ... please wait ...

Cameron19:10:26

on a side note, I'm looking at your threading library 👀

tristefigure10:10:45

Thank you for your attention. I'm still not satisfied with arrow fletchings, the frontier with arrow head being too blurry. I went with >-args but looking back, I wonder: why not args-> ? For know I let the teabag infuse in the cup, but I think I'm heading toward a >- = >-> = -> = (build-arrow >- identity ->) equivalence. Not sure if this make any sense, but it looks cleaner I think.

Tom19:10:01

I'm just skimming the code, and I notice that there's no use of count: the idea is to put it into the position based on the amount of text covered by the tree so far

Tom19:10:40

so amending the example:

Tom19:10:48

[:file [:forms [:form [:list "(" [:forms [:form [:part "1abc"] " "] [:form [:part "2"] " "] [:form [:part "3"]]] ")"]]]]

Tom19:10:57

and insert :cursor at 2

Tom19:10:01

would yield:

Tom19:10:25

[:file [:forms [:form [:list "(" [:forms [:form [:part "1" :cursor "abc"] " "] [:form [:part "2"] " "] [:form [:part "3"]]] ")"]]]]

Tom19:10:54

so, it's split the :part string

noisesmith19:10:10

one way to do this kind of operation is to use zippers

Tom19:10:53

everyone is suggesting a different tool, but the solution is what's needed

Tom19:10:02

with respect, of course!

tristefigure19:10:09

wow wow it's coming I finally got what you meant

tristefigure19:10:30

you're probably transforming code/ast and need to keep track of the code lenght ... through the tree

noisesmith19:10:29

the reason I mention clojure.zip is it literally works in terms of stepping down, across / up an input and introducing changes at specific points, in a declarative / functional way

💯 4
noisesmith19:10:47

the design of the lib matches your problem description as you state it

Tom19:10:38

which sounds great, but unless you give the solution I have to look carefully to see if what you're saying is actually true

noisesmith19:10:58

I'm not a consultant, I'm a participant in a public discussion

☝️ 12
noisesmith19:10:03

the docs aren't that hard to read

Tom19:10:05

because the 'loc' in zip looks like it's not the 'loc' I care about

Tom19:10:16

right but you're actually just saying something random

noisesmith19:10:41

it's not random, it's an abstraction that fits your problem domain

Tom19:10:42

because without actually providing the solution you're just throwing up a tool and hoping it will be the right one

lilactown19:10:49

hey @tom1vuu2011, people are trying to point you in a direction they think might be useful. nobody is going to sit here and solve your problem for you. we have jobs

lilactown20:10:39

if you want to put a bounty up to solve this problem then you might find someone to give you the kind of help you're looking for

Tom20:10:48

thanks for the open source lecture.. believe it or not I'm working on this for free myself

lilactown20:10:51

but atm you are being very rude to people who are trying to help you

👍 12
Tom20:10:12

actually no

Tom20:10:17

you're being rude

Tom20:10:27

I've been through this kind of nonsense about 100 times in my life

nathanmarz20:10:21

@tom1vuu2011 this is exactly what specter excels at:

user=> (use 'com.rpl.specter)
nil
user=> (def data '[:file [:forms [:form [:list "(" [:forms [:form [:part "1"] " "] [:form [:part "2"] " "] [:form [:part "3"]]] ")"]]]])
#'user/data
user=> (setval [1 1 1 2 1 (before-index 2)] :cursor data)
[:file [:forms [:form [:list "(" [:forms [:form [:part "1"] :cursor " "] [:form [:part "2"] " "] [:form [:part "3"]]] ")"]]]]

Tom20:10:57

I was just looking at spectre... will read in a sec, thanks

nathanmarz20:10:56

@tom1vuu2011 your second example can be done like so:

(def data2 [:file [:forms [:form [:list "(" [:forms [:form [:part "1abc"] " "] [:form [:part "2"] " "] [:form [:part "3"]]] ")"]]]])

(defn divide-string [s index] (mapv #(apply str %) (split-at index s)))

(setval
  [1 1 1 2 1 1
   (srange 1 2)
   (view (fn [[s]] (divide-string s 1)))
   (before-index 1)]
  :cursor
  data2)

nathanmarz20:10:06

usually with data like this you don't have a big static path like that up front but need a recursive path to search through the data structure for what you want to target

Tom20:10:32

yeah, I think that the way the setval requires the position to be encoded suggests this isn't the right approach for this problem

Tom20:10:52

the "normal" solution would be to increment a counter

Tom20:10:52

but I think I'll have to go away and think of the solution myself, since it doesn't seem anyone has a straightforward answer

Tom20:10:55

but thanks very much

Tom20:10:55

@tristefigure if you manage to come up with a solution using your library, please dm me. thanks!

tristefigure20:10:32

I only managed :form forms, you'll have to do the same logic for :listetc...

dpsutton20:10:04

there's a notion similar to recursion limits. maybe gas? I think i remember reading this in one of @bbloom’s repos. does that ring a bell with anyone?

Tom20:10:05

@tristefigure that looks like it's on the right track!

tristefigure20:10:15

You can hang on this version since I'm doing work on the SNAPSHOT release (which clojars allows to be overwritten): [dance "0.2.0-Tom"]. That should be stable enough. The library itself is getting mature and don't expect any major interface breakage anymore at this point in its history.

alex31415920:10:24

Hello. I'm trying to build a desktop GUI app at work. My ideal scenario would be to do the number crunching in Clojure and the GUI in wxPython. What's the best interop? Use something like zeroMQ? Alternatively is there a good way to call C++ from Clojure to use wxWidgets? Open to anything but having to learn Swing or JavaFX.... Thank you!

alex31415905:10:39

@U8LB00QMD @U6XGSJV3M thank you, I’ll check these but at least with seesaw my impression is you still need to understand how Swing works behind the scenes to get things done

Bobbi Towers07:10:01

I just thought of something: what if you wrote your Clojure as Planck scripts and call them from your python GUI?

alex31415908:10:51

@U8LB00QMD that's an interesting idea! If startup time is slow enough that could work, let me play around with it, thanks!

Tom20:10:51

@tristefigure I'm still digesting it, but that looks very elegant

Tom20:10:00

it's actually not correctly counting the text because it only counts if the text is in a vector starting with :part

Tom20:10:05

but I get the gist

tristefigure20:10:42

there is also rewrite-clj, not sure if you know about it

Tom20:10:25

no. it looks like your library will do the job

Tom20:10:36

I'll look more into it tomorrow. thanks

Tom20:10:50

@tristefigure you should do intro videos to all your inventions... weaving looks cool

tristefigure21:10:13

While we're at it ... I'm in the process of polishing one of these inventions. It's a new kind of lexical closure: instead of capturing the environment surrounding the construction site of the function, I suggest to also capture the lexical context surrounding the call-site. Since I came up with this as I was pondering on the best way to extract a closure out of the claws of an enclosing let, I decided to call them delexical closures. https://github.com/TristeFigure/delexical

Tom21:10:46

you definitely need videos

cfleming21:10:37

@bfabry If you import the project into Cursive, you can just run a REPL with the IntelliJ classpath.

cfleming21:10:47

You’ll need to add Clojure to your deps and that’s it.

bfabry21:10:29

will that mess with my existing "this is already a java intellij project" settings?