Fork me on GitHub

I'd like to make a script to automatize my responses when my laptop battery is low. But I have no idea how can I calculate the battery, any ideas? (I don't know Java)

Rolfe Power00:04:06

You can try which could provide that capability

👍 3
💯 3

I’m making a multipart request to the server. Earlier the request was working, but now when I make the request, I get the following error:

2021-04-06 22:06:11,024 [manifold-pool-2-149] ERROR humboiserver.middleware - Stream ended unexpectedly 
org.apache.commons.fileupload.MultipartStream$MalformedStreamException: Stream ended unexpectedly
	at org.apache.commons.fileupload.MultipartStream$ItemInputStream.makeAvailable(
	at org.apache.commons.fileupload.MultipartStream$
	at $fn__11530.invokeStatic(io.clj:305)
	at $fn__11530.invoke(io.clj:302)
	at clojure.lang.MultiFn.invoke(
	at $fn__11534.invokeStatic(io.clj:321)
	at $fn__11534.invoke(io.clj:319)
	at clojure.lang.MultiFn.invoke(
	at $copy.invokeStatic(io.clj:406)
	at $copy.doInvoke(io.clj:391)
	at clojure.lang.RestFn.invoke(
	at ring.middleware.multipart_params.temp_file$temp_file_store$fn__39717.invoke(temp_file.clj:69)
	at ring.middleware.multipart_params$parse_file_item.invokeStatic(multipart_params.clj:84)
	at ring.middleware.multipart_params$parse_file_item.invoke(multipart_params.clj:76)
	at ring.middleware.multipart_params$parse_multipart_params$fn__9115.invoke(multipart_params.clj:94)
	at clojure.core$map$fn__5866.invoke(core.clj:2755)
	at clojure.lang.LazySeq.sval(
	at clojure.lang.LazySeq.seq(
	at clojure.lang.RT.seq(
	at clojure.core$seq__5402.invokeStatic(core.clj:137)
	at clojure.core$filter$fn__5893.invoke(core.clj:2809)
	at clojure.lang.LazySeq.sval(
	at clojure.lang.LazySeq.seq(
	at clojure.lang.LazySeq.first(
	at clojure.lang.RT.first(
	at clojure.core$first__5384.invokeStatic(core.clj:55)
	at clojure.core$first__5384.invoke(core.clj:55)
	at ring.middleware.multipart_params$parse_html5_charset.invokeStatic(multipart_params.clj:63)
	at ring.middleware.multipart_params$parse_html5_charset.invoke(multipart_params.clj:62)
	at ring.middleware.multipart_params$decode_string_values.invokeStatic(multipart_params.clj:67)
	at ring.middleware.multipart_params$decode_string_values.invoke(multipart_params.clj:66)
	at ring.middleware.multipart_params$parse_multipart_params.invokeStatic(multipart_params.clj:95)
	at ring.middleware.multipart_params$parse_multipart_params.invoke(multipart_params.clj:89)
	at ring.middleware.multipart_params$multipart_params_request.invokeStatic(multipart_params.clj:126)
	at ring.middleware.multipart_params$multipart_params_request.invoke(multipart_params.clj:111)
	at ring.middleware.multipart_params$wrap_multipart_params$fn__9126.invoke(multipart_params.clj:171)
	at ring.middleware.params$wrap_params$fn__9150.invoke(params.clj:67)
	at ring.middleware.cookies$wrap_cookies$fn__8841.invoke(cookies.clj:214)
	at ring.middleware.absolute_redirects$wrap_absolute_redirects$fn__9338.invoke(absolute_redirects.clj:47)
	at ring.middleware.resource$wrap_resource_prefer_resources$fn__9186.invoke(resource.clj:25)
	at ring.middleware.content_type$wrap_content_type$fn__9286.invoke(content_type.clj:34)
	at ring.middleware.default_charset$wrap_default_charset$fn__9310.invoke(default_charset.clj:31)
	at ring.middleware.not_modified$wrap_not_modified$fn__9252.invoke(not_modified.clj:61)
	at ring.middleware.x_headers$wrap_x_header$fn__8486.invoke(x_headers.clj:22)
	at ring.middleware.x_headers$wrap_x_header$fn__8486.invoke(x_headers.clj:22)
	at ring.middleware.x_headers$wrap_x_header$fn__8486.invoke(x_headers.clj:22)
	at humboiserver.middleware$wrap_internal_error$fn__9412.invoke(middleware.clj:17)
	at aleph.http.server$handle_request$fn__30032$f__25130__auto____30033.invoke(server.clj:158)
	at io.aleph.dirigiste.Executor$Worker$
	at manifold.executor$thread_factory$reify__25012$f__25013.invoke(executor.clj:44)
It gives a stream-ended unexpectedly error, and I don’t know what’s causing it. I didn’t change a single line of code, and it was working before, but now it doesn’t. How to debug this?


Some things to check: • Is the server running out of disk space? • Is it failing when uploading the same exact file or does it matter which file is being uploaded? • What size is the file? • What does the server do with the file that is uploaded? Is it being read immediately? • Are there any new intermediate proxies like nginx, a load balancer, cloudfront, etc? • What type of file is being uploaded? • Is compression being used? Have compression options changed?


Another tool to help debugging is to use Google Chrome's network console to gather more information: • Does the upload fail immediately? • Does the upload hang? • Does the upload make some progress before failing? • What headers are used? • What HTTP method is being used?

Noah Bogart15:04:09

I want to assoc some stuff onto a map, but skip certain keys depending on some conditionals. what's the best method for doing that?

Noah Bogart15:04:31

I want to avoid doing (-> m (assoc :key1 (when conditional? :value1) :key2 (when conditional2? :value2)) (prune-nils)) (where prune-nils is a function that iterates over a map and dissoc's any key that has a nil value)

Darin Douglass15:04:05

i've seen it as:

(merge m (when conditional? {:key1 :value1}) ...)
(cond-> m
  conditional? (assoc :key1 :value1)

Noah Bogart15:04:37

cond-> is exactly what I'm looking for, thank you! completely forgot about that one

👍 3

For the cases where there’s too many potential nils and you don’t want to check each one:

(defn clear-nils
 "Remove the keys from m for which the value is nil; O(N)"
  dissoc m
  (for [[k v] m :when (nil? v)] k)))
This solution specifically uses (dissoc …) so it should be a bit better in terms of perf than other solutions using (filter ...) et al; Still O(N), of course. Should not be used with large maps.

👍 3
Jeff Evans15:04:47

what am I doing wrong? trying to create a new deps.edn alias to start nREPL in an existing project. when running clojure -M:nREPL, I get the output about the remote debugger started (implying :jvm-opts was picked up correctly), but it fails with Could not locate nrepl/commandline__init.class, nrepl/commandline.clj or nrepl/commandline.cljc on classpath.

 {:nREPL {:extra-paths ["test"]
          :jvm-opts    ["-Dclojure.compiler.disable-locals-clearing=true" "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=15325"]
          :extra-deps  {nrepl/nrepl {:mvn/version "0.8.3"}}
          :main-opts   ["-m" "nrepl.commandline" "-b" "" -p "59173"]}}}


It’s nrepl.cmdline not nrepl.commandline

Jeff Evans15:04:50

thank you! I have no idea where that substitution came from. probably my own addled brain

Michael Stokley16:04:52

from "A History of Clojure" > As an application architect, working with databases taught me several important things about programming languages and their role in systems. The primary information model should not live in any application program. The more elaborate the type abstractions built up inside the programming language the less likely they would be shared by any other system participant, and the more involved and necessary marshaling would be to get in/out of the program’s model. what's Rich talking about here? having types in the application that aren't present - aren't formalized - in the persistence layer?


I took it as meaning “data should be the source of truth” (not code). So you want your primary information model to be something external to code, that all different parts of the system can read/interact with. That means very few types — only “universal” ones that all programs can read/manipulate.

👍 3

(numbers — but maybe also integers and floating point separately, strings, booleans, vectors, hash maps… dates are not quite universal for all sorts of reasons but they are an important “type” that we all have to agree on and work with and that’s hard)


As an example, C++ or Java class inheritance details are things that are typically not represented in databases, as far as I understand. And if you do, and the details of how that works is different from one programming language to another, putting those specifics in the persistent data means that writing a program in other languages to access it will be an unnatural act.

🙌 6
Alex Miller (Clojure team)20:04:41

They totally are represented in databases and people have whole schools of thought about how to do so :)


Wow, I stand corrected. I wish I didn't stand corrected 🙂


Would you say that these schools of thought somehow avoid unnatural acts across different programming languages trying to access the same database, if those programming languages have too-different OO language features?

Alex Miller (Clojure team)22:04:45

Oh, it’s all unnatural


Keeping this to a thread since it’s OT for beginners: Anyone remember the POET database? (or any other similar monstrosities?) 🙂


The article has a lot of nice things to say about it 🙂


“Object-oriented database management systems (also known as OODBMSs) are better suited than relational databases (such as SQL Server) for many of today’s new information types.” — but not for long 🙂


I've actually seen at least one kind of inheritance postgres supports used in production (

Alex Miller (Clojure team)20:04:01

Hibernate has a family of strategies for this iirc

Lennart Buit21:04:45

Yeah, Rails and Django (the webframeworks) have all sorts of ideas about this too in their ORMs


STI or Single Table Inheritance


speaking of using language specific types leading to extra cruft and boilerplate, It’s awesome that the work is being done to make cljs work great, but it would be nice if js wasn’t manufacturing extra work.