我正在寻找从最后一次提交创建补丁的神奇命令.
我的工作流程有时看起来像这样
vi some.txt
git add some.txt
git commit -m "some change"
Run Code Online (Sandbox Code Playgroud)
现在我只想写
git create-patch-from-last-commit-to-file SOME-PATCH0001.patch
Run Code Online (Sandbox Code Playgroud)
但是我应该把它放在那里而不是create-patch-from-last-commit-to-file?
我有一个来自我正在使用tail-seq读取的文件的传入惰性流行(对于contrib - 现在!)我想要一个接一个地处理这些行,其中有几个"侦听器函数"根据re-seq采取行动-hits(或其他东西)在行中.
我尝试了以下方法:
(defn info-listener [logstr]
(if (re-seq #"INFO" logstr) (println "Got an INFO-statement")))
(defn debug-listener [logstr]
(if (re-seq #"DEBUG" logstr) (println "Got a DEBUG-statement")))
(doseq [line (tail-seq "/var/log/any/java.log")]
(do (info-listener logstr)
(debug-listener logstr)))
Run Code Online (Sandbox Code Playgroud)
它按预期工作.但是,代码中有很多代码重复和其他错误,更新代码很无聊.
一个重要的步骤似乎是将许多函数应用于一个参数,即
(listen-line line '(info-listener debug-listener))
Run Code Online (Sandbox Code Playgroud)
并使用它而不是枯燥和容易出错的声明.
我尝试了以下看似聪明的方法:
(defn listen-line [logstr listener-collection]
(map #(% logstr) listener-collection))
Run Code Online (Sandbox Code Playgroud)
但这只会呈现
(nil) (nil)
Run Code Online (Sandbox Code Playgroud)
懒惰或一流的功能肯定会咬我,但我在哪里提出申请?
我也对这个问题采取截然不同的方法,但这似乎是一个非常理智的方式.宏/多方法现在似乎有点矫枉过正.
使用repl时,有时你想销毁一个变量,因为它会以某种方式妨碍你的编程(最常见的是命名空间冲突).
有没有办法在clojure中销毁变量?
user>(def x 1)
#'user/x
user>(aggressive-destroy! x)
nil
user>x
Unable to resolve symbol: x in this context
Run Code Online (Sandbox Code Playgroud) 我是领域驱动设计的新手,我对一些概念有所怀疑(希望这是一个正确的问题).
我知道在DDD我应该避免贫血模型,所以考虑一个社交网络模型谁应该(保存)两个朋友之间的友谊?
我想象有一个代表用户的类(使用类似Java的语法)的情况:
class User{
String username
List<User> friends
}
Run Code Online (Sandbox Code Playgroud)
那么,它应该有一个添加朋友的方法
class User{
void friendship(User friend)
}
Run Code Online (Sandbox Code Playgroud)
或者我应该使用服务吗?
class UserService{
void friendship(User user, User user2)
}
Run Code Online (Sandbox Code Playgroud) 在调试时能够以简单的方式打印东西通常很方便.
如何在Clojurescript中调用document.write?
在OLAP-cubes中,可以对大量聚合数据进行快速查找.这样做的主要原因是一个预先聚合操作中的数据,这些数据易于向上组合(主要是+, - ,mean,std,max,min等等).
如何在clojure中获得这种"反懒惰"行为?
我正在考虑类似的事情
(def world-population {:africa 4e8 ;;this is an aggregation!
:africa/liberia 3.4e6
:africa/ethiopia 7.4e7
...})
Run Code Online (Sandbox Code Playgroud)
如何更新这样的数据结构并确保实体的父级也更新?有人必须推出自己的ref实现吗?
我的目的是使用Arduino使用HC-05蓝牙模块在PC和Android设备之间建立通信.
我使用PC和Arduino(串行监视器)之间的USB通信和SoftwareSerial连接到HC-05.
我的问题是从BT到PC的通信运行良好,但在其他方面不能按预期工作.当从PC发送到BT时,只有当我关闭PC上的串行监视器或重置Arduino时,BT设备才会收到所有发送的字符.
我已经排除了BT模块或Android应用程序的问题,因为如果在Arduino中我实现了"ECHO"代码(在Android中编写并在Android中发送)一切正常.
随着下面发布的Arduino代码预期的行为是:Arduino reset-> Hello word发送,串口监视器打开 - >没有任何反应,字符写在串行监视器上 - > BT上收到的字符,字符写在BT->串行监视器上收到的字符,串口监视器关闭 - >没有任何反应.
真正的行为是:Arduino reset-> Hello word发送,串口监视器打开 - > 2个BT上的Hello字和PC上的1个字("晚安"),串行监视器上写的字符 - >没有,字符写在BT->字符收到在串行监视器上,串行监视器关闭 - >先前在串行监视器中写入的字符+ Hello Word.
我该如何解决这个问题?
码:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX
int a=0;
char c;
char d;
void setup() {
Serial.begin(9600);
Serial.println("Goodnight moon!");
mySerial.begin(9600);
mySerial.println("Hello, world?");
}
void loop() {
delay(10);
if (Serial.available()) {
c=Serial.read();
delay(10);
Serial.write(c);
}
delay(10);
if (mySerial.available()) {
d=mySerial.read();
delay(10);
mySerial.write(d);
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试om.next,尝试扩展组件,身份和规范化中给出的示例.
上面链接的示例中的代码包含两个列表,这些列表由状态中两个不同路径中的数据支持.该示例显示了数据规范化如何使得可以轻松更新在不同视图中出现的规范化实体.在下面的代码中,我删除了下面示例中的第二个列表,因为无论如何行为都会显示出来.
以下示例适用并显示:
其中+是一个增加人物点数的按钮.
(ns ui.core
(:require [om.next :as om :refer-macros [defui]]
[om.dom :as dom]
[goog.dom :as gdom]))
(def init-data
{:list/one [{:name "John" :points 0}
{:name "Mary" :points 0}
{:name "Bob" :points 0}]})
;; -----------------------------------------------------------------------------
;; Parsing
(defmulti read om/dispatch)
(defn get-people [state key]
(let [st @state]
(into [] (map #(get-in st %)) (get st key))))
(defmethod read :list/one
[{:keys [state] :as env} key params]
{:value (get-people state key)})
(defmulti …Run Code Online (Sandbox Code Playgroud) 如何在clojure重新模式中打开/关闭贪婪?
(re-find #"(.+)-(.+)" "hello-world-you") => ["hello-world-you" "hello-world" "you"]
Run Code Online (Sandbox Code Playgroud)
VS
(re-find #"(.+)-(.+)" "hello-world-you") => ["hello-world-you" "hello" "world-you"]
Run Code Online (Sandbox Code Playgroud) 我正在处理一个考试项目,我需要更改页面中样式表的名称。我怎样才能用 Dart 做到这一点?我已经看到我可以从 Dart 编辑我的 css 的每个属性,但我已经制作了我想在我的页面中使用的其他 css。例如,我的 html 页面中有这个:
<link href="stile.css" rel="stylesheet" type="text/css">
Run Code Online (Sandbox Code Playgroud)
我需要编辑页面才能做到这一点
<link href="stile-blu.css" rel="stylesheet" type="text/css">
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
clojure ×4
aggregation ×1
android ×1
arduino ×1
bluetooth ×1
css ×1
dart ×1
dart-polymer ×1
git ×1
html ×1
olap ×1
om-next ×1
patch ×1
regex ×1
serial-port ×1