This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-25
Channels
- # aws (2)
- # aws-lambda (2)
- # beginners (95)
- # boot (47)
- # cider (13)
- # clara (5)
- # cljs-dev (36)
- # cljsjs (9)
- # clojure (51)
- # clojure-austin (1)
- # clojure-greece (25)
- # clojure-italy (4)
- # clojure-japan (10)
- # clojure-russia (13)
- # clojure-spec (61)
- # clojure-uk (25)
- # clojurescript (26)
- # core-matrix (5)
- # cursive (8)
- # data-science (7)
- # datomic (43)
- # dirac (2)
- # emacs (8)
- # events (3)
- # fulcro (17)
- # graphql (29)
- # jobs-rus (4)
- # lambdaisland (4)
- # lein-figwheel (3)
- # leiningen (60)
- # luminus (15)
- # lumo (8)
- # mount (3)
- # off-topic (28)
- # om (22)
- # onyx (115)
- # other-languages (6)
- # pedestal (5)
- # re-frame (41)
- # reagent (12)
- # ring-swagger (12)
- # shadow-cljs (127)
- # unrepl (27)
- # yada (5)
can someone help me. I'm trying to generate csv file on the fly. using
. and it works when I'm doing it with get
request. In my case though I have to do it with post request (because data gets composed via om.next/parser). So this, kinda works:
(defn download-csv [req]
(let [result (run-om-query (:body req) (:user req))
query-k (-> req :body ffirst)
data (get-in result [query-k :data])]
{:status 200
:headers {"Content-Type" "text/csv"
"Content-disposition" "attachment; filename=filename.csv"}
:body (ring-io/piped-input-stream
(fn [out]
(let [columns (-> data first keys)]
(with-open [wtr (io/writer out)]
(csv/write-csv wtr [columns])
(doseq [row data]
(csv/write-csv wtr [(map row columns)]))))))}))
but browser doesn't "recognize it". no "dowload to" popup comes up, etc.i use https://github.com/eligrey/FileSaver.js but that is browser side, don't know if that helps
has a cljsjs wrapper
the content it returns from server is fine - it is correct csv. but browser doesn't recognize it as "file download"
as I said - if I ignore the om.parser part, and generate just random csv and use get
, instead of post
it works just fine - I don't even have to set the correct content-type and other headers
I like using emacs for clojure, is there a way to do code autocompletion, i'm using inferior-clojure module
ok, cool. Will check
How about treating vars like ns alias so we can use shorthand for creating keywords associated with a fn like ::myfn/props
does anyone have any experience with hugsql (https://www.hugsql.org/)? i'm trying to debug some tricky sql statements and i'd like to see what sql statement hugsql is generating under the hood.
;; For most HugSQL usage, you will not need the sqlvec functions.
;; However, sqlvec versions are useful during development and
;; for advanced usage with database functions.
(hugsql/def-sqlvec-fns "princess_bride/db/sql/characters.sql")
take a look at def-sqlvec-fnsFor myself I found it very useful
@joshkh the best option would be to check your DB logs. Configure your database to log all the queries into a file. Or you may run the database not as a service but as process. So you’ll see all the queries in the console. For postgres, start it with
postgres -E -D /usr/local/var/postgres
(on Mac)
I want some debug msgs to dump FILE__ so it's easy to figure out where they are coming from
You can use (meta #'any-function-or-variable) ;; => {:line 13, :column 1, :file "path/to/file.clj", :name var-name, :ns #namespace[namespace-where-var-defined]}
:file is related to your classpath
https://clojure.org/reference/metadata there are more information about this
@dominicm: not quite tools.logging: it's ... I'm looking at this cljs app, I see this div, whose body says "todo" -- I want to kow where this "todo" is coming from -- so I grep for "todo" in my source tree -- and I get many matches, so I'd really prefer is that div said "todo: foobart.clj: line 74" instead of just "todo"
@qqq you need a macro which looks at *ns*
, which is how this is done in tools logging
@dominicm, @delaguardo: going with @delaguardo’s meta solution 🙂
I know what I ca ndo (io/copy in out) -- however, is there a nice way to inject a "gunzip" in the middle of it?
@qqq GZIPInputStream https://docs.oracle.com/javase/7/docs/api/java/util/zip/GZIPInputStream.html
very easy to use in my experience
I was just doing this and found a cookbook recipe: https://github.com/clojure-cookbook/clojure-cookbook/blob/master/04_local-io/4-21_read-write-gzip.asciidoc
nice, I did not reailze you could just 'wrap' java.util.zip.GZIPInputStream. and have it take care of the rest
I am looking for advice to connect to a Mysql Database. I am using jbdc and mysql/mysql-connector-java plugin to run a simple query to my database. however, the connection does not seem to connect (to a my local environment) and not able to pull any data. Does anyone know any helpful tutoriasl or walk-throughs to help me connect to a db. error messages: 1. {user=, password=}, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ] 2. Cannot JSON encode object of class: class [B: [B@2466ff66
I would look at the stacktrace for 2, my bet is you have other library loaded that globally extends jdbc to automatically json encode things
1 looks like something from a connection pooling library, which again leads me to believe you are dealing with a much larger pile of code then your question suggests
Does anyone know if there's a 'Storm' channel? Specifically using Clojure spouts/bolts with Storm.
There is not. You might as well ask questions here and see if anyone responds...
Hey guys, I’m looking for some resources/examples of speccing and unit testing database transactions in Clojure w/ clojure.java.jdbc (for now). Does anyone have a project or resource they can point me to for testing functions for reads, writes, and deletes?
@admay Perhaps start with clojure.java.jdbc
's own test suite? Your question is a bit vague so I'm not sure what you're really asking.
(I would also say that "unit testing" and "database transactions" don't really go together -- that's more of an "integration test")
So I have a bunch of functions like (fetch-from-db ...)
, (insert-into-db! ...)
, (delete-from-db! ...), and
(update-in-db!)` that I need to test in order to pass my companies ‘code coverage’ standards and I’m not quite sure how to go about it. Like you said, ‘unit testing’ and ‘database transactions’ don’t really go together. I’m absolutely open to another approach given I’m very new to unit/integration testing as long as they’re automated. The automation is non-negotiable as per company standards.
if you separate all logic into functional data to data transforms without side effects, the part where you talk to the db can be a very small stub that should already be tested by the library you are using
if they ask you to test interaction with the db lib, then you need integration testing instead of unit testing, and someone needs to hook up a db for that testing environment
This also highlights the disadvantage of writing wrappers for things that clojure.java.jdbc
already does since you are now creating extra code that you need to "test" to pass an arbitrary code coverage rule 🙂
(as well as actually creating a layer of logic where regressions can occur)
In order to test that insert-into-db!
"does the right thing" you'd need to read the data back in and assert it matches your expectations -- which means that your tests rely on fetch-from-db
which is a bit circular. And how would you test that fetch-from-db
is doing the right thing? (would you insert-into-db!
and then fetch-from-db
and compare the result? Again, circular)