clojure

How to represent pivot table (with extra data on it) in datomic?

 ̄綄美尐妖づ 提交于 2020-06-01 05:29:09
问题 I realise that we don't need ordinary pivot tables in datomic because we can just pick one side of the relationship and put a :db.cardinality/many attribute on there (being sure to model the relationship in one direction only). The next thing I encounter in converting from sql is a pivot table that also stores an attribute on the relationship, like: series_subscriptions user_id int series_id int expires_at timestamp I was wondering what the options are to model this in datomic. I notice there

clojure: no cons cells

不问归期 提交于 2020-05-28 12:44:27
问题 i heard that clojure does not have cons cells as of most lisp languages. does that mean a clojure list does not end with an empty list? could anyone explain what that exactly means? 回答1: Lisp provides a primitive cons data structure and a notation for it. See John McCarthy, Recursive Functions of Symbolic Expressions and Their Computation by Machine, Part I, 1960, Chapter 3, Recursive Functions of Symbolic Expressions. That chapter introduces: Symbolic expressions made of atoms and pairs of

clojure: no cons cells

a 夏天 提交于 2020-05-28 12:44:03
问题 i heard that clojure does not have cons cells as of most lisp languages. does that mean a clojure list does not end with an empty list? could anyone explain what that exactly means? 回答1: Lisp provides a primitive cons data structure and a notation for it. See John McCarthy, Recursive Functions of Symbolic Expressions and Their Computation by Machine, Part I, 1960, Chapter 3, Recursive Functions of Symbolic Expressions. That chapter introduces: Symbolic expressions made of atoms and pairs of

how to have postgres ignore inserts with a duplicate key but keep going

早过忘川 提交于 2020-05-27 02:43:12
问题 I am inserting record data in a collection in memory into postgres and want the database to ignore any record that already exists in the database (by virtue of having the same primary key) but keep going with the rest of my inserts. I'm using clojure and hugsql, btw, but I'm guessing the answer might be language agnostic. As I'm essentially treating the database as a set in this way I may be engaging in an antipattern. 回答1: If you're using Postgres 9.5 or newer (which I assume you are, since

how to have postgres ignore inserts with a duplicate key but keep going

本秂侑毒 提交于 2020-05-27 02:41:06
问题 I am inserting record data in a collection in memory into postgres and want the database to ignore any record that already exists in the database (by virtue of having the same primary key) but keep going with the rest of my inserts. I'm using clojure and hugsql, btw, but I'm guessing the answer might be language agnostic. As I'm essentially treating the database as a set in this way I may be engaging in an antipattern. 回答1: If you're using Postgres 9.5 or newer (which I assume you are, since

Including JS files compiled using Figwheel to Uberjar built

感情迁移 提交于 2020-05-17 05:53:06
问题 Here is Figwheel config, app.cljs.edn ^{:watch-dirs ["src/cljs" "src/cljc"]} {:modules {:aff {:entries #{asaas.aff.aff} :output-to "target/public/js/aff.js"} :loc {:entries #{asaas.aff.loc} :output-to "target/public/js/loc.js"} :user {:entries #{asaas.user.user} :output-to "target/public/js/user.js"} :auth {:entries #{asaas.auth.auth} :output-to "target/public/js/auth.js"}} :output-dir "target/public/js/app" :asset-path "/js/app", } The problem is, it just works in dev . How should I go about

Clojure call series of functions and store their return values

帅比萌擦擦* 提交于 2020-05-15 09:33:07
问题 I'm building a datomic schema and have the following at the foot of my clj file which defines and transacts schema and initial data. The functions being called below each call d/transact . (defn recreate-database [] "To recreate db after running delete-database in bin/repl" (pt1-transact-schema) (pt1-transact-data) (pt2-transact-schema) (pt2-transact-data) (pt3-transact-schema) (pt3-transact-data)) By default we only see the return value of the last form, but I'd like to see, or save, the

How to find the path of keys to a value in a nested array map in Clojure?

左心房为你撑大大i 提交于 2020-05-15 05:00:05
问题 Supposing I had: (def a-map {:foo "bar" :biz {:baz "qux"}}) How would I find the path of keys to a given value "qux" such that (get-in a-map <the resulting path>) would return "qux"? In other words, a function that takes a-map and "qux" and returns [:biz :baz]. I would then be able to use the returned path like this: (get-in a-map [:biz :baz]) and get "qux". The paths I need are going to be far more nested than this simple example. I am wanting to find the path to a given value in html that

我只是个1x程序员,这是我五年总结出的经验法则

蹲街弑〆低调 提交于 2020-05-06 13:31:29
云栖号资讯:【 点击查看更多行业资讯 】 在这里您可以找到不同行业的第一手的上云资讯,还在等什么,快来! 作为一名 1x 开发人员,我在亚马逊五年的工作中总结了 20 条经验法则,希望能够在有限的自由时间内自我提升为 1.1X 开发人员。这些经验法则涉及生产力和学习、编程语言、技术、测试、DevOps、安全、设计和项目管理等领域。希望对大家有所启发。 序 言 我不是一个10x 开发人员。自从有了拨号上网以后,我就没有再建过网站。我在大学毕业几年之后才开始学习编程,因为我在政府和政治领域的职业生涯已经走到了瓶颈。 我写了五年代码了,这段时间都在亚马逊。在这期间,我还在养育三个孩子,我刚开始工作时,他们分别是 0 岁、0 岁和 2 岁。 所以我不是那种在晚上和周末还在努力加班的人。我很顾家。 大约一年前,我做了自己的第一个开源项目。这是我的第一个副业项目,它是一个会议网站。 我从来没有系统地从头到尾读过一本关于软件工程的书。 总之,我是一个 1x 开发人员。我为了体面的生活付出了足够的努力。我没有太多有普遍价值的东西要说,也没有太多时间去提升。 作为一个 1x 开发人员,我使用的是大量的传统智慧。 关于软件工程,我没有太多有趣或新鲜的东西可说。 总的来说,我还没有找到方法去从工作中抽出大量时间,或者去做一些更大的副业项目,或者去大量地阅读,又或者是去取得巨大的成就。我只是能抽点小空

神奇的Scala Macro之旅(一)- 什么时候用宏

泪湿孤枕 提交于 2020-05-02 10:24:56
在Lisp语言中,macro是一个神器,可以“动态的生成代码”,然后被执行,这种方式给到Lisp无限的表达能力。除Lisp之外,很少有语言支持Macro这个特性,我记得 GWT之中曾经有一个类似的Generator的概念,可以在编译期间提供一定的代码生成能力(GWT Project),很多GWT的高级特性都是通过这个语言特性而得以实现的,譬如: UiBinder 可以实现申明式的 UI 开发。 ImageBundle 简单的实现很多图片的聚合,从而减少round-trip,提高网页装载速度。 Scala自2.10开始尝试支持macro编程,2.11基本步入”成熟“阶段,2.12中基本稳定,不过,在最新的路线图中,Scala之父,Martin再次表现了将在未来的scala版本(Dotty)中重新设计macro,采用基于scalameta的一套编译器“中立”的元信息模型,试图让macro变得更简单、容易。因此,尝试 macro,目前仍然具有很大的风险性,或许随着scala语言的未来版本,现有的macro也需要重新迁移、实现。 What is Macro? 简而言之,macro就是让你的代码具备有生成代码的能力,最简单的macro可以算上 C/C++ 的 ##define, 最早的 C 程序员就广泛的使用 define 来生成代码。(严格意义上,C的define并不算是 macro)