This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-09-01
Channels
- # aws (7)
- # bangalore-clj (10)
- # beginners (27)
- # braveandtrue (4)
- # calva (2)
- # cider (9)
- # cljs-dev (20)
- # clojure (228)
- # clojure-germany (5)
- # clojure-spec (7)
- # clojurescript (32)
- # datomic (11)
- # figwheel-main (10)
- # fulcro (21)
- # hyperfiddle (3)
- # off-topic (53)
- # onyx (1)
- # portkey (2)
- # re-frame (21)
- # reagent (1)
- # shadow-cljs (5)
- # spacemacs (7)
- # specter (4)
Hi, just a quick question. Is anyone using Slack for notifications about things like website, server monitoring? Just a quick question for you guys
https://github.com/SevereOverfl0w/terraform-aws-notify-slack I wrote this to notify slack
Unixy one... given a set of lines, how do I sort them by a set of words? i.e given an input like,
cljfmt/src/cljfmt/core.cljc
cljfmt/test/cljfmt/core_test.cljc
I want to show the lines matching src
first, then test
. For each group (src/test), lines should remain sorted lexicographically. So the final command would look like git ls-files | sort-by "src,test"
Hopefully the syntax would be clean so I can easily change src,test
to foo,bar
in a different project
(also speed is a requirement)@vemv Check out group-by
or partition-by
. Then sort each group internally (`sort-by`).
Note: if you use partition-by
, you have to make sure the primary collection is sorted first.
Alright, then #!/usr/local/bin/lumo
at the top of your script, then all of the above applies. 😉
git ls-files | tee tmp.txt | egrep 'foo' > foo.out; cat tmp.txt | egrep 'bar' > bar.out
egrep
allow to use regexp.
Lumo is node-js tech?
NodeJS startup time = JVM startup time, difference is Clojure class loading and compilation
you can also checkout GraalVM
. Do this script with sh/sh
and slurp
, then build with native-image
and then export a binary with "zero" startup time (like cljfmt does)
yes grallvm works, but you can't run any eval
and the community edition only has binaries for linux
I'd try to go the bash route (that way I don't have to make presumptions about my users)
will play with the bash snippet above. btw item 6 would be a good fit https://zwischenzugs.com/2018/01/06/ten-things-i-wish-id-known-about-bash/
It depends on how involved you want the foobar criteria to be (is it a list of entirely arbitrary strings?), and whether they change over time
* the strings represent directories like src
, test
, src/dev
etc. So not that arbitrary
* they definitely change over time - each project can have its own directory list
yeah it's like a priority list. For src/dev,test,src
Lines should be emitted in that order: src/dev, test, src
The simplest way I can think of is to have an array/list of patterns, and use the index of matched pattern as score for the sorting function.
The fact that one line could match several patterns (as with src, src/dev) complicated things, since you have to check patterns in order of specificity which might not be the same as the order you in which you want to output
Unless you can figure out some restrictions that will always apply to your sort criteria.
That’s why I asked about arbitrariness: as a further example, for patterns abc/src, src, src/cde - and a file on path abc/src/cde, which one would you expect to match, and in what order to sort, would require defining pattern match order and sort order separately
I like the idea of an array of patterns. if you have [/src\/dev/, /test/, /src/]
, then you can shortcircuit at the first matching regex and grab that index. That way there's no ambivalence
I'll probably implement it as a ruby script, they tend to be reasonably fast and accessible. Perl definitely out my reach 😂
You could not short circuit at the first matching regex if you wanted src to be sorted before src/dev
> You could not short circuit at the first matching regex if you wanted src to be sorted before src/dev
The intent is kind of non-sensical, the user cannot possibly want to display src before src/dev. Bit hard to explain but I think it's easy to see.
That said, one could pass a regex like src/^(?!dev)
I hear Windows GraalVM will come with Java 11
What would be really cool is Graal in serverless workflow, such as with Ions. But I understand there are limitations still.
Perl tends to be good for this kind of stuff (ie somewhat more advanced string processing if you’re doing it as a one liner from command line.) You can feed a comparison function to its sort. Also it’s ubiquitous, like bash.
I am mostly excited about using Clojure to write command line apps with GraalVM
Unfortunately what is more likely to be the result of GraalVM is more intrusion by Python, JS and Ruby on Clojure's turf
I will stick with Clojure until there’s a smaller mind-machine interface available. None of those languages solve that for me.
For anyone curious this is how the final script looks like
git ls-files | ruby -e 'puts STDIN.read.split("\n").sort_by{|line| %w(src test).find_index{|pattern| line.include? pattern } || 9999 }'
I often forget about ruby's scripting capabilities, defo they take a sweet spot between speed, concision, ubiquity, etc