我的sh
Linux环境中有一个示例脚本,基本上运行的ssh-agent
是当前shell,为它添加一个键并运行两个git命令:
#!/bin/bash
eval "$(ssh-agent -s)"
ssh-add /home/duvdevan/.ssh/id_rsa
git -C /var/www/duvdevan/ reset --hard origin/master
git -C /var/www/duvdevan/ pull origin master
Run Code Online (Sandbox Code Playgroud)
脚本实际上运行正常,但每次运行它都会得到一个新进程,所以我认为它可能会成为一个性能问题而且我最终可能会遇到无用的进程.
输出的一个例子:
Agent pid 12109
Identity added: /home/duvdevan/.ssh/custom_rsa (rsa w/o comment)
Run Code Online (Sandbox Code Playgroud)
此外,除此之外,是否可以找到现有ssh-agent
流程并将其添加到其中?
我有这些菜单项 menu_main.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity">
<item android:id="@+id/action_restart" android:title="Restart"
android:orderInCategory="1" />
<item android:id="@+id/action_clear" android:title="Clear"
android:orderInCategory="2" />
<item android:id="@+id/action_update" android:title="Update"
android:orderInCategory="3" />
<item android:id="@+id/action_about" android:title="About"
android:orderInCategory="4" />
<item android:id="@+id/action_try_restart" android:title="Try Restart"
android:orderInCategory="5" />
</menu>
Run Code Online (Sandbox Code Playgroud)
我的onOptionsItemSelected
方法中有这个:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == …
Run Code Online (Sandbox Code Playgroud) 我有其中有一个字段的表`activated_at` timestamp NULL DEFAULT NULL
,这意味着它可以包含时间戳,也可以是null
和它的null
默认.
我有另一个[gii-generated]搜索模型,在该search()
方法中具有以下配置:
public function search($params)
{
$query = User::find();
// add conditions that should always apply here
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$andFilterWhere = [
'id' => $this->id,
'status' => $this->status,
'role' => $this->role,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
'completed_files' => $this->completed_files,
// 'activated_at' => null, …
Run Code Online (Sandbox Code Playgroud) 假设我有这个表结构:
+----+------------+-----------+---------+------+---------+---------+---------------------+---------------------+
| id | first_name | last_name | country | city | address | zipcode | created | updated |
+----+------------+-----------+---------+------+---------+---------+---------------------+---------------------+
| 1 | Duvdevan | Duvdevani | NULL | NULL | NULL | NULL | 2016-02-12 15:37:19 | 2016-02-12 16:35:57 |
+----+------------+-----------+---------+------+---------+---------+---------------------+---------------------+
Run Code Online (Sandbox Code Playgroud)
我想添加一个名为新列email
,刚过id
之前first_name
,使用addColumn
方法的的Migration
类.
我在新迁移中唯一能做的就是:
public function up()
{
$this->addColumn('contacts', 'email', $this->string(64));
}
Run Code Online (Sandbox Code Playgroud)
它将把它放在桌子的最后,updated
在场后.
如何在表中的特定位置添加列,以便可以遵循此SQL查询:
ALTER TABLE contacts ADD email VARCHAR(64) AFTER id
Run Code Online (Sandbox Code Playgroud) 我有一个场景,我必须首先创建一个 zip 文件,然后,当我的文件从另一个位置到达时,它们将被添加到 zip 中。
第二部分是通过-u
参数完成的:
zip -u {{project}}.zip {{file}}
Run Code Online (Sandbox Code Playgroud)
--help
因为这个命令也不是很有帮助:
user@host:~# zip --help
Copyright (c) 1990-2008 Info-ZIP - Type 'zip "-L"' for software license.
Zip 3.0 (July 5th 2008). Usage:
zip [-options] [-b path] [-t mmddyyyy] [-n suffixes] [zipfile list] [-xi list]
The default action is to add or replace zipfile entries from list, which
can include the special name - to compress standard input.
If zipfile and list are omitted, zip compresses stdin to stdout. …
Run Code Online (Sandbox Code Playgroud) 我正在扩展yii\db\Migration
类以添加一个方法timestamps
,该方法将加快我创建迁移的速度。它将在我将创建的每个迁移中添加我需要的所有时间戳。
我已经在 Laravel 和 CakePHP 框架中看到了这个功能,我很好奇为什么在 Yii 2 迁移工具中默认情况下不可用。
我尝试了以下方法:
namespace custom\db;
use \yii\db\Migration as YiiMigration;
class Migration extends YiiMigration
{
public function timestamps($tableName)
{
$this->addColumn(
$tableName,
'created_at',
$this->timestamp()->null()->defaultExpression('CURRENT_TIMESTAMP')
);
$this->addColumn(
$tableName,
'updated_at',
$this->timestamp()->null()
);
$this->addColumn(
$tableName,
'deleted_at',
$this->timestamp()->null()->defaultExpression('NULL')
);
}
}
Run Code Online (Sandbox Code Playgroud)
在我的实际迁移up
或safeUp
方法中,我执行以下操作:
public function safeUp()
{
$this->createTable('test', [
'id' => 'pk',
]);
$this->timestamps('test');
}
Run Code Online (Sandbox Code Playgroud)
当我运行它时,字段created_at
并deleted_at
按照指定获取它们的类型和默认值。created_at
可以为空,但它的默认值是CURRENT_TIMESTAMP
并且可以deleted_at
为空,它的默认值是NULL
。
问题是updated_at
字段。我不知道如何使用 Yii …
我在VPS上连接时手动运行以下两个命令:
eval ssh-agent $SHELL
ssh-add /home/duvdevan/.ssh/id_rsa
Run Code Online (Sandbox Code Playgroud)
我尝试将它们添加到a ssh.sh
并使用以下命令在该目录中运行:
./ssh.sh
Run Code Online (Sandbox Code Playgroud)
但没有任何事情发生.
我不是那么bash
- 所以任何帮助都是值得赞赏的.
我有一个使用大量$(document).on('click', selector, ...)
事件处理程序的Web应用程序,我想将它们全部切换为'touchstart'事件,但我希望在任何情况下都避免任何事件冒泡或重复.
我想把所有这些分成单独的JS文件,但是,有很多这些文件利用上面提到的事件监听器.
我有兴趣以任何程序化方式获得这个,如果有的话?
我在考虑:
$('a, button, input').each(function() {
$(this).on('touchstart', this.click);
});
Run Code Online (Sandbox Code Playgroud)
但这可能是一个性能问题.
我有两个表名列相同的表,使用两个不同的搜索模型(都使用ActiveDataProvider
's)所以当我按列排序时,另一个也会受到影响.
我试过在第二次设置这个GridView
:
'sorter' => [
'class' => 'yii\widgets\LinkSorter',
'sortParam' => 'sortB',
],
Run Code Online (Sandbox Code Playgroud)
但无济于事.
编辑:排序参数是传递给服务器的GET变量:?sort=amount
,或?param=1&sort=created_at
.
如何FULLTEXT
使用Yii 2迁移为字段添加索引?
没有createFulltextIndex
或createUniqueIndex
方法.课yii\db\Migration
文档.
如何通过Yii 2迁移来解决这个问题?
yii2 ×5
php ×3
bash ×2
linux ×2
mysql ×2
ssh ×2
activerecord ×1
android ×1
android-menu ×1
gridview ×1
javascript ×1
jquery ×1
shell ×1
touch ×1
ubuntu ×1
yii ×1
yii2-model ×1
zip ×1