我正在尝试编写一个简单的shell脚本来简化git提交过程.
代替
git add . -A
git commit -m "message"
git push
Run Code Online (Sandbox Code Playgroud)
我想要做 commit.sh "my commit message"
这就是我所拥有的:
#!/bin/bash
commit_message="$1"
git add . -A
git commit -m $commit_message
git push
Run Code Online (Sandbox Code Playgroud)
这有两个问题:
当提交消息包含空格时,比如"我的提交消息",我得到以下输出:
error: pathspec 'commit' did not match any file(s) known to git.
error: pathspec 'message' did not match any file(s) known to git.
因此,它使用的提交消息的唯一部分是"我的",其他部分"提交消息"被省略.
我认为git add .引用shell脚本的位置,而不是当前的项目目录.我该怎么做才能git add .引用我目前在终端的位置?
比方说,我有一个设备齐全的以服务Rails应用程序与乘客和Apache的容器,和我有一个虚拟主机的路由到/ var /网络/应用/在我的容器公众.由于容器应该有点像进程,当我的Rails代码发生变化时,我该怎么办?如果app使用Git克隆,并且repo中有待更改,那么pull这些容器中的容器如何自动更改?
在npm版本6.0.0中,执行该npm install命令会报告此消息:
up to date in 13.576s
[!] 52 vulnerabilities found [15904 packages audited]
Severity: 8 low | 40 moderate | 4 high
Run `npm audit` for more detail
Run Code Online (Sandbox Code Playgroud)
为什么会出现这种情况,以及如何禁用它?
我正在尝试为比较字段的对象编写一个equals方法,如果它们相等则返回true.
private int x, y, direction;
private Color color;
public boolean equals(Ghost other){
if (this.x == other.x && this.y == other.y &&
this.direction == other.direction && this.color == other.color)
return true;
else
return false;
}
Run Code Online (Sandbox Code Playgroud)
这可能有什么问题?
Snape的"不友好的向导算法"教科书声称合并排序的运行时间为O(n ^ 4).这个说法是否正确?
解决方案:是的.这种说法在技术上是正确的,因为O(n ^ 4)仅给出算法花费多长时间的上限.然而,这是一个令人讨厌的无益答案,因为紧张局限是?(n log n).
我不太明白解决方案的内容.O(n ^ 4)如何正确?
因此,如果函数或运行时间不是f(n)的BigO,我们可以说它的BigOmega是f(n)吗?
这个问题令我感到困惑.我有一棵树,我想写一个方法,计算某个节点的孙子数(但不是伟大的granchildren).我不能使用循环,只能递归.所以问题是如何实现我的基础案例?我怎么让它停下来?我想不出这会实现的方式......
不确定这是否可行,但有一种自动方式,使用mod或类似的东西,自动纠正错误的输入值?例如:
If r>255, then set r=255 and
if r<0, then set r=0
Run Code Online (Sandbox Code Playgroud)
所以基本上我要问的是一个聪明的数学方法来设置它而不是使用
if(r>255)
r=255;
if(r<0)
r=0;
Run Code Online (Sandbox Code Playgroud) 这是一个非常简单的问题,但我不知道它为什么会发生.在我的头文件中,我已声明了一个UIButton *leftButton.在viewDidLoad方法中,我这样做leftButton=[UIButton buttonWithType:UIButtonTypeRoundedRect];
然后我用其他方法:
leftButton.frame=newFrame;
leftButton.tag=i;
[leftButton addTarget:self action:@selector(leftButtonSelected:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:leftButton];
Run Code Online (Sandbox Code Playgroud)
但是,当调用上述方法时,我一直在崩溃.有时我收到一条消息,有时它只是崩溃而没有消息.我无法真正复制任何崩溃消息,现在我所得到的只是一般崩溃,但它仍然因为[UIGestureRecognizer setFrame]导致问题或[WebView setFrame]或其他东西等奇怪问题而崩溃.由于某种原因它一直认为leftButton不是UIButton,但事实并非如此.在我的整个项目中没有其他任何名为leftButton的东西.有任何想法吗?
我正在尝试在UIButton上实现拖放功能,它工作正常,但我无法找到一种方法来确定用户何时放开按钮并完成拖动.下面的代码适用于拖动,但我需要在用户完成拖动并释放按钮时收到通知.
- (void)viewDidLoad
{
[gesturesBrowserButton addTarget:self action:@selector(wasDragged:withEvent:)
forControlEvents:UIControlEventTouchDragInside];
[gesturesBrowserButton addTarget:self action:@selector(finishedDragging:withEvent:)
forControlEvents:UIControlEventTouchDragExit];
}
- (void)wasDragged:(UIButton *)button withEvent:(UIEvent *)event
{
// get the touch
UITouch *touch = [[event touchesForView:button] anyObject];
// get delta
CGPoint previousLocation = [touch previousLocationInView:button];
CGPoint location = [touch locationInView:button];
CGFloat delta_x = location.x - previousLocation.x;
CGFloat delta_y = location.y - previousLocation.y;
// move button
button.center = CGPointMake(button.center.x + delta_x,
button.center.y + delta_y);
NSLog(@"was dragged");
}
- (void)finishedDragging:(UIButton *)button withEvent:(UIEvent *)event
{
//doesn't get called
NSLog(@"finished dragging");
}
Run Code Online (Sandbox Code Playgroud) algorithm ×3
big-o ×2
iphone ×2
java ×2
objective-c ×2
bash ×1
cocoa-touch ×1
docker ×1
equals ×1
git ×1
mergesort ×1
modulo ×1
npm-install ×1
object ×1
performance ×1
recursion ×1
shell ×1
tree ×1