This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-03-31
Channels
- # admin-announcements (1)
- # beginners (16)
- # boot (25)
- # braid-chat (7)
- # cider (4)
- # cljsfiddle (6)
- # cljsrn (1)
- # clojure (256)
- # clojure-austin (4)
- # clojure-ireland (1)
- # clojure-poland (15)
- # clojure-russia (80)
- # clojure-uk (2)
- # clojurescript (30)
- # core-async (14)
- # core-typed (3)
- # cursive (35)
- # datomic (1)
- # editors (28)
- # hoplon (32)
- # immutant (1)
- # jobs (8)
- # jobs-discuss (1)
- # juxt (6)
- # leiningen (8)
- # liberator (7)
- # off-topic (16)
- # om (69)
- # onyx (38)
- # re-frame (10)
- # spacemacs (1)
- # untangled (117)
я как-то спрашивал про библиотеку для конфига – нашел наконец практически идеальный вариант: https://github.com/AvisoNovate/config
можно писать в .edn или .yaml; читать из ENV; выставлять разные профайлы по приоритету (типа :profiles [:default :dev :local]
), и он грамотно все замерджит, а отсутствующие файлы проигнорирует (например, local.yaml какой-нибудь) + конфиги валидируются schema и еще есть фишки для работы с component.
осталось это соединить с фетчилкой конфига из консула
надеюсь, кому-нибудь тоже пригодится! хотя сейчас понимаю, что это самому написать не проблема.
правда все равно пришлось немного поковыряться, чтобы это заработало с boot и динамически подгружало разные профайлы в зависимости от APP_ENV.
1. для clj мега удобно пользоваться биндингом C-c C-x
и приконнектить к нему рестарт system-map
(если конечно вы пользуетесь component) - что то вроде
(setq cider-refresh-before-fn "user/stop-system" cider-refresh-after-fn "user/start-system")
2. для cljs у меня была проблема прикрепить красиво фигвилл, чтобы при запуске второго репла в емаксе фигвил сразу инициировался и был готов у бою
(setq cider-cljs-lein-repl "(do (require 'user) (user/start-cljs) (user/repl-cljs))”)
Не знаю, может быть это тривиально было для всех кто пользуется cider+clojure каждый день
@sasha а что именно подробнее? пишешь в yesql
-- name: callSmth
CALL procName(:arg)
и все, работаешь как и с остальными запросамиЭрик на курсере (или удасити, или где-то еще) вел курс о FP с Хаскелем, как базовым языком. можно поискать его.
@sasha что-то типа
(defn call-proc [conn param]
(log/info (str "connection " conn))
(with-open [stmt (.prepareCall (:connection conn) "{call proc_name(?)}")]
(.setString stmt 1 param)
(loop [res (.execute stmt)
results []]
(if res
(do
(let [rs (.getResultSet stmt)
results (conj results (doall (jdbc/result-set-seq rs)))]
(.close rs)
(recur (.getMoreResults stmt)
results)))
results))))
@batsuev: а что-то типа http://ado.net не попадалоись на глаза случайно вам?
фактически это то же самое что и yesql, только там можно нормально работать с хранимыми процедурами и т.д.
user> (type (:quantity z))
java.lang.Integer
user> (type (:cancelled_quantity z))
java.lang.Integer
user> (type (- (:quantity z) (:cancelled_quantity z)))
java.lang.Long
есть идеи, что происходит?yeah but docs say:
clojure.core/-
([x] [x y] [x y & more])
If no ys are supplied, returns the negation of x, else subtracts
the ys from x and returns the result. Does not auto-promote
longs, will throw on overflow. See also: -'
user=> (type (+ Integer/MAX_VALUE 1))
java.lang.Long
user=> (type (+ Long/MAX_VALUE 1))
ArithmeticException integer overflow clojure.lang.Numbers.throwIntOverflow (Numbers.java:1501)
задублирую сюда тоже, может кто быстрее подскажет hi everyone! I have this problem with compojure and multiple middlewares I use components
:site-handler (handler-component (:site-app config))
:http (jetty-server (:http config))
:site-endpoint (endpoint-component site-endpoint)
:api-endpoint (endpoint-component api-endpoint)
with deps
:http [:site-handler]
:site-handler [:site-endpoint :webhook-endpoint :api-endpoint]
:site-endpoint {:db :db
:input-chan :notification-worker-in-channel}
:api-endpoint {:db :db
:channel :notification-worker-in-channel}
in site routes I have something like this:
(defn site-endpoint [{{db :spec} :db input-chan :input-chan}]
(-> (routes
;; more routes
(POST "/send-message/:channel-id" [channel-id :<< as-int :as request]
(message-route/send-message db input-chan channel-id request))
(resources "/"))
(wrap-routes (fn [handler]
(-> handler
(wrap-access-rules {:rules rules :on-error on-error})
(buddy-middleware/wrap-authorization backend)
(buddy-middleware/wrap-authentication backend)
(defaults/wrap-defaults defaults/site-defaults)
)))))
and in api
(defn api-endpoint [{{db :spec} :db channel :channel}]
(api
{:swagger {:ui "/api-docs"
:spec "/swagger.json"
:data {:info {:title "PushToTelegram Public API"}}
}}
(context "/api" []
(GET "/send/channelMessage" []
:return {:channel-id s/Int
:recipients-count s/Int}
:query [message ApiChannelMessage]
(api-route/send-channel-message db channel message))
)))
and then in handler component they are combined with (routes api-routes site-routes)
in post route I have ring antiforgery exception, because of api-middleware, and the only way I can fix it is to wrap api routes with some context, e.x (context "/my-api" [] (api ;; etc))
but then I have swaggers docs broken with wrong api urls
What is the right way to split api and site routes in web app?народ, какой там аналог https://ocaml.org/learn/tutorials/99problems.html для кложуры?
я прорешивал https://projecteuler.net/
во, первое, не мог вспомнить @rmuslimov: спасибо!
может кому-то будет интересно - немножко про устройство структур данных в кложурке - http://fxposter.github.io/persistent-data-structures-presentation/
кстати по 4clojure -- я могу смотреть решения на кого я "подписался" или надо чтобы человек меня тоже зафрендил?
https://www.youtube.com/watch?v=siUvJN4FoVY&feature=youtu.be ссылка на сам доклад (он немного фейловый, но тем не менее)
господа, а compojure или ring из коробки не умеет query-params нормально в json отобразить?
кажется, это проще закодить т.к. сам по себе query-params не типизированы и все там строки
да ну его, там непонятное раскрытие макросов и куча куда, у меня все гораздо лаконичнее вышло