小编Nic*_*nto的帖子

切换到另一个分支而不提交

我正在开发一个功能分支并且还没有完成那里的工作 - 现在我需要更改到另一个分支来修复某些东西

例如

feat1 - 6+ files changed
Run Code Online (Sandbox Code Playgroud)

当我签出到feat2分支时,git add .在feat1之后,git似乎继续进行了暂存但未提交的文件更改.

如果我在feat1中提交了这些文件更改,则检查到feat2将不会继承这些更改

如何在不提交文件更改的情况下切换分支?

git

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

Postgres中的uuid ossp是什么

我在迁移中已经看到了

enable_extension 'uuid-ossp'
Run Code Online (Sandbox Code Playgroud)

据我所知,uuid是基于某些RFC的长而唯一的字符串,这使db(在本例中为pg)具有作为uuid的列类型

我的问题是-为什么需要这种类型的列,而不仅仅是字符串列?是替换常规的整数id列,而是使用uuid作为id?

使用uuid作为id而不是让字符串类型的列包含uuid有什么好处?

postgresql uuid ruby-on-rails

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

在Rails 4 + unicorn + foreman中禁用资产日志记录

在Rails 4 + thin,quiet_assets gem工作得很好.

一旦我加入独角兽并与领班一起运行,资产再次变得嘈杂.

这有什么解决方案吗?

unicorn sprockets asset-pipeline foreman ruby-on-rails-4

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

没有标签链接的 Bootstrap 可切换标签

有没有办法做到以下几点

<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
  <li class="active"><a href="#home" role="tab" data-toggle="tab">Home</a></li>
  <li><a href="#profile" role="tab" data-toggle="tab">Profile</a></li>
  <li><a href="#messages" role="tab" data-toggle="tab">Messages</a></li>
  <li><a href="#settings" role="tab" data-toggle="tab">Settings</a></li>
</ul>

<!-- Tab panes -->
<div class="tab-content">
  <div class="tab-pane active" id="home">...</div>
  <div class="tab-pane" id="profile">...</div>
  <div class="tab-pane" id="messages">...</div>
  <div class="tab-pane" id="settings">...</div>
  <div class="tab-pane" id='extra'> .... </div>

</div>
Run Code Online (Sandbox Code Playgroud)

所以还有另一个名为 的选项卡窗格#extra,但我不希望它有一个链接作为选项卡,但我确实希望它可以被其他事件切换

由于 bootstrap tabs.jstab('show')在链接上触发 a而不是在窗格本身上工作,如何在不处理选项卡的情况下触发选项卡窗格?

注意:我知道它在选项卡窗格上执行 show() 和 hide() 的基本操作,但我觉得手动执行所有这些操作会阻止我使用回调等

javascript jquery tabs twitter-bootstrap

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

使用后台工作者进行片段缓存

我有一个呈现很多部分内容的页面。我将它们全部缓存起来,这使得速度非常快。天哪!

问题是,由于部分的数量,第一次运行,在写入缓存时,需要很长时间,请求超时(但其他时间真的很快)

我也使用 sidekiq (但问题与任何后台处理器相关)

有没有办法将这些部分保存在后台进程中,以便错过缓存(由于过期)的用户不会超时?所以我会检查所有部分,以及那些缓存过期(或即将过期)的部分,我将重新缓存它们?

caching ruby-on-rails fragment-caching background-process ruby-on-rails-4

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

Xcode中的灰色变暗

我正在尝试调试+了解自动布局约束,我注意到在使用xcode调试视图时(使用酷层事物)我注意到在视图中的一个元素上,约束看起来像这样

在此输入图像描述

而观点确实忽略了这些限制.

所有约束具有相同的优先级(1000),因为我想要它们.所有约束都是使用接口构建器而不是通过代码进行的,并且IB中没有警告或冲突.

但在运行时我确实看到了这一点

Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSLayoutConstraint:0x79684f10 V:[UIImageView:0x79686800(>=160)]>",
    "<NSLayoutConstraint:0x7968a310 V:[UIImageView:0x79686800]-(130.5)-|   (Names: '|':UIView:0x79686790 …
Run Code Online (Sandbox Code Playgroud)

xcode constraints objective-c ios autolayout

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

搜索栏在导航栏中更改颜色

我在导航项目的标题视图中添加了一个搜索栏.搜索工作正常,但使用导航控制器时,搜索栏的背景会改变颜色,如下所示

我触摸颜色的唯一地方是通过xcode更改故事板中导航项的颜色

将搜索栏放在titleview中的相关代码

_searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
[_searchController.searchBar sizeToFit];
self.navigationItem.titleView = _searchController.searchBar;
Run Code Online (Sandbox Code Playgroud)

导致这种颜色的原因是什么?

在此输入图像描述

试图改变bartint颜色

[_searchController.searchBar setBarTintColor:[UIColor clearColor]];
Run Code Online (Sandbox Code Playgroud)

但我得到了这个 在此输入图像描述

还有一些不起作用的东西

[_searchController.searchBar setBarTintColor:self.navigationController.navigationBar.tintColor];
_searchController.searchBar.backgroundColor = self.navigationController.navigationBar.tintColor;
Run Code Online (Sandbox Code Playgroud)

backgroundColor

似乎这种颜色不同于设置.请看这里的redColor

在此输入图像描述

uinavigationcontroller uisearchbar ios

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

在Rails中查询Postgres整数数组

我的模型有一个pg数组,我用它来存储整数

使用我从其他问题中找到的方法查询会产生错误或给出空的结果

MyModel.where("? = ANY (myarray)", 42)
Run Code Online (Sandbox Code Playgroud)

PG::UndefinedFunction: ERROR:  operator does not exist: integer = text
Run Code Online (Sandbox Code Playgroud)

 MyModel.where("myarray @> '{?}'", 42)
Run Code Online (Sandbox Code Playgroud)

给出一个空的结果,但我确实有一个42的模型作为数组中的一个int

#<MyModel:0x007f9a77dd5608> {
                :id => 170,
      :myarray => [
    [0] 42,
    [1] 43,
    [2] 58,
    [3] 61,
    [4] 63
  ]
Run Code Online (Sandbox Code Playgroud)

有没有一种特殊的方法来查询Rails中postgres数组中的整数(或浮点数)?

迁移

class AddMyarrayToMyModel < ActiveRecord::Migration
  def change
    add_column :my_models, :myarray, :integer, array: true, default: []
    add_index  :my_models, :myarray, using: 'gin'
  end
end
Run Code Online (Sandbox Code Playgroud)

和架构

t.integer  "myarray",                 default: [],              array: true
Run Code Online (Sandbox Code Playgroud)

arrays postgresql activerecord ruby-on-rails ruby-on-rails-4

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

测试与 docker 守护进程的连接

我正在编写一个将自动启动 docker-compose 的脚本。

但是,有时,这样eval "$(docker-machine env default)"做不会导致 docker 守护进程立即连接,当下一行出现时 ( docker-compose up) 我得到Cannot connect to the Docker daemon. Is the docker daemon running on this host?

如果我使用sleep几秒钟,问题就会解决。

有没有办法通过一些系统工具测试连接到守护程序(检查进程是否存在,是否进行了网络连接,端口监听等)?我想在外部测试 docker 守护进程而不是使用dockercli

linux docker

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

使用 pycharm 调试 console_script

我有一个复杂的 python 程序,我想调试 setup.py 的位置

 entry_points=dict(
      console_scripts=[
          'myprog = myprog.command:myprog_main',
      ]
  )
Run Code Online (Sandbox Code Playgroud)

其中 command.py 具有接受命令的逻辑,因此我可以运行类似的东西

myprog process --config config.yaml 
Run Code Online (Sandbox Code Playgroud)

在 pycharm 中放置断点不会导致程序停止,因为 dopython command.py process --config config.yaml不会执行任何操作

我觉得这是基本的东西,但我找不到调试它的方法(使用 pycharm)

python pycharm

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