小编Jas*_*son的帖子

在Vim中,如何使用vimscript获取当前文件中的行数?

我正在尝试使用vimscript获取当前文件中的行数,但我无法弄清楚如何(以及google返回一堆关于显示行号的垃圾).

vim

47
推荐指数
2
解决办法
3万
查看次数

如何使linearlayout填充相对布局中的剩余空间?

作为孩子,我有三个线性布局的相对布局.最后一个具有固定的高度,并将android:layout_alignParentBottom设置为"true".当中间的一个正确定位在第一个下方时,它会一直到屏幕的底部,因此它的下部与第三个重叠.

怎么了?

谢谢

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <LinearLayout
        android:id="@+id/category"
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:layout_alignParentTop="true"
        android:orientation="horizontal" >

        <ImageView
            android:id="@+id/back_btn"
            android:layout_width="29dp"
            android:layout_height="34dp"
            android:layout_gravity="center_vertical"
            android:src="@drawable/red_arrow_left" />

        <TextView
            android:id="@+id/cat_name"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:gravity="center"
            android:textSize="20sp" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/category"
        android:layout_marginTop="10dp"
        android:orientation="horizontal" >

        <ListView
            android:id="@+id/android:list"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="@android:color/white"
            android:cacheColorHint="@android:color/white" />

        <TextView
            android:id="@+id/android:empty"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="@android:color/white"
            android:cacheColorHint="@android:color/white"
            android:padding="10dp"
            android:text="@string/no_item" />
    </LinearLayout>

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/nav_bar"
        android:layout_width="fill_parent"
        android:layout_height="40dp"
        android:layout_alignParentBottom="true"
        android:orientation="horizontal" >
    //stuff

    </LinearLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

layout android

21
推荐指数
2
解决办法
6万
查看次数

你如何恢复错误的git合并提交

所以我的一个同事意外地进行了合并,实际上只保留了树的一面.于是他开始合并,删除了合并引入的所有更改,然后提交了合并.

这是我在测试仓库上做的一个简单的测试用例.这个回购有三个分支.idx是意外合并的主题分支,master是主线.dev只是测试revert -m如何工作,所以你可以忽略它.

替代文字

我想要做的是恢复错误的合并.所以从主人我尝试运行,git revert -m 1 <sha1sum of faulty merge>但然后git响应:

# On branch master                               
nothing to commit (working directory clean)
Run Code Online (Sandbox Code Playgroud)

所以它实际上并没有创建撤消合并的恢复提交.我相信这是因为合并实际上并没有包含任何真正的变化.

如果你想玩我的测试报告,你可以从这里下载它

这是一个git bug,还是我错过了什么?

git version-control merge

16
推荐指数
2
解决办法
1万
查看次数

以编程方式获取 bash 中 git 目录的路径(包括子模块)

是否可以以编程方式找到 .git 目录的路径,包括子模块?

我正在尝试编写一个安装 git hook 的脚本,但我找不到一种直接的方法来查找项目的 .git 目录。理想情况下,它应该涵盖以下情况:

  1. 在项目根目录下
  2. 在项目的子目录中
  3. 在项目内子模块的根目录中
  4. 在项目内子模块的子目录中

我可以手动完成所有这些,但我宁愿不解析子模块的 .git 文件。

编辑:我也对 python 中的解决方案感兴趣。

git bash git-submodules

6
推荐指数
1
解决办法
491
查看次数

Ansible sudo_user没有使用正确的$ HOME目录

我有一个git目录,由我不能ssh的用户拥有.我正在使用sudo_user: user哪个正在工作,但似乎没有正确设置$ HOME.我的用户帐户在〜/ .ssh/known_hosts文件中有github,但它被添加到我的~ssh_user/.ssh/known_hosts文件中(来自accept_hostkey = yes).

http://docs.ansible.com/git_module.html

- hosts: myhost
  sudo_user: user
  tasks:
    - name: git
      git: repo=git@github.com:user/repo.git dest=/home/user/repo update=no accept_hostkey=yes
Run Code Online (Sandbox Code Playgroud)

我需要做些什么来告诉ansible正确使用$ HOME吗?

我在Joyent上运行Solaris,但我不认为这直接适用于这个问题.

git solaris ansible ansible-playbook

5
推荐指数
2
解决办法
3462
查看次数

尝试使用Ruby super直接调用方法

考虑以下代码:

class Hello
  def hi
    puts "Hello"
  end
end

class HelloWorld < Hello
  def hi
    super.hi
    puts "World"
  end
end

HelloWorld.new.hi
Run Code Online (Sandbox Code Playgroud)

给出输出:

$ ruby super.rb
Hello
super.rb:9:in `hi': undefined method `hi' for nil:NilClass (NoMethodError)
    from super.rb:14:in `<main>'
Run Code Online (Sandbox Code Playgroud)

为什么Hello打印出来?我希望得到错误.此外,我知道我真正应该做的只是打电话super而不是,super.hi但我想了解"引擎盖下"正在发生的事情.

ruby

1
推荐指数
1
解决办法
743
查看次数