我经常至少有3个远程分支:master,staging和production.我有3个本地分支跟踪那些远程分支.
更新我所有的本地分支机构很繁琐:
git fetch --all
git rebase origin/master
git checkout staging
git rebase origin/staging
git checkout production
git rebase origin/production
Run Code Online (Sandbox Code Playgroud)
我很乐意能够做一个"git pull -all",但我无法让它发挥作用.它似乎执行"fetch --all",然后更新(快进或合并)当前工作分支,而不是其他本地分支.
我仍然卡在手动切换到每个本地分支和更新.
我可以在python中做这样的事情:
l = ['one', 'two', 'three']
if 'some word' in l:
...
Run Code Online (Sandbox Code Playgroud)
这将检查列表中是否存在"某个单词".但我可以做反向的事情吗?
l = ['one', 'two', 'three']
if l in 'some one long two phrase three':
...
Run Code Online (Sandbox Code Playgroud)
我必须检查数组中的某些单词是否在字符串中.我可以使用循环来做这个,但这种方式有更多的代码行.
如何制作多行预处理器宏?我知道怎么做一行:
#define sqr(X) (X*X)
Run Code Online (Sandbox Code Playgroud)
但我需要这样的东西:
#define someMacro(X)
class X : public otherClass
{
int foo;
void doFoo();
};
Run Code Online (Sandbox Code Playgroud)
我怎样才能让它发挥作用?
这只是一个例子,真正的宏可能很长.
我在控制器中有一个函数,我是单元测试,期望http请求的标头中的值.我无法初始化HttpContext,因为它只是readonly.
我的控制器函数需要"device-id"的http请求标头值
[TestMethod]
public void TestValuesController()
{
ValuesController controller = new ValuesController();
//not valid controller.HttpContext is readonly
//controller.HttpContext = new DefaultHttpContext();
var result = controller.Get();
Assert.AreEqual(result.Count(), 2);
}
Run Code Online (Sandbox Code Playgroud)
没有使用第三方库,有没有直接的方法来做到这一点?
似乎Spinner控件在用户明确按Enter键之前不会更新手动键入的值.因此,他们可以键入一个值(不按回车键)退出控件,并提交表单,并且微调器中显示的值不是微调器的值,它是旧值.
我的想法是为丢失的焦点事件添加一个监听器,但我看不到一种获取输入值的方法?
spinner.focusedProperty().addListener((observable, oldValue, newValue) ->
{
//if focus lost
if(!newValue)
{
//somehow get the text the user typed in?
}
});
Run Code Online (Sandbox Code Playgroud)
这是奇怪的行为,它似乎违反了GUI微调控件的惯例.
我有一个.NET核心MVC休息服务.我有一个我想测试的控制器.此控制器具有IOptions的构造函数参数,其中AppSettings是我的配置设置类(我将数据库连接字符串存储在其中).它从Startup.cs中的ConfigureServices中的设置注入
休息服务工作.我的问题是我已经设置了一个MSTest测试项目来测试服务.我无法弄清楚如何初始化IOptions实例以满足我的控制器的构造函数.
我已经为我的项目添加了额外的json配置文件
appsettings.DEV.json
appsettings.QA.json
Run Code Online (Sandbox Code Playgroud)
并将它们加载到Startup基于环境的函数中:
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
...
Run Code Online (Sandbox Code Playgroud)
我了解如何更改环境:修改ASPNETCORE_ENVIRONMENT项目属性中环境变量的值.但是,似乎没有能力根据配置指定不同的环境变量,下拉列表标记为"N/A"并禁用.
我看到的唯一选择是手动更改环境变量值,以更改使用的appsettings.我确信有一种方法可以自动完成,或者你会如何使用CI?(除了使用脚本来更改环境变量之外,还必须有一种更简单的方法).
这里的目标是为三个环境设置自动构建和持续集成:DEV,QA和PROD. DEV和QA位于同一台计算机上,因此无法手动设置指定环境的环境变量.
当我尝试这样做时,Easy_install和Pip在python 2.7上不再起作用了:
sudo easy_install pip
Run Code Online (Sandbox Code Playgroud)
我明白了:
Traceback (most recent call last):
File "/usr/bin/easy_install", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/bin/lib/python2.7/site-packages/distribute-0.6.19-py2.7.egg/pkg_resources.py", line 2713, in <module>
parse_requirements(__requires__), Environment()
File "/usr/bin/lib/python2.7/site-packages/distribute-0.6.19-py2.7.egg/pkg_resources.py", line 584, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: distribute==0.6.15
Run Code Online (Sandbox Code Playgroud)
当我尝试:
sudo pip install [package]
Run Code Online (Sandbox Code Playgroud)
我明白了:
Traceback (most recent call last):
File "/usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/bin/lib/python2.7/site-packages/distribute-0.6.19-py2.7.egg/pkg_resources.py", line 2713, in <module>
parse_requirements(__requires__), Environment()
File "/usr/bin/lib/python2.7/site-packages/distribute-0.6.19-py2.7.egg/pkg_resources.py", line 584, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pip==0.8.2
Run Code Online (Sandbox Code Playgroud)
我已经安装了它们(是的,先删除它们),但没有结果......
谢谢! …
我已经看到这两个术语可以互换使用。网上找到的定义似乎也各不相同。
根据我的理解,极端情况是输入的极值。边缘情况是设计算法时要处理的极端情况。这样对吗?
有标准定义吗?
我正在尝试在 cloudformation (yaml) 中定义角色和用户之间的信任关系策略文档。
为了在角色的 中指定用户的 ARN AssumeRolePolicyDocument,我想从实际的 cloudformation 资源中引用 ARN,而不必构造 ARN 字符串。
但是,它不起作用。当我使用 时!Ref rUser,在创建 cloudformation 堆栈时出现错误“策略中的无效主体”。
当我只是将 ARN 字符串粘贴为值时,它就起作用了。是因为!Ref rUser返回用户对象类型并且不计算为字符串吗?如果是这样,我如何从资源中引用 ARN?
代码:
rUser:
Type: "AWS::IAM::User"
Properties:
UserName: "my_user"
rRole:
DependsOn: rRole
Type: "AWS::IAM::Role"
Properties:
RoleName: "my_role"
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
-
Effect: "Allow"
Principal:
AWS:
# this does not work, gives error "Invalid Principal in policy"
- !Ref rUser
# this does work (just hard coding the ARN string):
# - "arn:aws:iam::111111111111:user/my_user"
Action: …Run Code Online (Sandbox Code Playgroud) asp.net-core ×3
asp.net-mvc ×3
c# ×3
python ×2
unit-testing ×2
.net ×1
algorithm ×1
amazon-iam ×1
c ×1
c++ ×1
git ×1
java ×1
javafx ×1
javafx-8 ×1
json ×1
list ×1
python-2.7 ×1
spinner ×1
yaml ×1