假设您的git commit历史如下所示:
A---B---C---D---E---F master
\ /
X---Y---Z topic
Run Code Online (Sandbox Code Playgroud)
是否可以让git列表只有master,AF上的提交?换句话说,如果提交是在合并分支上,我不希望它显示.
要进行正则表达式替换,您可以使用以下三种方法:
正则表达式引擎发现了我感兴趣的三件事:
使用时re.sub,最后的字符串是返回的.但是有可能访问其他两个东西,匹配的字符串和替换字符串?
这是一个例子:
orig = "This is the original string."
matchpat = "(orig.*?l)"
replacepat = "not the \\1"
final = re.sub(matchpat, replacepat, orig)
print(final)
# This is the not the original string
Run Code Online (Sandbox Code Playgroud)
匹配字符串是"original",替换字符串是"not the original".有办法获得它们吗?我正在编写一个脚本来搜索和替换许多文件,我希望它能够打印出它正在查找和替换的内容,而不打印整行.
我正在使用Vagrant和Chef来构建一个Ubuntu 12.04虚拟机.我正在使用这里的opscode cookbook:https://github.com/opscode/cookbooks
我想使用opscode apt cookbook来安装包.我想确保它安装特定版本的软件包,以确保构建环境一致.这是我正在尝试做的一个例子:
package "git" do
action :install
end
Run Code Online (Sandbox Code Playgroud)
我知道如果你从命令行使用apt安装软件包,你可以像这样指定版本:
apt-get install git=1:1.7.9.5-1
Run Code Online (Sandbox Code Playgroud)
但我无法通过食谱弄清楚如何做到这一点.这可能吗?
我正在尝试编写一些C++代码,使用Rcpp访问Windows中的某些操作系统级别的东西.一旦我包含windows.h或shlobj.h,我得到一堆编译错误.当我运行此代码时,它可以工作,所以我知道我正在获得一些基础知识.但是,当我取消注释与Windows相关的任何#include一行时,它都不起作用.
library(inline)
inc <- '
#include <iostream>
#include <stdio.h>
// #include <windows.h>
// #include <shlobj.h>
using namespace std;
'
src <- '
cout << "foo\\n";
printf("foo2\\n");
return Rcpp::wrap(20);
'
fun <- cxxfunction(signature(),
includes = inc,
src, plugin="Rcpp")
fun()
Run Code Online (Sandbox Code Playgroud)
注意:当我在RStudio中运行它时,输出cout和printf出现在控制台中,但是当我从Windows RGui运行它时,输出不会出现.我认为这与RGui处理文本输出的方式有关.
当我取消注释那些包含行时,我得到的错误如下所示:
In file included from c:\rtools\gcc-4.6.3\bin\../lib/gcc/i686-w64-mingw32/4.6.3/../../../../i686-w64-mingw32/include/objbase.h:154:0,
from c:\rtools\gcc-4.6.3\bin\../lib/gcc/i686-w64-mingw32/4.6.3/../../../../i686-w64-mingw32/include/ole2.h:16,
from c:\rtools\gcc-4.6.3\bin\../lib/gcc/i686-w64-mingw32/4.6.3/../../../../i686-w64-mingw32/include/windows.h:94,
from file43c2f9e3518.cpp:22:
c:\rtools\gcc-4.6.3\bin\../lib/gcc/i686-w64-mingw32/4.6.3/../../../../i686-w64-mingw32/include/objidl.h:598:52: error: macro "Realloc" requires 3 arguments, but only 2 given
c:\rtools\gcc-4.6.3\bin\../lib/gcc/i686-w64-mingw32/4.6.3/../../../../i686-w64-mingw32/include/objidl.h:598:56: error: ISO C++ forbids initialization of …Run Code Online (Sandbox Code Playgroud) 考虑这个函数a(),它打印出传入的参数:
a <- function(x) {
message("The input is ", deparse(substitute(x)))
}
a("foo")
# The input is "foo"
tmplist <- list(x1 = 1, x2=2)
a(tmplist)
# The input is tmplist
Run Code Online (Sandbox Code Playgroud)
这样可行.但是当a()从另一个函数调用时,它不再打印出原始的参数名称:
b <- function(y) {
a(y)
}
b("foo")
# The input is y
b(tmplist)
# The input is y
Run Code Online (Sandbox Code Playgroud)
一个似乎有用的解决方案是包装另一个substitute和一个eval:
a1 <- function(x) {
message("The input is ", deparse(eval(substitute(substitute(x)), parent.frame())))
}
a1("foo")
# The input is "foo"
tmplist <- list(x1 = 1, x2=2) …Run Code Online (Sandbox Code Playgroud) 我为R编写了一个程序包,其中包括程序ttf2pt1的源代码,该程序在安装时进行编译。该程序未链接到;我编写的代码使用称为的函数调用该程序,system2()基本上就像从命令行调用它一样。该程序的整个源代码都在其自己的目录中,我根本没有对其进行任何修改。
我想在GPL的某些版本下分发该软件包,但是我不清楚这是否可行。如果没有,我可以使用另一个免费软件许可证。
该程序有一个许可文件,但基本上需要包括:
这是文本:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All …Run Code Online (Sandbox Code Playgroud) r ×3
apt ×1
branch ×1
chef-infra ×1
git ×1
git-branch ×1
git-log ×1
gpl ×1
licensing ×1
open-source ×1
python ×1
rcpp ×1
regex ×1
ubuntu ×1
vagrant ×1