Fork me on GitHub
#clojure
<
2016-06-28
>
aengelberg04:06:44

Does anyone have a good script or program to alter the name of a project and propagate that to all the relevant files? I want to change the name of all the file paths in the filesystem my/proj1/ns.clj => my/proj2/ns.clj and change all references to the namespaces my.proj1.ns => my.proj2.ns.

aengelberg04:06:05

I'm thinking something like sed but not sure how to do the filesystem part.

groglogic05:06:02

not a direct answer, but if there are only a few hits to change I'd recommend doing it manually. can be done fast anyway if you have good enough find/grep/vim-fu. it doesn't scale to a huge number of hits, but has advantage of being context-smart and filetype smart, and safer. plus it should be rare you change a project name

hans05:06:21

aengelberg: clj-refactor has cljr-rename-file which updates both the file name and the package name, including references to it within the same project.

seylerius07:06:57

Gah. How the hell do you parse multiple regexps out of a string efficiently?

seylerius07:06:53

Need to turn foo *bar /baz/ bar* _foo_ into ["foo " [:b "bar " [:i "baz"] " bar"] " " [:u "foo"]]

seylerius07:06:57

Org-mode inline parsing, in other words. I've already got the regexps, but efficiently recursing over the string is a mystery to me.

seylerius07:06:42

Also, hat tip to @chingfan_newbie for helping me figure out the missing bit for my regexps earlier.

aengelberg07:06:19

With http://github.com/engelberg/instaparse:

boot.user=> (def p (insta/parser "
S = token*
<token> = b | i | u | string
b = <'*'> token* <'*'>
i = <'/'> token* <'/'>
u = <'_'> token* <'_'>
<string> = #'[^*/_]+'
"))
#'boot.user/p
boot.user=> (p "foo *bar /baz/ bar* _foo_")
[:S "foo " [:b "bar " [:i "baz"] " bar"] " " [:u "foo"]]

aengelberg07:06:07

You could also change S to <S> to effectively omit the :S in the result

seylerius07:06:52

Wat. That looks awesome.

danielohrlund13:06:49

instaparse looks amazing!

neilmock13:06:29

anyone else had a problem with ring-jetty serving an empty root response only when packaged in an uberjar (ie works fine in dev mode)

neilmock13:06:34

can’t quite figure this one out

neilmock14:06:25

can’t think of anything other than that the wrap-resource middleware resolves “/“ as an empty resource and serves it

neilmock14:06:30

only in a jar though

martinklepsch14:06:04

I have a thing that gives me allowed-actions which will advance the thing into a new state which in turn also has allowed-actions — now I want to compute all possible paths using these allowed actions.

martinklepsch14:06:28

With "thing" I'm referring to a state machine such as this: https://github.com/ztellman/automat/raw/master/docs/readme-2.png

martinklepsch14:06:54

For the image above I'd want to end up with [[1 2 3] [1 3]]

martinklepsch14:06:30

I considered clojure.walk but I'm not seeing how it would help me yet.

neilmock18:06:24

unlikely anyone has this particular problem, bit if you are using the “friend” auth library be sure to exclude ring/ring-core from it if you plan on deploying an executable jar to run your web app

neilmock18:06:46

there was a fix put in long ago into ring to account for empty directories being picked up as valid resources

neilmock18:06:20

friend targets ring 1.2.0 unfortunately

ddellacosta18:06:52

So, I feel pretty sure Alex Miller had a great post on protocol and multi-method performance, but I'm having trouble finding it now

ddellacosta18:06:07

and indeed, can't even seem to find his blog. My google-fu is failing me. Anyone know where that is?

Tim18:06:14

hasn’t updated in a while

ddellacosta18:06:16

yeah, that seems to be his old one though

ddellacosta18:06:21

I could swear he has a newer one

Tim18:06:38

oh, it didn’t come up, when I was reading his blog this weekend

ddellacosta18:06:02

his newer one you mean? Yeah I'm confused as to where that went

ddellacosta18:06:17

I know, I'll try twitter

ddellacosta19:06:27

weelll I'll stop spamming #C03S1KBA2 about this. @alexmiller or anyone if you see this and can point me in the right direction, let me know! Thanks

ddellacosta19:06:07

Aha, I figured it out: I was looking for his posts on http://insideclojure.org. This is the one in particular I was after if anyone else cares: http://insideclojure.org/2015/04/27/poly-perf/

ddellacosta19:06:11

sorry again for the noise!

Tim19:06:17

oh cool, looks like a good resource, though

ddellacosta19:06:39

yeah, lots of great pieces there

richiardiandrea20:06:13

Hello all, is there a way, with an immutant server, to wait for it to close? akid to aleph's wait-for-close https://github.com/ztellman/aleph/blob/master/src/aleph/netty.clj#L732

richiardiandrea20:06:51

oh, redirecting to #C085AR8RE

staypufd23:06:32

I need some help understanding why this returns a LazySeq with count of 1

staypufd23:06:37

(doall (filter (fn [li] (nil? (:id li))) [{:id 1} {:id 2}]))

staypufd23:06:04

Anyone know why that isn’t count zero?

austb23:06:13

When I ran that, I got a count of 0

austb23:06:29

To get the count, you’re simply running

austb23:06:32

(count (doall (filter (fn [li] (nil? (:id li))) [{:id 1} {:id 2}])))

staypufd23:06:03

@austb - Yes if I wrap in count function but the Cursive evaluator there is showing count of 1

austb23:06:32

Hmm I’m not experienced with how Cursive evaluator works, but is it possible that it’s saying the result was 1 LazySeq?

staypufd23:06:13

That may be it

codonnell23:06:22

@staypufd: filter returns a seq with the list items where the predicate function returns true. Since none of those maps have the value associated to :id as nil, filter returns an empty list.

codonnell23:06:12

You can remove elements satisfying a predicate with remove

austb23:06:03

@staypufd: does this give a count of two?

(doall (filter (fn [li] (nil? (:id li))) [{:id 1} {:id 2}])) ()

codonnell23:06:33

oh I understand the concern.

codonnell23:06:48

I also get 0

austb23:06:13

Yeah cursive is throwing in a weird count = 1, but we don’t know what it’s counting

norman23:06:04

what does (.isRealized (doall (filter (fn [li] (nil? (:id li))) [{:id 1} {:id 2}]))) show in cursive?

staypufd23:06:19

I'll check in a few. Driving