workspace
stringclasses
4 values
channel
stringclasses
4 values
text
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
clojurians
clojure
Sure - it's hard for me to say without seeing a more detailed curriculum of course, just a thought. I think people could save a lot of trouble if they were more pragmatic about using host interop
2017-11-23T16:13:49.000054
Margaret
clojurians
clojure
Pretty sure you do `space 1` for the first pane, `space 2` for the second and so on - unless I misunderstand the question.
2017-11-23T16:15:38.000160
Rene
clojurians
clojure
Hi, I tried to do something like this in jdbc and get an Exception: ``` (j/db-do-prepared (:user-db @g-config) ["select case when (select 1 from user_favorstocks where uid=1823 and stockid='600123.SH') is not null then (select 8) else (select 5) end as tmp"]) ``` `SQLException SQL String can not be NULL com.mysql.jdbc.SQLError.createSQLException (SQLError.java:957)`
2017-11-24T03:27:39.000279
Tari
clojurians
clojure
what could be the reason?
2017-11-24T03:28:09.000026
Tari
clojurians
clojure
<@Tari>, don't you need to prepare the statement first?
2017-11-24T03:29:55.000188
Fe
clojurians
clojure
maybe not
2017-11-24T03:30:17.000402
Tari
clojurians
clojure
`The sql parameter can either be a SQL string or a PreparedStatement.` in clojure.java.jdbc doc
2017-11-24T03:30:39.000033
Tari
clojurians
clojure
and here is the test code:
2017-11-24T03:30:55.000294
Tari
clojurians
clojure
``` (deftest test-do-prepared4 (doseq [db (test-specs)] (create-test-table :fruit2 db) (sql/db-do-prepared db ["INSERT INTO fruit2 ( name, appearance, cost, grade ) VALUES ( ?, ?, ?, ? )" ["test" "test" 1 1.0] ["two" "two" 2 2.0]] {:multi? true}) (is (= 2 (sql/query db ["SELECT * FROM fruit2"] {:result-set-fn count}))))) ```
2017-11-24T03:31:00.000003
Tari
clojurians
clojure
on <https://searchcode.com/file/138699/src/test/clojure/clojure/java/test_jdbc.clj>
2017-11-24T03:31:09.000160
Tari
clojurians
clojure
maybe you're looking for `execute!`?
2017-11-24T03:31:10.000404
Fe
clojurians
clojure
I've tried that seems not working.
2017-11-24T03:31:31.000261
Tari
clojurians
clojure
`SQLException Can not issue executeUpdate() or executeLargeUpdate() for SELECTs com.mysql.jdbc.SQLError.createSQLException (SQLError.java:957)` if I change to `execute!`
2017-11-24T03:31:58.000039
Tari
clojurians
clojure
btw, can I do an `insert` stmt in a `then` subclause?
2017-11-24T03:32:52.000278
Tari
clojurians
clojure
ah you need `query`
2017-11-24T03:33:34.000145
Fe
clojurians
clojure
`execute!` is only for "write"-y queries (INSERT, UPDATE, etc.)
2017-11-24T03:34:29.000051
Fe
clojurians
clojure
I am just trying to select something from the table, and if found, check the value of some column ( and if satisfied some condition do update, otherwise nothing ), if not ,do insert. And return a value that tells me what has been done.
2017-11-24T03:34:29.000102
Tari
clojurians
clojure
yes, but can I do an `insert` in a `then` subclause when using `query`?
2017-11-24T03:35:14.000240
Tari
clojurians
clojure
you're shifting the goalposts
2017-11-24T03:35:25.000042
Fe
clojurians
clojure
better to ask one thing at a time, not "everything I've always wanted to know about SQL"
2017-11-24T03:36:08.000139
Fe
clojurians
clojure
:smile:
2017-11-24T03:36:30.000357
Tari
clojurians
clojure
sorry for that.
2017-11-24T03:36:47.000126
Tari
clojurians
clojure
`query` works!
2017-11-24T03:37:12.000006
Tari
clojurians
clojure
you can't nest INSERT inside of a compound statement - you'll need to do multiple queries, or use a stored procedure I think
2017-11-24T03:37:51.000084
Fe
clojurians
clojure
Thanks.
2017-11-24T03:38:33.000223
Tari
clojurians
clojure
I tried to write a stored procedure but `ERROR 1548 (HY000): Cannot load from mysql.proc. The table is probably corrupted` happens. But it is not right to ask this here. It seems the mysql version is too old. some `5.1` version.
2017-11-24T03:39:44.000241
Tari
clojurians
clojure
Is it possible to utilize java annotations from clojure?
2017-11-24T03:48:48.000218
Jodie
clojurians
clojure
<@Jodie> maybe this? <https://github.com/clojurebook/ClojureProgramming/tree/master/ch09-annotations>
2017-11-24T04:10:09.000143
Tari
clojurians
clojure
<@Tari> perfect. Thanks. Completely missed that.
2017-11-24T04:11:43.000364
Jodie
clojurians
clojure
I want to use `migratus` in my dev environment. I also use `environ` to manage environments variables. How can I set a value in my `project.clj` by evaluating data from `environ`? working example: ```clojure :migratus {:store :database :migration-dir "migrations" :db "<postgresql://postgres:pass@localhost/xchange>"} ``` What I want: ```clojure ```
2017-11-24T05:56:52.000216
Mina
clojurians
clojure
``` :migratus {:store :database :migration-dir "migrations" :db ~(environ.core/env :db-url)} ```
2017-11-24T05:57:24.000108
Mina
clojurians
clojure
<@Mina> `:migratus {:store :database :db ~(get (System/getenv) "DATABASE_URL")}`
2017-11-24T06:17:55.000212
Verna
clojurians
clojure
<@Mina> the rule is simple: once lein sees a list form, it tries to evaluate it.
2017-11-24T06:18:31.000280
Verna
clojurians
clojure
But using `environ`, my `DB_URL` is not in the `System/getenv` map
2017-11-24T06:19:25.000338
Mina
clojurians
clojure
Can `(let [...] (defn ...))` be problematic? (generally I'd never do that, but from time to time I need some dynamism e.g. defns emitted from macros)
2017-11-24T06:39:18.000026
Kristy
clojurians
clojure
Not that I know of; `(def fname (let [,,,] (fn ,,,)))` may be more conventional
2017-11-24T12:56:58.000044
Danyel
clojurians
clojure
Thanks for the input! Might end up using that one
2017-11-24T13:01:10.000046
Kristy
clojurians
clojure
I’m using stuartsierra component and can’t figure out how to fix this error anyhow. any hints would be much appreciated: ``` IllegalArgumentException No implementation of method: :stop of protocol: #'com.stuartsierra.component/Lifecycle found for class: nil clojure.core/-cache-protocol-fn (core_deftype.clj:568) ``` this is my application: ``` (ns application.system (:require [application.web :refer [app]] [com.stuartsierra.component :as component] [org.httpkit.server :refer [run-server]])) (defn- start-server [handler port] (run-server app {:port port}) (println "Started server on localhost" port)) (defn- stop-server [server] (when server (server))) (defrecord Application [] component/Lifecycle (start [this] (assoc this :server (start-server #'app 9009))) (stop [this] (stop-server (:server this)) (dissoc this :server))) (defn create-system [] (Application.)) (defn -main [&amp; args] (.start (create-system))) ```
2017-11-24T15:20:00.000225
Tameka
clojurians
clojure
<@Tameka> that error means one of your components returns nil instead of a valid component
2017-11-24T15:21:31.000088
Margaret
clojurians
clojure
(probably from a start method)
2017-11-24T15:21:48.000079
Margaret
clojurians
clojure
but it relates to this Application component right?
2017-11-24T15:22:27.000072
Tameka
clojurians
clojure
how would I know?
2017-11-24T15:22:49.000001
Margaret
clojurians
clojure
one of your components, when started, returns nil instead of a component
2017-11-24T15:23:00.000008
Margaret
clojurians
clojure
that's what causes that error
2017-11-24T15:23:06.000010
Margaret
clojurians
clojure
unless you call stop on the wrong object and it was not your component in the first place
2017-11-24T15:23:17.000238
Margaret
clojurians
clojure
:smile: well this is my whole application, so .. it has to be here
2017-11-24T15:24:19.000036
Tameka
clojurians
clojure
somewhere
2017-11-24T15:24:20.000131
Tameka
clojurians
clojure
OK - nothing in that code is calling the stop method
2017-11-24T15:25:08.000026
Margaret
clojurians
clojure
who calls the stop method?
2017-11-24T15:25:12.000100
Margaret
clojurians
clojure
I don't know component at all, but should 'start-server' return anything? It's returning nil at the moment.
2017-11-24T15:25:21.000037
Bibi
clojurians
clojure
<@Bibi> that's the error, good eye
2017-11-24T15:25:46.000092
Margaret
clojurians
clojure
<@Tameka> - println returns nil, so start-server returns nil
2017-11-24T15:26:23.000052
Margaret
clojurians
clojure
ah damn it should be the other way round
2017-11-24T15:26:49.000139
Tameka
clojurians
clojure
we still don't know what is calling stop, but that's what is causing the error
2017-11-24T15:26:53.000034
Margaret
clojurians
clojure
yeah that was the issue. I had to have them other way round
2017-11-24T15:31:14.000110
Tameka
clojurians
clojure
now the server instance is returned and life is good
2017-11-24T15:31:24.000007
Tameka
clojurians
clojure
… again
2017-11-24T15:31:29.000044
Tameka
clojurians
clojure
Do you know about the system library?
2017-11-24T15:34:56.000119
Bertram
clojurians
clojure
<https://github.com/danielsz/system>
2017-11-24T15:35:15.000130
Bertram
clojurians
clojure
It looks like it could be helpful based on your recent questions in the channel.
2017-11-24T15:35:53.000044
Bertram
clojurians
clojure
Also lots of examples in the repo
2017-11-24T15:36:13.000060
Bertram
clojurians
clojure
is there a clojure builtin for "take this vec of 5 elements, pad it to a list of 10 elemes by adding :null" 's ?
2017-11-24T17:34:55.000105
Berry
clojurians
clojure
basically, "make this vec longer by repeating this elem"
2017-11-24T17:35:08.000105
Berry
clojurians
clojure
no builtin, I'd use concat and repeat (concat coll (repeat 5 nil)) or (take 10 (concat coll (repeat nil)))
2017-11-24T17:39:55.000123
Margaret
clojurians
clojure
`(first (partition 10 10 (repeat :b) [:a]))`
2017-11-24T17:40:01.000113
Willow
clojurians
clojure
you could partition with a pad and take the first partition
2017-11-24T17:40:08.000058
Willow
clojurians
clojure
although i think the take concat version is nicer
2017-11-24T17:40:26.000089
Willow
clojurians
clojure
For those who use Docker, any reason to use java image instead of clojure image ?
2017-11-24T19:29:49.000031
Bebe
clojurians
clojure
I've found making an uberjar (either on my machine or a build server) and then deploying as if it was java keeps things simple
2017-11-24T19:32:52.000088
Margaret
clojurians
clojure
I was thinking of a workflow including ansible &amp; docker. Maybe it's better to just stick to ansible
2017-11-24T19:38:38.000091
Bebe
clojurians
clojure
Is docker more popular right now for production Clojure apps?
2017-11-24T19:41:11.000027
Giovanni
clojurians
clojure
I saw some snippets to build &amp; deploy with docker, but it seems a bit old and use java image instead of clojure one
2017-11-24T19:46:48.000016
Bebe
clojurians
clojure
I'm about to deploy for the first time, what is the "safe" bet?
2017-11-24T19:48:46.000089
Giovanni
clojurians
clojure
the simplest thing is to make an uberjar, make sure there's a jvm on your server, and run it
2017-11-24T19:49:29.000024
Margaret
clojurians
clojure
I was thinking that docker container networking might be a better fit for me because I want a local database connection. How do Clojarians typically handle that sort of situation?
2017-11-24T19:56:08.000023
Giovanni
clojurians
clojure
I've used dedicated database servers, so can't offer anything on that
2017-11-24T19:57:01.000032
Margaret
clojurians
clojure
though with mongo, we do have a mongo server process for sharded dbs, that's set up by chef in our case
2017-11-24T19:57:44.000002
Margaret
clojurians
clojure
(I think using ansible would be very similar)
2017-11-24T19:58:15.000031
Margaret
clojurians
clojure
<@Giovanni> <https://www.reddit.com/r/java/comments/46ksv2/why_bother_with_docker_deployments_when_jars_are/>
2017-11-24T20:31:49.000018
Bebe
clojurians
clojure
Ah and I found this: <http://www.capsule.io/>
2017-11-24T20:32:34.000033
Bebe
clojurians
clojure
:slightly_smiling_face:
2017-11-24T20:32:34.000078
Bebe
clojurians
clojure
This seems to confirm my suspicion that the benefits of solo UberJar is that simple deployment is easy, but doing anything non-trivial becomes a nightmare and the benefits of containers being that it can manage high amounts of deployment complexity, but is pretty heavy and frustrating to set up. Thanks for the resources, I'll have to ponder more what fits for my use case
2017-11-24T20:36:00.000057
Giovanni
clojurians
clojure
"nightmare" is not my experience
2017-11-24T20:36:18.000072
Margaret
clojurians
clojure
That's good to hear! Does the box running your UberJar have other dependencies that lein doesn't support?
2017-11-24T20:37:27.000086
Giovanni
clojurians
clojure
I know you mentioned mongo, but I imagine you can keep the config inside of your .clj
2017-11-24T20:37:57.000072
Giovanni
clojurians
clojure
it has a few local deps that are set up by chef (I am not the one managing ops / chef stuff though)
2017-11-24T20:38:03.000024
Margaret
clojurians
clojure
there's a mongo program that you need to run, it's not a client thing
2017-11-24T20:38:19.000103
Margaret
clojurians
clojure
(for sharded dbs)
2017-11-24T20:38:25.000063
Margaret
clojurians
clojure
basically it's a mongo server running on localhost that interacts with the sharded system, because the client can't use it directly
2017-11-24T20:39:12.000081
Margaret
clojurians
clojure
I'll have to consider the UberJar setup more seriously considering your positive experience. All of my professional dev is done on 'Nix boxes, and I'm a huge 'nix buff so I normally wouldn't shy away so much, but I have a few other portability considerations this time around.
2017-11-24T20:40:54.000006
Giovanni
clojurians
clojure
yeah, even just the differences between OSX and Linux are a pain, and I see how a container helps there
2017-11-24T20:41:29.000068
Margaret
clojurians
clojure
Two startups in a row we’ve deployed services in docker and never regretted it. “Pretty heavy” and “frustrating” have not been our experience.
2017-11-24T20:41:45.000035
Kyung
clojurians
clojure
but an uberjar is an uberjar, and it really does work
2017-11-24T20:41:48.000061
Margaret
clojurians
clojure
Thanks <@Kyung>, I haven't heard of many people regretting dockerizing. I didn't mean to use such bold words! :slightly_smiling_face: I'm just trying to view my options for their _upsides_ and their _downsides_.
2017-11-24T20:44:51.000031
Giovanni
clojurians
clojure
I really don't think either option will cause too many problems. I'm thinking docker would give me a bit of the agility I'm after
2017-11-24T20:46:46.000092
Giovanni
clojurians
clojure
Thanks much for the answers
2017-11-24T20:47:24.000043
Giovanni
clojurians
clojure
<@Kyung> did you use java or clojure image ? just curious :slightly_smiling_face:
2017-11-24T20:48:26.000012
Bebe
clojurians
clojure
Custom images.
2017-11-24T21:03:06.000049
Kyung
clojurians
clojure
regardless of the solution you pick, I would like to advocate for having a separate build server or process, that isn't something run on your production server (eg. let circleci create your uberjar and upload it, and download it from your server process)
2017-11-24T21:04:39.000076
Margaret
clojurians
clojure
In our case we built the docker images too, and we tagged (w/ version numbers) and uploaded those to a local docker image repository.
2017-11-24T22:00:07.000023
Kyung