clojure

Clojure: Convert hash-maps key strings to keywords?

半城伤御伤魂 提交于 2020-04-08 08:36:15
问题 I'm pulling data from Redis using Aleph: (apply hash-map @(@r [:hgetall (key-medication id)])) The problem is this data comes back with strings for keys, for ex: ({"name" "Tylenol", "how" "instructions"}) When I need it to be: ({:name "Tylenol", :how "instructions}) I was previously creating a new map via: { :name (m "name"), :how (m "how")} But this is inefficient for a large amount of keys. If there a function that does this? Or do I have to loop through each? 回答1: There is a handy function

正则表达式-零宽断言

断了今生、忘了曾经 提交于 2020-04-06 06:24:48
[toc] 一、零宽断言-介绍 零宽断言,它匹配的内容不会提取,其作用是在一个限定位置的字符串向前或向后进行匹配查找。 1.1、应用场景 排除查找,查找不含有某段字符串的行 包含查找,查找含有某段字符串的行 二、断言的分类 2.1、正先行断言 什么是正先行断言,就是在字符串相应位置之前进行查找匹配,使用 (?=exp) 匹配exp前面的位置。 import re str = 'abcgwcab' pattern = 'bc(?=gw)' result = re.search(pattern,str) print(result.group()) # 输出结果 bc 解析:首先查找字符串”abcgwcab”中gw位置,断言为真,然后再匹配 bc,然后再向后匹配。 example: pattern = 'bc(?=gw)ca' # 匹配失败,因为找到了 gw 的位置后,断言为真,再向前匹配 bc ,再然后是从 bc 处进行匹配是 gwca ,所以会失败。 pattern = 'bc(?=gw)gwca' # 匹配成功,输出结果 bcgwca 2.2、反先行断言 什么是反先行断言,使用 (?!exp) 匹配后面跟的不是exp。 import re str = 'abcgwcab' pattern = 'bc(?!ww)gw' result = re.search(pattern,str)

wrap-cors middleware not working with system.components

[亡魂溺海] 提交于 2020-03-25 21:51:22
问题 I have the following system.components middleware config, in which I'm using the ring.middleware wrap-cors, to allow for redirects to an external server: (defn config [] {:http-port (Integer. (or (env :port) 5000)) :middleware [[wrap-defaults api-defaults] wrap-with-logger wrap-gzip ignore-trailing-slash [wrap-reload {:dir "../../src"}] [wrap-trace :header :ui] wrap-params wrap-keyword-params wrap-cookies [wrap-cors :access-control-allow-headers #{"accept" "accept-encoding" "accept-language"

Browser says access-control-allow-origin header not present in clojure ring

为君一笑 提交于 2020-03-25 17:53:53
问题 I make a request to a server through the client browser like so https://example.com/bar, but get the error: Access to XMLHttpRequest at 'https://example.com/bar/' from origin 'https://www.example.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. However, when using clj-http.client, I get the following headers: {"Access-Control-Allow-Headers" "Content-Type", "Server" "Aleph/0.4.4", "Via" "1.1 vegur", "Content-Type" "application

Browser says access-control-allow-origin header not present in clojure ring

别来无恙 提交于 2020-03-25 17:52:46
问题 I make a request to a server through the client browser like so https://example.com/bar, but get the error: Access to XMLHttpRequest at 'https://example.com/bar/' from origin 'https://www.example.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. However, when using clj-http.client, I get the following headers: {"Access-Control-Allow-Headers" "Content-Type", "Server" "Aleph/0.4.4", "Via" "1.1 vegur", "Content-Type" "application

Using imported Java libs in Clojure REPL

安稳与你 提交于 2020-03-22 09:04:39
问题 Twilio docs for Java lib MVN for this lib I'm trying to use Twilio from Clojure. Pretty new to Clojure dev, so I'm trying to get to grips with importing libs, in general. My project.clj looks like this: (defproject magical-new-project "0.1.0-SNAPSHOT" :description "FIXME: write description" :url "http://example.com/FIXME" :license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0" :url "https://www.eclipse.org/legal/epl-2.0/"} :dependencies [[org.clojure/clojure "1.10.0"] [com

graphqlize 基于jvm的快速生成graphql api 的库

◇◆丶佛笑我妖孽 提交于 2020-03-19 10:44:31
graphqlize 是基于Clojure 开发的快速生成java graphql api 的库,支持pg 以及mysql 使用比较方便 graphqlize 基本玩法 添加依赖(library) 初始化resovler (配置sql 数据源) 添加graphql api endpoinnt 配置 当前支持的开发模式 java spring boot spark java 原生java Clojure Pedestal Ring 原生Clojure 支持的数据库 当前作者已经支持了pg以及mysql,同时对于oracle还有sql server 的也在规划中,这是一个比较好玩的库,相比 使用graphql-java 快速了好多 参考资料 https://github.com/graphqlize/graphqlize 来源: https://www.cnblogs.com/rongfengliang/p/12522023.html

第 433 期 Python 周刊

╄→尐↘猪︶ㄣ 提交于 2020-03-17 17:37:23
某厂面试归来,发现自己落伍了!>>> 文章教程 使用 Python 扩展 Clojure 链接: https://www.youtube.com/watch?v=vQPW16_jixs Libpython-clj 是一个库,它允许你从 clojure repl 中使用 python 库。我们将深入研究这个库的细节,并讨论构建它的设计决策中的一些潜在后果。 使用 TensorFlow 构建 AI 增强的音乐库 链接: https://blog.tensorflow.org/2020/01/building-ai-empowered-music-library-tensorflow.html QQ 音乐是腾讯音乐娱乐集团(TME)旗下的音乐流媒体服务,我们为全球 8 亿多用户提供服务。我们拥有庞大的音乐库,其中包含大量的专辑和现场音乐(音频和视频格式)。在 TensorFlow 的基础上,我们能够通过音乐标记,音乐评估,语音分离,音乐缺陷检测和恢复等的机器学习算法来有效地管理音乐库。在本文中,我们想与您分享我们如何构建这种具有 AI 功能的音乐库以及关于使用 TensorFlow 的经验。 使用 Python 读取二进制数据 链接: https://reachtim.com/articles/reading-binary-data-with-python.html 在 Python

clojure oauth and credentials

泄露秘密 提交于 2020-02-29 17:50:09
问题 I need some help with clojure and oauth. I got stuck at the last step: signing the request with the credentials. (def credentials (oauth/credentials consumer (:oauth_token access-token-response) (:oauth_token_secret access-token-response) :POST "http://twitter.com/statuses/update.json" {:status "posting from #clojure with #oauth"})) (http/put "http://twitter.com/statuses/update.json" :query-params credentials) Thats the example from github. Now, from the flickr API I have this test-url: http:

Java开发者薪资最低?程序员只能干到30岁?国外真的没有996?Intellij真的比Eclipse受欢迎?

余生长醉 提交于 2020-02-29 08:03:48
Stack Overflow作为全球最大的程序设计领域的问答网站,每年都会出据一份开发者调查报告。近日,Stack Overflow公布了其第9次年度开发者调查报告( https://insights.stackoverflow.com/survey/2019),这份报告基于对9万 Stack Overflow用户的调查。涉及众多领域,今天,挑其中和广大开发者最息息相关的几个重点调查结果给大家介绍一下。 这份报告的受访者主要是国外的开发者,其中的数据并不能完全的反应中国开发者的实际情况,但是也可以从一些侧面看出整个行业的一些信息。 这份报告还可以揭示几个一直困扰开发者的问题的答案,如: 1、哪种编程语言的开发者最赚钱? 2、Eclipse和Intellij哪个更受欢迎? 3、程序员可以干到多少岁? 4、哪种编程语言最受开发者欢迎? 5、国外程序员真的没有996吗? 6、到底要不要做Code Review? 接下来我们主要从技术、工作、开发者、薪水等4个方面展开,分析下这份报告。 一、关于技术 在Stack Overflow每年的报告中,都会对开发者所使用的技术做比较详尽的调查,其中包含编程语言、常用框架、甚至使用的操作系统等。 先来一张Stack Overflow描绘的技术全景图,方便开发者们了解自己所使用的技术所在的位置,以及和其他技术的关联性。 最常用的开发语言 在所有技术中