我开始在我的 Go 项目中使用 zap 日志库。我想根据日志级别将不同的颜色打印到 tty 控制台。
我发现该zap/internal/color包可以显示不同颜色的字符串,但我想用不同的颜色更改日志级别。
我还想将日志写入一些具有不同日志级别的日志文件。
如何初始化和配置 zap 记录器?
我使用异步来调用elisp中的异步函数.
首先,我在github上测试自述文件代码并且运行良好.
然后我写了一个测试代码:
(defun async-function ()
(async-start
;; What to do in the child process
(lambda ()
(shell-command-to-string "~/test.sh"))
;; What to do when it finishes
(lambda (result)
(message "Async process done, result is: %s" result)))
Run Code Online (Sandbox Code Playgroud)
test.sh代码非常简单:
#! /usr/bin/env sh
sleep 2
echo "shell finish"
Run Code Online (Sandbox Code Playgroud)
它可以工作,但是当我改变这样的lisp代码时失败了:
;;;###autoload
(defun test ()
(shell-command-to-string "~/test.sh"))
(defun async-function ()
(async-start
;; What to do in the child process
(lambda ()
(test))
;; What to do when it finishes
(lambda (result)
(message "Async process done, …Run Code Online (Sandbox Code Playgroud) 我发现我的Mac上的Python使用narrow-build构建,这会在我使用re模型时引发字符范围错误.
所以我想在我的Mac上安装广泛的版本.那么如何在Mac上安装广泛的Python?
出于某种原因,我编写了一些 Common Lisp 代码来完成我想要的操作。我使用 QuickLisp 和 Slime。现在我希望能与Emacs Lisp集成。
我尝试使用
(slime)
(slime-eval-region start end)
...
Run Code Online (Sandbox Code Playgroud)
在我的 el 文件中,但它不起作用。
我只是运行 Common Lisp 代码并捕获返回值,仅此而已。所以我该怎么做?
首先,我有一个像这样的Mysql表:
create table t (id int(11) PRIMARY KEY unsigned NOT NULL AUTO_INCREMENT, name varchar(20), age int(10));
我定义了一个在t中创建一行的函数:
(require '[honeysql.core :as sql])
(defn do-something []
(sql/query {:insert-into :t
:values [{:name "name1" :age 10}]})
(> 3 (rand-int 5)))
Run Code Online (Sandbox Code Playgroud)
现在我想运行这个函数,直到它返回true但最多N次.
这段take-times代码是错误的,因为repeat将eval do-something函数一次,然后构造惰性序列.
(defn take-times []
(some true? (repeat 5 (do-something))))
Run Code Online (Sandbox Code Playgroud)
无论返回什么,这take-times2将减少do-something5次do-something.
(defn take-times2 []
(some true? (for [i (range 5)]
(do-something))))
Run Code Online (Sandbox Code Playgroud)
如果我不使用递归函数和宏,我该怎么办?
我在代码中定义了一个地图,例如:
(def templates {:list1 {:create_time "create_time"
:recharge_amount "recharge"
:invest_amount "invest"
;; something else
}
:list2 {:create_time "ct"
;; something else
}
;;something else
})
Run Code Online (Sandbox Code Playgroud)
我希望地图按照我定义的顺序排列。怎么解决呢?
我有一个像table1一样的
|id | user_id | amount | group_id|
|1 | 1 | 5 | 1 |
|2 | 2 | 1 | 1 |
|3 | 3 | 3 | 1 |
|4 | 3 | 9 | 2 |
|5 | 1 | 4 | 2 |
Run Code Online (Sandbox Code Playgroud)
我只想select为每个group_id找到最后一个:
|id | user_id | amount | group_id|
|3 | 3 | 3 | 1 |
|5 | 1 | 4 | 2 |
Run Code Online (Sandbox Code Playgroud)
有我的SQL:
select max(id) , user_id , …Run Code Online (Sandbox Code Playgroud)