#clojure log - Dec 21 2015

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:01 devth: appears that instances of Unbound are also falsey

0:01 ,(if a "yep" "nope")

0:01 clojurebot: #error {\n :cause "Unable to resolve symbol: a in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: a in this context"\n ...

0:04 justin_smith: ,(def a)

0:04 clojurebot: #'sandbox/a

0:04 justin_smith: ,(if a "yep" "nope")

0:04 clojurebot: "yep"

0:05 ridcully_: ,(def a nil)

0:05 clojurebot: #'sandbox/a

0:05 justin_smith: nope!

0:05 devth: hmm

0:05 justin_smith: unbound is truthy

0:05 ridcully_: why don't you want a to be unbound?

0:05 devth: ohhh you're right, i had set nil as my default

0:05 ridcully_: also you wound not be able to detect the difference to bound falsey?

0:06 justin_smith: ridcully_: unbound is truthy

0:06 devth: yep

1:40 ashwink005: what caching service do you guys usually use?

1:40 spyglass memcached?

1:44 how can I know the size of the data structure I'm caching?

1:53 keep_learning: Hello everyone

1:54 Could some one please me why this code is getting timeout exception

1:54 http://lpaste.net/147568

1:54 Yesterday night it was working so the only change is wifi

1:58 Kneiva: keep_learning: try running it with firefox or chrome driver and see what is happening?

1:58 keep_learning: Kneiva, I am running it with firefox

1:59 Kneiva: keep_learning: ok, at what point is it timing out?

2:00 keep_learning: Now I am getting some more weird error NoSuchElementException

2:00 I am not able to understand the behaviour of this code :(

2:00 It was running fine yesterday night and quit after loading the page.

2:02 Kneiva, Now I am getting TimeoutException Timed out

2:04 Kneiva: keep_learning: I can't find .scopedSearchDisplay from the page.

2:05 keep_learning: class="scopedSearchDisplay geoScopeDisplay whiteCaret"

2:05 <div style="position: absolute; left: -999em; top: 27px;" class="scopedSearchDisplay geoScopeDisplay whiteCaret"></div>

2:06 When I am commenting ;(t/wait-until #(= (t/title) (str "The 10 Best " city " Hotels - TripAdvisor")))

2:06 this line

2:06 Now it's running fine

2:06 user> (tripadvisor.core/go-to-tripadv "Gurgoan")

2:06 nil

2:06 and added (t/implicit-wait 3000)

2:08 Kneiva: ah, maybe one needs to input the city name before that is shown.

2:08 keep_learning: but yeah, you might need waits when dealing with ajax calls.

2:09 keep_learning: Kneiva, But I wanted to quit when page reloads and title appears

2:09 for next page

2:26 Kneiva: keep_learning: Does it go the 10 best -page after the search click?

2:26 keep_learning: Yes

2:27 Kneiva, I am getting false for

2:27 (= "The 10 Best Gurgaon Hotels - TripAdvisor" (str "The 10 Best " "Gurgoan" " Hotels - TripAdvisor"))

2:27 user> (= "The 10 Best Gurgaon Hotels - TripAdvisor" (str "The 10 Best " "Gurgoan" " Hotels - TripAdvisor"))

2:27 false

2:29 I think (t/wait-until #(= (t/title) (str "The 10 Best " city " Hotels - TripAdvisor"))

2:29 is problematic

2:31 Kneiva: Strange, to clojure those strings are different

2:33 lambda-11235: keep_learning: Gorgoan and Gurgaon are spelled differently. o and a are reversed

2:33 Kneiva: how I missed that! =)

2:34 keep_learning: lambda-11235, Thank you. Stupid me :)

2:45 visof: hi guys

2:46 the day has 24 hours, what is the best way to tell specific hour is closer than another one?

2:47 hour 23 is closer to hour 0 than hour 6 for example

3:13 TEttinger: ,(mod (- 24 0 23) 24)

3:13 clojurebot: 1

3:13 TEttinger: ,(mod (- 24 6 23) 24)

3:13 clojurebot: 19

3:13 TEttinger: hm

3:13 ,(mod (- (+ 24 6) 23) 24)

3:13 clojurebot: 7

3:13 TEttinger: ,(mod (- (+ 24 0) 23) 24)

3:13 clojurebot: 1

3:14 TEttinger: ,(mod (- (+ 24 20) 23) 24)

3:14 clojurebot: 21

3:14 TEttinger: hm

3:17 ,(let [hour-a 23 hour-b 20] (mod (- (+ (if (< hour-a (+ 12 hour-b)) 0 24) hour-b) hour-a) 24)

3:17 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

3:17 TEttinger: ,(let [hour-a 23 hour-b 20] (mod (- (+ (if (< hour-a (+ 12 hour-b)) 0 24) hour-b) hour-a) 24))

3:17 clojurebot: 21

3:17 TEttinger: dammit

3:18 ,(let [hour-a 23 hour-b 20] (mod (- (+ (if (< hour-a (+ 12 hour-b)) 12 24) hour-b) hour-a) 24))

3:18 clojurebot: 9

3:18 TEttinger: guh

3:19 ,(let [hour-a 23 hour-b 20] (mod (- (+ (if (< hour-a (+ 12 hour-b)) -24 24) hour-b) hour-a) 24))

3:19 clojurebot: 21

3:21 amalloy: TEttinger: take the minimum, mod 24, of a-b and b-a

3:22 TEttinger: ,(let [hour-a 23 hour-b 6] (rem (- (+ (if (< hour-a (+ 12 hour-b)) 0 24) hour-b) hour-a) 24))

3:22 clojurebot: 7

3:22 TEttinger: thanks amalloy, I was hoping to get negative answers like

3:22 ,(let [hour-a 23 hour-b 20] (rem (- (+ (if (< hour-a (+ 12 hour-b)) 0 24) hour-b) hour-a) 24))

3:22 clojurebot: -3

3:23 TEttinger: ,(let [a 23 b 20] (rem (min (- a b) (- b a)) 24))

3:23 clojurebot: -3

3:23 TEttinger: sweet, amalloy wins

3:24 ,(let [a 23] (doseq [b (range 24)] (print (rem (min (- a b) (- b a)) 24))))

3:24 clojurebot: -23-22-21-20-19-18-17-16-15-14-13-12-11-10-9-8-7-6-5-4-3-2-10

3:24 amalloy: uhhh, i don't think that works

3:24 TEttinger: hm, less good

3:24 ,(let [a 23] (doseq [b (range 24)] (print (mod (min (- a b) (- b a)) 24))))

3:24 clojurebot: 12345678910111213141516171819202122230

3:24 amalloy: you can't just rem a negative number usefully

3:25 you have to work with positive numbers, so add 24 to each first

3:25 TEttinger: ,(let [a (+ 23 24)] (doseq [b (range 24 48)] (print (mod (min (- a b) (- b a)) 24))))

3:25 clojurebot: 12345678910111213141516171819202122230

3:26 TEttinger: wait that wasn't what you meant was it?

3:26 ,(let [a 23] (doseq [b (range 24)] (print (mod (+ (min (- a b) (- b a)) 24) 24) " ")))

3:26 amalloy: 24 to each subtraction

3:26 clojurebot: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 0

3:26 TEttinger: not to the min?

3:26 amalloy: no, because you've already made the decision by the time you call min

3:27 (min (rem (+ 24 (- a b) 24)) (rem (+ 24 (- b a)) 24))

3:27 TEttinger: ,(let [a 23] (doseq [b (range 24)] (print (min (rem (+ 24 (- a b) 24)) (rem (+ 24 (- b a)) 24)) " ")))

3:27 clojurebot: #error {\n :cause "Wrong number of args (1) passed to: core/rem--inliner--4336"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "clojure.lang.ArityException: Wrong number of args (1) passed to: core/rem--inliner--4336, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6891]}\n {:type clojure.lang.ArityException\n :message "Wrong numb...

3:28 TEttinger: ,(let [a 23] (doseq [b (range 24)] (print (min (rem (+ 24 (- a b)) 24) (rem (+ 24 (- b a)) 24)) " ")))

3:28 clojurebot: 1 2 3 4 5 6 7 8 9 10 11 12 11 10 9 8 7 6 5 4 3 2 1 0

3:28 TEttinger: perfect

3:28 visof you still around? :D

3:48 user5252: Hi. In a lein project, I have listed a java class which includes a public static void main method as a dependency. Inside the repl I can import that class. Can I run the main method of the class inside the repl?

3:49 noncom: sure

3:50 (MyClass/main args) i think

3:50 user5252: how? :)

3:51 noncom: iirc the "args" should be a [] of strings. iirc that's the way to call a varargs method..

3:52 but if i am mistaken then it could just the strings passed as args, without being united in the []

3:54 user5252: it strange that it autocompletes "/main" and yet when run I get a compiler exception: no such field main

3:54 it should run with or without arguments, I tried both

3:57 it is strange*

4:02 keep_learning: (let [curr-url (t/current-url)]

4:02 (t/quit)

4:02 curr-url

4:02 )

4:03 How to make sure that it's executed in sequence.

4:03 I understand that I can use do keyword but

4:03 I am wanted to store the current-url before quitting the browser

4:35 favetelinguis: how can i check the value of a top level def in clojurescript from javascript console in chrome?

4:38 user5252: So, my problem actually lies on the fact that the main method expects an array of Strings as an argument. (to-array '(new String "")) returns an array of java.lang.Objects. How can I make an array of the sequence without recasting the class?

4:43 ok, found it. (into-array java.lang.String '(""))

4:51 jweiss: I've got {:foo-1 {:bar-1 0, :bar-2 1}, :foo-2 {:bar-1 3, :bar-3 4}} and want to turn inside out so that the nested map is keyed by bar first and then foo. eg {:bar-1 {:foo-1 0, foo-2 3}, :bar-2 {:foo-1 1} :bar-3 {:foo-2 4}. Only way i could think of to do this is with an intermediate list of triples and then reduce that to make a new map. maybe there's a more efficient or clear way?

4:56 drorbemet: Hi, currently I am looking for a way to disown a forked shell process using clojure.java.shell/sh or org.clojars.hozumi/clj-commons-exec/sh-pipe. In a linux bash terminal I am using command & disown

5:03 Guest96645: if i have a function that creates data what would be the best way to use that function to store the results in a vector?

5:03 for, and reduce seem to be better used after you have data

5:05 ridcully_: Guest96645: into ?

5:05 ,(into [] (range 10))

5:05 clojurebot: [0 1 2 3 4 ...]

5:05 Guest96645: ridcully_: and just mapv the function over that?

5:07 ridcully_: im starting with an empty vector [] and a function that generates new data to put into that (i guess a good example would be (rand n), i feel like theres a more elegant way

5:07 i could use repeatedly but that seems to be fore side effects

5:11 ashwink005: memcached clojure client is giving me stackoverflow

5:11 any idea why that could be? Its a recursive call to serializing an object

5:15 user5252: join #eclim

5:15 :)

5:19 Guest96645: what do you do if you want a lazy version of reapetedly?

5:20 MJB47: repeatedly is lazy?

5:20 https://clojuredocs.org/clojure.core/repeatedly

5:23 Guest96645: MJB47: yea sorry i was thrown off becaus it said assumably with side-effects

5:24 MJB47: thats just because if there werent side effects you would rather use repeat

5:24 as it would be more efficient

5:25 Guest96645: MJB47: really? repeat always returns the same number tho even if you give it a fuction, where as repeatedly calls the function over and over?

5:25 MJB47: yes, but if there were no side effects, then the function would always return the same value

5:25 Guest96645: MJB47: ah i see

5:27 thinkingslowly: Anyone seen this error with clj-http? "SSL peer shut down incorrectly"?

5:59 hamid: Hi, Does anyone know how can I pass JVM options to "boot" in order to install it? I want use socks proxy so I have to pass socks options. When I manipulate the boot.sh file it says the jar file(probably the boot.sh itself) is corrupted.

8:07 mmi: (eval :foo)

8:09 * mmi slaps a4j around a bit with a large fishbot

8:18 keep_learning: Hello everyone

8:18 I am trying to extract :href from ({:tag :div, :attrs {:class "pageNumbers"}, :content ({:tag :span, :attrs {:onclick "ta.trackEventOnPage('STANDARD_PAGINATION', 'curpage', '1', 0);", :class "pageNum first current", :data-offset "0", :data-page-number "1"}, :content ("1")} {:tag :a, :attrs {:onclick "ta.hac.filters.paging(this, event); ta.trackEventOnPage('STANDARD_PAGINATION', 'page', '2', 0);", :class "pageNum taLnk", :data-offset "30", :data-

8:18 page-number "2", :href "/Hotels-g297684-oa30-Lucknow_Uttar_Pradesh-Hotels.html#ACCOM_OVERVIEW"}, :content ("2")} {:tag :a, :attrs {:onclick "ta.hac.filters.paging(this, event); ta.trackEventOnPage('STANDARD_PAGINATION', 'last', '3', 0);", :class "pageNum last taLnk", :data-offset "60", :data-page-number "3", :href "/Hotels-g297684-oa60-Lucknow_Uttar_Pradesh-Hotels.html#ACCOM_OVERVIEW"}, :content ("3")})})

8:18 using enlive

8:20 I am trying to extract the list from ( -> html-resource (select [:content]) (select :href))

8:20 is giving empty list

8:36 I have filtered the data little bit

8:36 but still getting error

8:36 My data is

8:36 ({:tag :a, :attrs {:onclick "ta.hac.filters.paging(this, event); ta.trackEventOnPage('STANDARD_PAGINATION', 'page', '2', 0);", :class "pageNum taLnk", :data-offset "30", :data-page-number "2", :href "/Hotels-g297684-oa30-Lucknow_Uttar_Pradesh-Hotels.html#ACCOM_OVERVIEW"}, :content ("2")} {:tag :a, :attrs {:onclick "ta.hac.filters.paging(this, event); ta.trackEventOnPage('STANDARD_PAGINATION', 'last', '3', 0);", :class "pageNum last taLnk", :data

8:36 -offset "60", :data-page-number "3", :href "/Hotels-g297684-oa60-Lucknow_Uttar_Pradesh-Hotels.html#ACCOM_OVERVIEW"}, :content ("3")})

8:37 I am trying to use map to fetch :href

8:37 (map :href) on this list

8:37 but getting ClassCastException java.lang.String cannot be cast to clojure.lang.IFn user/eval13851 (form-init148529210888258716.clj:1)

8:39 ridcully_: please provide some complete code+error on refheap/...; also isn't selected used to select items in a form?

8:50 benjyz1: hi. I'm working on a simple problem

8:50 selecting from a map

8:50 ,(def x [{:a :foo} {:a :bar}])

8:50 clojurebot: #'sandbox/x

8:51 benjyz1: I want => [:foo :bar]

8:51 MJB47: ,(vals x)

8:51 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.util.Map$Entry>

8:52 ridcully_: ,(map :a x)

8:52 MJB47: ,(apply vals x)

8:52 clojurebot: (:foo :bar)

8:52 #error {\n :cause "Wrong number of args (2) passed to: core/vals"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (2) passed to: core/vals"\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.AFn invoke "AFn.java" 36]\n [clojure.lang.AFn applyToHelper "AFn.java" 156]\n [clojure.lang.AFn a...

8:52 MJB47: im stupid nvm

8:52 go with ridcully_ method

8:52 ridcully_: well... OPs intention is not perfectly clear :)

8:53 benjyz1: that simple, eh... thanks

8:55 ,(def x [{:a {:x :foo}} {:a {:x :bar}}])

8:55 clojurebot: #'sandbox/x

8:55 benjyz1: (map :a x)

8:55 ,(map :a x)

8:55 clojurebot: ({:x :foo} {:x :bar})

8:55 benjyz1: ,(map (map :a x) :x)

8:55 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword>

8:55 benjyz1: ,(map :x (map :a x)

8:56 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

8:56 benjyz1: ,(def y [{:a {:x :foo}} {:a {:x :bar}}])

8:56 clojurebot: #'sandbox/y

8:56 benjyz1: ,(map :x (map :a y)

8:56 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

8:56 benjyz1: ,(map :x (map :a y))

8:56 clojurebot: (:foo :bar)

8:57 MJB47: ,(map #(get-in % [:a :x]) y)

8:57 clojurebot: (:foo :bar)

8:57 ridcully_: ,(map (comp :x :a) y)

8:57 clojurebot: (:foo :bar)

8:58 ridcully_: if this grows in complexity, also have a look at specter

9:01 Idoiw9Ax: How can I query all entities satisfying the given predicate from datascript db without counting the same pairs two times?

9:01 BRODUS: im having trouble mocking one of my dependencies, i think if i adopted style 2 here: http://pastebin.com/M8EeK0Nc mocking would be easier, but im wondering if thats bad style, any advice?

9:01 Idoiw9Ax: So if (pred x y) is true and (pred y x), I want to return only [x y] or [y x], but not both.

9:03 *is true too

9:28 drorbemet: Hi, currently I am looking for a way to disown a forked shell process using clojure.java.shell/sh or org.clojars.hozumi/clj-commons-exec/sh-pipe. In a linux bash terminal I am using command & disown

10:09 troydm: is there a version of pmap that optionally takes number of processes to use

10:11 like standard version has this Runtime getRuntime availableProcessors + 2 line but this isn't enough for me

10:51 keep_learning: ,(map (comp :href :attrs) '({:tag :a, :attrs {:onclick "ta.hac.filters.paging(this, event); ta.trackEventOnPage('STANDARD_PAGINATION', 'page', '2', 0);", :class "pageNum taLnk", :data-offset "30", :data-page-number "2", :href "/Hotels-g297685-oa30-Varanasi_Uttar_Pradesh-Hotels.html#ACCOM_OVERVIEW"}, :content ("2")} {:tag :a, :attrs {:onclick "ta.hac.filters.paging(this, event); ta.trackEventOnPage('STANDARD_PAGINATION', 'last', '3', 0);", :class

10:51 "pageNum last taLnk", :data-offset "60", :data-page-number "3", :href "/Hotels-g297685-oa60-Varanasi_Uttar_Pradesh-Hotels.html#ACCOM_OVERVIEW"}, :content ("3")}))

10:51 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

10:53 keep_learning: ,(map (comp :href :attrs) '({:tag :a, :attrs {:onclick "ta.hac.filters.paging(this, event); ta.trackEventOnPage('STANDARD_PAGINATION', 'page', '2', 0);", :class "pageNum taLnk", :data-offset "30", :data-page-number "2", :href "/Hotels-g297685-oa30-Varanasi_Uttar_Pradesh-Hotels.html#ACCOM_OVERVIEW"}, :content ("2")} {:tag :a, :attrs {:onclick "ta.hac.filters.paging(this, event); ta.trackEventOnPage('STANDARD_PAGINATION', 'last', '3', 0);", :class

10:53 "pageNum last taLnk", :data-offset "60", :data-page-number "3", :href "/Hotels-g297685-oa60-Varanasi_Uttar_Pradesh-Hotels.html#ACCOM_OVERVIEW"}, :content ("3")}))

10:53 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

10:57 keep_learning: http://lpaste.net/147584

10:57 Could some one please tell me why second part is not working

10:58 (map (comp :href :attirs) '(element from list)) is working fine

10:59 (-> '(element from list) (map (comp :href :attrs))) is not working

10:59 I am getting

10:59 IllegalArgumentException Don't know how to create ISeq from: clojure.core$comp$fn__4495 clojure.lang.RT.seqFrom (RT.java:528)

10:59 MJB47: use ->>

11:00 -> places the argument as the first argument in the next function

11:00 ->> places it as the last

11:00 keep_learning: MJB47, Thank you

11:00 powered: keep_learning, macroexpand is a useful function to see what is actually getting generated

11:01 keep_learning: MJB47, so if I write (-> '(element from list) (map (comp :href :attrs) %0)) should work

11:01 MJB47, I get your point

11:01 MJB47: no

11:02 it would expand to

11:02 (map '(element from list) (comp ...))

11:02 which is obviously not what you want

11:02 imojinflakk: hey all

11:03 keep_learning: MJB47, Thank you

11:09 MJB47, (->> (-> (java.io.StringReader. page)

11:09 ehtml/html-resource

11:09 (ehtml/select [:div.pageNumbers :a]))

11:09 (map (comp :href :attrs)))

11:09 I have written it like this

11:09 is it idiomatic clojure ?

11:11 TimMc: keep_learning: A little funky. Try using as->, like so: https://www.refheap.com/112979

11:12 That mixing of -> and ->> can be difficult to read.

11:12 ridcully_: i'd not use -> and ->> together. you can as well just wrote (map ... (-> ...)) here. or just use a let

11:12 keep_learning: TimMc, Thank you

11:13 ridcully_: s/wro/wri/

11:31 keep_learning: ,(str "Hello" "World")

11:31 clojurebot: "HelloWorld"

11:32 keep_learning: ,(map (fn [x] (str "hello" x)) '("how" "are"))

11:32 clojurebot: ("hellohow" "helloare")

11:33 keep_learning: ,(map (str "hello" %) '("hello", "world"))

11:33 clojurebot: #error {\n :cause "Unable to resolve symbol: % in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: % in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: % in this context"\n ...

11:33 TimMc: keep_learning: Missing a #

13:04 orz: Hi everyone, I'm writing a server app that accepts photo uploads from mobile phones, and it turns out images uploaded from phones are big (~3mb)

13:04 Can anyone reccomend a library that will let me reduce the size of these images on disk after the file is uploaded?

13:04 Like, some kind of jpeg quality reduction

13:05 noncom: well agaik java imageio can do

13:05 or just zip them

13:05 but also there are things like http://fiji.sc/Clojure_Scripting

13:05 *afaik

13:06 ridcully_: zipping jpegs ?

13:06 justin_smith: yeah, imageio isn't super hard to use

13:06 engblom: I am trying to use gpio-clj to program my raspberry pi. (def port (open-port 4)) gives CompilerException java.io.FileNotFoundException: /sys/class/gpio/gpio4/value (Permission denied), compiling:(form-init7023382170868619027.clj:1:11)

13:07 ridcully_: engblom: your current user can not access that file or the directiory to that file

13:07 noncom: ridcully_: well yeah, i assume that if orz needs some more compression, then there is a room for it. if not, then jpeg is not really reducible and the question cannot be really answered positively

13:07 justin_smith: engblom: sounds like your user doesn't have permission to access the gpio?

13:07 engblom: I am having permission to write to that file and I have tested it with "echo 1 >/sys/class/gpio/gpio4/value"

13:07 justin_smith: OK

13:08 orz: I just want to reduce the quality because my app serves the images over http

13:08 and when I have 10 images loading at 3mb each that's slow as hell

13:09 justin_smith: yeah, for that I'd use imageio to reduce the image quality and/or size

13:09 noncom: yeah, java imageio or fiji (imagej)... there can be others ofcourse

13:09 orz: Cool, I'll look into those, thanks!

13:10 justin_smith: or hey, you could even make the browser side do the shrinking of the image before uploading

13:10 noncom: broswer side is better

13:10 let the user computer do the job: )

13:10 engblom: -rwxrwx--- 1 root gpio 4096 Dec 21 20:05 /sys/class/gpio/gpio4/value

13:11 I am in the gpio group, and thus I am able to pipe 1 and 0 to /sys/class/gpio/gpio4/value

13:11 orz: You mean with javascript somehow?

13:11 justin_smith: orz: right

13:11 engblom: I just do not understand why I am not able to open this file through gpio-clj

13:11 orz: Right now web uploads happen with a standard form file upload

13:11 noncom: engblom: are you able to open it at all from your jvm process?

13:11 orz: would I have to abandon that pattern and make the upload happen though JS then?

13:11 noncom: engblom: try with java.io.File. first or slurp/spit

13:12 justin_smith: engblom: also you could double check that java is running as your user (I know it's weird if it isn't, but it's possible...)

13:15 engblom: justin_smith: Yes, the java process is run by me, I checked up with ps.

13:15 noncom: (slurp "/sys/class/gpio/gpio4/value") works well and returns the value from it

13:15 noncom: engblom: ok, reading works, what about writing

13:17 engblom: noncom: Apparently spitting to the file fails with the same message

13:17 noncom: engblom: then it's the jvm thing

13:17 you could google for this kind of thing with jvms. i remember seeing similar things

13:17 ridcully_: just to have it asked. have you added yourself to gpio _after_ you have started that jvm process and are you testing your echos in a new terminal?

13:17 noncom: also, all kinds of ssh-related weirdnesses are possible

13:18 agentmeerkat: Hi all, work has asked me to look into a change control system. I've looked at some different ones online, but wanted to see if anyone found a change control system that didn't make them want to jump out a window?

13:18 engblom: Really strange as the file got " -rwxrwx--- 1 root gpio 4096 Dec 21 20:05 /sys/class/gpio/gpio4/value". If I am able to read, I should also be able to write

13:18 justin_smith: engblom: it could be something else it is trying to do

13:18 eg. flush

13:18 noncom: engblom: reading and writing are different permissions ? or no?

13:19 justin_smith: it could be using some weird system call that works for files but not for /sys/ pseudo-files

13:19 noncom: the read and write perms there are identical for all users

13:19 noncom: also: https://github.com/peterschwarz/clj-gpio/blob/master/src/main/clojure/gpio/core.clj#L127 - you can try to see what's there and search line-per-line

13:19 justin_smith: oh ok

13:20 or, if spit gives the same error, then its just the jvm

13:20 also, ridcully_ said a thing that could be

13:21 engblom: ridcully_: I have alwasys been in the gpio group. I even rebooted the raspberry just to make sure nothing is messed up

13:22 ridcully_: also didnt the jvm have some security stuff that that restricts the sandbox? well i doubt, that it would be enabled on the pi... also se-linux, systrace, whatthecoolkidsusetoday

13:23 my pi is rotting in a box... to lazy to check myself ;P

13:28 TimMc: engblom: What pi are you using, out of curiosity?

13:28 I tried running Java on my B and it took about 4 minutes to start up a lein repl. :-P

13:29 justin_smith: TimMc: what about just starting clojure.jar?

13:29 engblom: TimMc: Pi2

13:35 * justin_smith makes a note to check if clojure.jar is usable on his pi2 when he gets home.

13:35 engblom: justin_smith: I am running the most recent Raspbian-Lite

14:08 rhg135: Clojure.jar works splendidly on a piB

14:09 Takes a few seconds to start

14:13 TimMc: Maybe they have a better JVM for it now...

14:16 rhg135: That limited ram

15:18 TimMc: You mean I actually have to care about JVM heap size settings? This is preposterous! *stalks off*

15:19 arrdem: seeing as TimMc is still reachable he can't have stalked far

15:20 rhg135: The default is not too big anyway

15:24 {blake}: cfleming_: Trying to buy...checkout not working...

15:37 arrdem: why aren't you taking our money dot jpeg

15:41 {blake}: I might as well just set it on fire.

16:24 benjyz1: hi. I'm working with channels over TCP and edn

16:24 anyone working with libraries on TCP? all I've seen is based on netty

16:25 justin_smith: there's sente for websockets, which is one way of setting up a tcp socket

16:25 transit tends to work nicely for serializing / deserializing edn to go over tcp

16:28 cfleming_: {blake} That's not good - what's the error you're getting?

16:28 {blake} It's just declining?

16:29 {blake}: In most browsers it's just never coming back.

16:29 benjyz1: jusint_smith: thanks. I mean non HTTP which also has some constructs for the streams used

16:29 {blake}: One of them gets a "connection refused", I think? Let me chcek.

16:29 Er, Chrome ges "Connection reset"

16:30 "Powered by paddle" in the lower left.

16:30 benjyz1: not only a data-format but channels on each side e.g.

16:30 justin_smith: benjyz1: websockets are non-http

16:30 I mean they may not be what you want at all, but they are not an http request

16:31 benjyz1: ok, I'm using plain java sockets

16:31 justin_smith: benjyz1: aleph has some nice stuff for raw sockets

16:31 benjyz1: right. that's the netty library underneath, which has channel and pipeline semantics

16:31 justin_smith: also manifold, by the same author

16:31 OK

16:32 benjyz1: yes, I like aleph, but I don't know netty etc. and so its hard to understand

16:32 so I'm experimenting with just java sockets and works well for me. just wondering whether someone has done something like this

16:34 justin_smith: benjyz1: where aleph and manifold come in is if you plan on having more than a few client connections, and need high throughput. They deal with things like backpressure and thread management and such that become concerns when you scale up.

16:35 benjyz1: my concern is not performance, but complex semantics

16:35 so I need to create a kind of DSL for users which they can use

16:41 justin_smith: benjyz1: manifold also gives a simpler semantics, eg. it can tie incoming messages to callbacks or core.async

17:01 visof: hi guys

17:01 how can i split string at n whitespaces?

17:02 MJB47: https://clojuredocs.org/clojure.string/split

17:02 visof: i know slipt

17:02 split

17:02 how can i split each 200 spaces?

17:02 MJB47: it takes an optional third argument

17:02 for maximum number of splits

17:05 visof: MJB47: i mean if i have string which has pattern as each 200 spaces there is word and i want to split at each 200 spaces?

17:05 MJB47: oh i see

17:05 justin_smith: visof: then make a 200 space regex?

17:05 visof: ,(clojure.string/split "hello world", #"\s\s\s")

17:06 clojurebot: ["hello" "world"]

17:06 visof: justin_smith: how? write it?

17:06 ,(clojure.string/split "hello world", #"\s\s\s\s\s\s\s\s\s\s")

17:06 clojurebot: ["hello" "world"]

17:06 ridcully_: ,(clojure.string/split "A B C D" #"[ ]{2,}")

17:06 clojurebot: ["A B" "C D"]

17:07 visof: ,(clojure.string/split "hello world" #"[ ]{10,}")

17:07 clojurebot: ["hello" "world"]

17:07 visof: ridcully_: thanks man

17:07 #"[ ]{10,}" what is refer?

17:07 ridcully_: that's n and more

17:07 might not, what you want

17:07 justin_smith: visof: heh, I remembered that specifying exactly N repititions could be done in a regex, just forgot the syntax, luckilly ridcully_ remembered

17:08 ridcully_: would {10,10} be exactly 10?

17:08 or just {10} or?

17:09 ridcully_: it is, but not sure, what OP wants here

17:09 (clojure.string/split "A B C D C" #"[ ]{2}")

17:09 ,(clojure.string/split "A B C D C" #"[ ]{2}")

17:09 clojurebot: ["A B" "C D" " C"]

17:09 ridcully_: see the second C

18:29 devth_: i want a data structure backed by an edn file where writes are persisted back to disk. (e.g. read/write config files)

18:29 devth: and it should maintain whitespace and comments :)

18:31 and the ability to pass around a cursor into a specific part that also allows writes

18:32 does anyone else want that? does it exist? should i build it?

18:41 spieden: devth: hmm. why not a database?

18:42 devth: reminds me of tie in perl

18:42 devth: hmm. well it's configuration for my chat bot

18:42 part of which contains db connection info :)

18:43 the user can tweak settings through interacting with the bot itself, which then need to be written back

18:43 spieden: heh, sounds like something your provisioning would generate and write out

18:43 ah hrm

18:53 justin_smith: devth: persisting changes to data into a file has all the problems that coordinating change across threads has, plus extra probles introduced by the OS / filesystem layer

18:53 devth: single resource / single lock ?

18:54 ,(doc locking)

18:54 clojurebot: "([x & body]); Executes exprs in an implicit do, while holding the monitor of x. Will release the monitor of x in all circumstances."

18:55 devth: version 2: support cloud-based storage, retries and all that fun :)

18:57 anyway it's a great place to play with failure. low risk, low impact, mostly for fun

18:57 justin_smith: devth: sure, locks work as long as you know you won't get a deadlock (eg. what happens if something that is modifying the file (has the lock) calls something else that wants to modify the file (waits for the lock)) - it's easy to get an infinite stall this way

18:57 devth: yeah

18:58 what happens if an agent tries to do that? (call another fn that uses that agent?)

18:58 justin_smith: the action sent to the agent goes into a queue and cannot be carried out until the other queued actions finish

18:59 agents are async

18:59 so you send f to a, a carries out f, mid f you send g to a, a waits until it finishes with f, then starts g

19:01 devth: nice. so that could be used as a locking mechanism that avoids deadlocks

19:03 justin_smith: sure, you could use a single agent - but it would be up to you to make sure the file access is always tied to that one agent

19:03 perhaps a watcher on that agent that does the file writes?

19:04 devth: yep

19:06 justin_smith: add-watch that is

19:26 spieden: yeah that sounds good

19:29 myogenic: hey, can anyone help an OO programmer with a breadth first n-ary tree type problem in clojure?

19:34 arrdem: myogenic: dunno if I can help but by all means describe the problem more

19:34 "ask to ask" applies

19:34 amalloy: well, "don't ask to ask"

19:34 myogenic: hah my bad

19:35 arrdem: all good

19:37 myogenic: basically I'm primitively modelling the movement of people from one city to another, so people from city A will move to all the surrounding cities and so on

19:38 so i'm basically creating a breadth first n-ary tree

19:38 but I'm struggling with passing progressive results on due to immutability

19:38 then there's accumalating the results at the end

19:39 would a loop/recur structure be generally the way to go for a problem like this?

19:39 justin_smith: myogenic: the general approach is to turn your mutable item into a block local binding - like a loop binding

19:39 yeah

19:39 so you pass the new value to each iteration

19:40 the same can be done with reduce, if your input is a sequence

19:40 TEttinger: there's a bunch of ways to do it, and loop/recur is sometimes the best suited.

19:40 iterate can somewhat rarely be a good fit.

19:40 justin_smith: it's definitely the version that translates easiest from the imperative one

19:40 true!

19:41 myogenic: can I pastebin what I have so far? feels like im hacking a bit

19:41 TEttinger: sure

19:41 refheap is common, but we don't care what pastebin you use

19:42 myogenic: I've kinda stopped mid-line, it's totally not finished but just wondering if I'm on the right lines at all https://www.refheap.com/45d6a4e3408e377210db2c731

19:44 I think the dotimes is the wrong choice, I need that to iterate through the surrounding counties, which basically act as children nodes to city A

19:44 justin_smith: anyone else having trouble connecting to refheap right now?

19:45 TEttinger: calling things that modify in dotimes won't really work

19:45 (or that modify immutable data)

19:45 myogenic: yeah I know it was kinda wrong

19:45 TEttinger: you may want for

19:46 justin_smith: but for won't pass updates to the next iteration either

19:46 TEttinger: ,(for [n (range 5)] (str "thing " n))

19:46 clojurebot: ("thing 0" "thing 1" "thing 2" "thing 3" "thing 4")

19:47 justin_smith: myogenic: you can't recur to a loop from inside dotimes, because nothing inside dotimes can be in the loop's tail position

19:48 myogenic: the idea with a tail recursion is that it can be replaced with a regular for-loop style goto plus a variable update, without consuming stack

19:48 myogenic: assign-pop-split will return a structure like ([524 1001] [141 1002]) which is basically ([population-count county-id]), I need to make a recursive call for each tupple

19:49 justin_smith: myogenic: if it's not in the tail position you need to do the regular (non optimized) kind of direct recursion

19:49 myogenic: Ahh I see

19:49 justin_smith: but, you can usually find a transform that puts more data into the loop bindings, and then allows not consuming stack

19:50 myogenic: so would a for work in place of that dotimes?

19:50 or do I run into the same issue?

19:50 justin_smith: myogenic: also, peek/pop in clojure are not mutations, and peek returns the top of the stack, pop returns everything but the top

19:51 myogenic: as long as the stack doesn't go deep enough to cause an error, a for would probably work

19:52 myogenic: How would I pass the structure returned from assign-pop-split into the to-move binding since I'm already passing it to (conj res ...)

19:53 do I have to introduce a let if I want to reference the result of assign-pop-split more than once?

20:02 justin_smith: myogenic: let is the straightforward way to do that, yeah

20:02 myogenic: justin_smith okay thanks man, I'll keep trying with this then, doesn't look horrible does it?

20:03 justin_smith: myogenic: many small errors, typical newcomer mistakes, all should be easy to fix

20:03 don't be afraid to ask more questions, and definitely look for a book or at least check out some simple exercises like 4clojure.com

20:04 myogenic: justin_smith: thanks a lot, I have the o'reilly book and I've done a couple of questions on 4clojure :D

20:04 justin_smith: cool, sounds like you are on the right track

20:20 * koszti

20:22 slester: myogenic: welcome!

20:25 rritoch: Hi, what is the best way to handle the clojure dependency in a publicly released library (clojars) generated with leiningen? I currently have :dependencies [[org.clojure/clojure "1.5.1"]] in my code but I'm thinking that may conflict with other libraries so should I move that to the dev profile, remove it entirely, etc.. so it'll work with any version of clojure and not override higher versions?

20:32 Looking at core.async & cljs-time it seems that the way I have it defined is common, it just seems wrong.

20:33 futuro: rritoch: Why?

20:34 shouldn't the language handle the dependency graph and only including something once?

20:34 rritoch: futuro: Because it's common to need to add a clojure exclusion when pulling in libraries when libraries include the clojure dependency that overrides the version the developer requires.

20:35 futuro: Yes, the problem is it doesn't always include the intended version, mostly because of libraries like this one that can cause the wrong decision to be made and 1.5.1 loaded instead of the latest version (for example).

20:35 futuro: rritoch: hmm...I can see what you mean

20:38 rritoch: Anyhow, I'm just prepping a new release of clj-nativedep to include explicit mac detection support.

20:50 Are codox & marginalia still the "standard" for documentation?

20:58 Apparently codox still doesn't work on windows

21:51 * rritoch released clj-nativedep v0.2.0 @ https://github.com/rritoch/clj-nativedep & clojars

23:11 mindbender1: What does a process mean in the context used on the transducers page at http://clojure.org/transducers?

Logging service provided by n01se.net