我正在开发一个Clojure webnoir应用程序,我需要构建一个回调网址(对于Twitter oauth),它在开发模式下与在生产模式下不同.在开发模式下,它需要 localhost:8080/smth和生产(heroku)显然是其他类似的东西http://smooth-lightning-xxxx.herokuapp.com/smth.如何以localhost:8080编程方式获取零件defpage?
如果在Dropbox文件夹中托管代码仓库并与其他协作的人共享,该怎么办?如果两个人同时推送到Dropbox仓库会怎么样?这会导致混乱git的冲突吗?
我有这个webnoir webapp作为Eclipse项目.您可以在此处下载:http://dl.dropbox.com/u/3914693/practicum5.zip
当我启动它时,使用Eclipse中的-main函数,似乎找不到resources文件夹(我在/css/tictactoe.css上获得了404).我有什么改变才能让它发挥作用?
对于那些不知道什么*print-length*代表的人:
如果您(set! *print-length* 200),并且您(range)在 REPL 中计算,这通常会导致打印无限的数字列表,则只会打印前 200 个数字。
我正在尝试将其设置为profiles.clj. 现在我得到了这个,但它不起作用:
{:user {:plugins [[lein-swank "1.4.4"]
[lein-catnip "0.5.0"]]
:repl-options {*print-length* 200}}
:dev {:dependencies [[clj-ns-browser "1.2.0"]
[org.clojure/tools.trace "0.7.5"]]}}
Run Code Online (Sandbox Code Playgroud)
这有什么问题?
更新。Tnx Michal 回答了这个问题。我的固定profiles.clj现在看起来像这样。请注意,它仅适用于项目内部。
{:user {:plugins [[lein-swank "1.4.4"]
[lein-catnip "0.5.0"]]
:repl-options {:init (set! *print-length* 200)}}
:dev {:dependencies [[clj-ns-browser "1.2.0"]
[org.clojure/tools.trace "0.7.5"]]}}
Run Code Online (Sandbox Code Playgroud) 我有一个点文件,我想转换为ps或png.Graphviz安装brew在OS X Yosemite上.但是,dot无法使用以下输出进行转换:
Borkdude@macbookair-michiel /tmp $ dot -Tps foo.dot -o foo.ps
Format: "ps" not recognized. Use one of:
Run Code Online (Sandbox Code Playgroud)
下一步去哪儿看?
我的查询基本上是一个select *.在开发中,这个表只有30000行,但在生产中它会更大.所以我想懒洋洋地使用这个查询.为什么下面的查询不是懒惰的?我正在使用Postgres 9.5.4.1.
(do
(def pg-uri {:connection-uri "jdbc:postgresql://localhost/..."})
(def row (atom 0))
(take 10 (clojure.java.jdbc/query
pg-uri
["select * from mytable"]
{:fetch-size 10
:auto-commit false
:row-fn (fn [r] (swap! row inc))}))
@row) ;;=> 300000
Run Code Online (Sandbox Code Playgroud) 表达式的时间复杂度是多少
(doall (take n (distinct stream)))
Run Code Online (Sandbox Code Playgroud)
其中stream是懒惰地生成具有重复(可能是无限的)集合?
我猜这部分取决于重复的数量或机会stream?如果stream在(repeatedly #(rand-int m)))哪里 m >= n呢?
我的估计:
对于结果列表中的每个元素,必须从流中至少实现一个元素。如果流中有重复项,则为多个。对于每次迭代,都有一个设置的查找和/或插入,但是由于它们接近恒定的时间,所以我们至少得到了:O(n*~1) = O(n)然后,重复项变得有些复杂。我的直觉是,也可以忽略重复项的复杂性,但是我不确定如何将其形式化。例如,我们不能只说某个常数为O(n*k*~1)= O(n),k因为在流中没有明显的最大k重复数。
让我用一些数据演示问题:
(defn stream [upper distinct-n]
(let [counter (volatile! 0)]
(doall (take distinct-n
(distinct
(repeatedly (fn []
(vswap! counter inc)
(rand-int upper))))))
@counter))
(defn sample [times-n upper distinct-n]
(->> (repeatedly times-n
#(stream upper distinct-n))
frequencies
(sort-by val)
reverse))
(sample 10000 5 1) ;; ([1 10000]) …Run Code Online (Sandbox Code Playgroud) 我不明白以下代码中的标签“:<>” clojure re-frame todomvc
(defn todo-app
[]
[:<>
[:section#todoapp
[task-entry]
(when (seq @(subscribe [:todos]))
[task-list])
[footer-controls]]
[:footer#info
[:p "Double-click to edit a todo"]]])
Run Code Online (Sandbox Code Playgroud)
谁可以帮我这个事?
我们有一张m1包含数百万条记录的表格.我们希望生成一个表格,m2其中包含每个记录的计算结果m1.我们目前运行如下:
(jdbc/with-db-transaction [tx connection]
(jdbc/query tx
[(jdbc/prepare-statement (:connection tx)
"select * from m1"
{:fetch-size 1000})]
{:result-set-fn (process! [tx result-set] ...)}))
Run Code Online (Sandbox Code Playgroud)
这里process!是
(defn process! [tx result-set]
(jdbc/with-db-transaction [tx tx]
(jdbc/insert-multi! tx :m2 [:m2_column]
(mapv (fn [r] [(calculate r)])
result-set))))
Run Code Online (Sandbox Code Playgroud)
该select查询使用游标并懒洋洋地消耗掉.请参阅:clojure.java.jdbc延迟查询.这就是它被包装在外部事务中的原因.
问题:
如何在有效的Postgres SQL查询中编写以下内容:
with foo as (select * from ...)
insert into bar select * from foo
insert into baz select * from foo
Run Code Online (Sandbox Code Playgroud)