Git stash似乎做了我想要的很多东西,除了它有点难以编写脚本,因为如果你没有变化,那么git stash; git stash pop将会做一些不同于你的存储库中有变化的东西.
似乎这git stash create就是问题的答案,一切都有效,除了一件事......我无法摆脱所创造的藏匿.有没有办法摆脱藏匿?
为了让我100%清楚我在做什么:
创建存储:
~/tmp/a(master) $ git stash create
60629375d0eb12348f9d31933dd348ad0f038435
~/tmp/a(master) $ git st
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: b
#
~/tmp/a(master) $ git reset --hard
HEAD is now at 555d572 log message
Run Code Online (Sandbox Code Playgroud)
使用藏匿处:
~/tmp/a(master) $ git apply 60629375d0eb12348f9d31933dd348ad0f038435
fatal: can't open patch '60629375d0eb12348f9d31933dd348ad0f038435': No such file or directory
~/tmp/a(master) $ git stash …Run Code Online (Sandbox Code Playgroud) 哪种是最有效的遍历集合的方式?
List<Integer> a = new ArrayList<Integer>();
for (Integer integer : a) {
integer.toString();
}
Run Code Online (Sandbox Code Playgroud)
要么
List<Integer> a = new ArrayList<Integer>();
for (Iterator iterator = a.iterator(); iterator.hasNext();) {
Integer integer = (Integer) iterator.next();
integer.toString();
}
Run Code Online (Sandbox Code Playgroud)
请注意,这不是这个,这个,这个或这个的完全重复,尽管最后一个问题的答案之一很接近.这不是欺骗的原因是,大多数都是比较你get(i)在循环中调用的循环,而不是使用迭代器.
正如Meta上所建议的,我将发布我对这个问题的回答.
其实我有两个问题.
(1)如果我只检索标题而不是使用php和curl进行完整页面检索,那么远程服务器上使用的处理能力或带宽是否会减少?
(2)由于我认为,我可能错了,第一个问题的答案是肯定的,我试图获取最后修改日期或If-Modified-Since标题的远程文件只是为了将它与时间日期进行比较本地存储的数据,所以我可以,如果它已被更改,将其存储在本地.但是,NULL当我运行这个时,我的脚本似乎无法获取那条信息:
class last_change {
public last_change;
function set_last_change() {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "http://url/file.xml");
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_FILETIME, true);
curl_setopt($curl, CURLOPT_NOBODY, true);
// $header = curl_exec($curl);
$this -> last_change = curl_getinfo($header);
curl_close($curl);
}
function get_last_change() {
return $this -> last_change['datetime']; // I have tested with Last-Modified & If-Modified-Since to no avail
}
}
Run Code Online (Sandbox Code Playgroud)
如果$header = curl_exec($curl)未启用,即使我没有请求它,也会显示标题数据,如下所示:
HTTP/1.1 200 OK
Date: Fri, 04 Sep 2009 12:15:51 GMT …Run Code Online (Sandbox Code Playgroud) 我有一个格式的字符串"[(1, 2), (2, 3), (3, 4)]",具有任意数量的元素.我想将它拆分的逗号分隔的坐标,也就是检索(1, 2),(2, 3)和(3, 4).
我可以用Java正则表达式吗?我是一个完整的菜鸟,但希望Java正则表达式足够强大.如果不是,你能建议一个替代方案吗?
由于各种原因,我想将列表转换为数组,但Collection包含本身就是泛型的对象.
我已经尝试了以下四个选项来编译它而不需要@supressWarnings('unchecked')注释,但它们都不起作用.是否有解决方案使这项工作正常,或者我被迫使用注释?
Iterator<T>[] iterators;
final Collection<Iterator<T>> initIterators = new ArrayList<Iterator<T>>();
// Type safety: Unchecked cast from Iterator[] to Iterator<T>[]
iterators = initIterators.<Iterator<T>>toArray(
(Iterator<T>[])new Iterator[initIterators.size()]);
// Type safety: Unchecked invocation toArray(Iterator[]) of the generic
// method toArray(T[]) of type Collection<Iterator<T>>
// Type safety: The expression of type Iterator[] needs unchecked conversion
// to conform to Iterator<T>[]
iterators = initIterators.<Iterator<T>>toArray(
new Iterator[initIterators.size()]);
// Type safety: The expression of type Iterator[] needs unchecked conversion
// to conform to Iterator<T>[]
iterators = …Run Code Online (Sandbox Code Playgroud) 如果您有需要编码的二进制数据,您使用的编码方案是什么?
我知道:
是否有其他常用的编码方案?如果是这样,有什么优点和缺点?
编辑:这很有用,例如,当尝试在cookie中存储任意数据时.Cookie只能存储文本,而不能存储任意数据,因此您需要以某种方式对其进行转换,最好是将其转换回来.此外,假设您正在使用无状态服务器,以便您无法在服务器上保存状态,只需将标识符放入cookie即可.当然,如果你这样做,你还需要一些方法来验证用户传递给你的是你传递给用户的内容,例如签名.
此外,由于目前的共识是你应该使用base64,因为它很普遍,我也会指出这是我使用的...我只是好奇,如果有人使用其他任何东西,如果是这样,为什么.
编辑:万一有人偶然发现,如果您确实想使用Base64将数据存储在cookie中,则需要使用修改后的Base64实现.看到这个答案的原因.
我最近遇到了这些问题,但在StackOverflow上找不到答案;
正如Meta上所建议的,我将发布我对这个问题的回答.
我有一个包含以下目录的存储库:
trunk目录包含主要的开发线.我为存储库创建了一个post-commit钩子脚本,用于在用户提交回存储库时更新(trunk)工作副本.
它看起来像这样:
/usr/bin/svn update /path/to/a/working/copy
Run Code Online (Sandbox Code Playgroud)
我刚刚创建了一个代码分支,因为我即将开始一些重大更改但是注意到当我将更改提交到分支时,它会调用post-commit钩子并更新工作副本(trunk的副本).
有没有办法可以修改我的post-commit钩子脚本或我可以创建的设置,只有在提交到trunk目录而不是任何其他目录时才会更新工作副本?
场景:(在PHP中)我有一个表单提交,其中包含UTF-8编码的字符串($name)以支持国际字符.在提交表单(通过GET)后,我正在创建一个CSV下载文件.我希望文件的名称是字符串 + .csv ("$name.csv").对于西方字符集,我可以通过以下方式做到这一点:
header("Content-Disposition: attachment; filename=\"$name\"");
Run Code Online (Sandbox Code Playgroud)
但对于其他字符集,下载文件的名称是垃圾字母 + .csv(例如×œ×œ× ×›×•×ª×¨×ª.csv).我试图遵循RFC 2231做类似的事情:
header("Content-Disposition: attachment; filename*=UTF-8''$name");
Run Code Online (Sandbox Code Playgroud)
但我似乎有几个问题:
我需要$name编码以十六进制编码的八位字节的每个字符,如" This%20is%20%2A%2A%2Afun%2A%2A%2A".有没有人有正确的功能?我编写了以下代码,但我不认为这是正确的:
$fileName = encodeWordRfc2231($name) . ".csv";
header("Content-Disposition: attachment; filename*=UTF-8''$fileName");
function &encodeWordRfc2231($word) {
$binArray = unpack("C*", $word);
foreach ($binArray as $chr) {
$hex_ary[] = '%' . sprintf("%02X", base_convert($chr, 2, 16));
}
return implode('', $hex_ary);
}
Run Code Online (Sandbox Code Playgroud)有没有人有这方面的经验,可以让我走上正确的道路?
所以问题在标题中得到了很好的解释.假设我有以下目录结构:
./index.html
./_includes/include1
Run Code Online (Sandbox Code Playgroud)
而index.html的内容是:
<!DOCTYPE html>
<html>
<head>
<title>Test page for inclusions</title>
</head>
<body>
{% include include1 %}
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
有没有办法index.html在include1文件更改时重建?
编辑:只是为了澄清,index.html在index.html更改时重新生成,我想知道如何在依赖于更改的内容时重新生成页面,在这种情况下include1是_includes/目录中的文件.
并且,如果它很重要:
$ jekyll --version
jekyll 1.0.3
$ ruby --version
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0]
Run Code Online (Sandbox Code Playgroud)
我的_config.yml:
$ cat _config.yml
timezone: Europe/Amsterdam
Run Code Online (Sandbox Code Playgroud)
也就是说,在大多数情况下,我只是运行默认值,这似乎有效,因为它知道在哪里找到include1文件.
该文件,意味着连接始终远程可用,但因为我用这个在笔记本电脑上,并改变网络,有时客户不知道如何连接,因为他们正试图使用一个IP是不再有效.
所以,问题是:有没有办法强制H2只在localhost上监听auto_server = true?