小编new*_*ike的帖子

macvim无法折叠代码"E490:找不到折叠"

我不能在macvim中折叠我的代码

我的环境和设置在gist链接https://gist.github.com/poc7667/7035979

有没有想法?

hi  Comment  ctermfg=6



"function SetCafeOptions()
    "CoffeeCompile
    ":set nonu
    ":res -24
    ":res +24
"endfunction

set encoding=utf-8 
set fileencoding=utf-8 

colorscheme elflord            
set smartindent
set tabstop=4
set expandtab  
set shiftwidth=4

"make it autoreload
set autoread 

"auto move it last time the position you viewed
"make vim save and load the folding of the document each time it loads"
""also places the cursor in the last place that it was left."

"try to set show ansi color
if &term=="ansi" 
    set …
Run Code Online (Sandbox Code Playgroud)

vim macvim

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

sudo:无法解析主机ServerName(需要很长时间才能"sudo su")

我使用vmware并安装ubuntu 12.10作为我的客户操作系统.并运行我的电脑,我的网络接口是无线卡,但每当我尝试sudo时,我应该等待很长时间.和回声

sudo: unable to resolve host ServerName pocUbuntu
[sudo] password for poc: 
Run Code Online (Sandbox Code Playgroud)

我通过谷歌搜索几乎解决方案,没有解决方案可以解决我的问题.

当我输入主机名

root@ServerName pocUbuntu:/home/poc# hostname
ServerName pocUbuntu
Run Code Online (Sandbox Code Playgroud)

还有我的主机文件

 cat /etc/hosts
127.0.0.1   localhost pocUbuntu
127.0.0.1   pocUbuntu
127.0.1.1   pocUbuntu

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
Run Code Online (Sandbox Code Playgroud)

我可以在ping服务器名pocUbuntu时得到确认

root@ServerName pocUbuntu:/home/poc# ping pocUbuntu
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_req=1 ttl=64 time=0.030 ms
64 bytes from localhost (127.0.0.1): icmp_req=2 ttl=64 time=0.026 …
Run Code Online (Sandbox Code Playgroud)

ubuntu sudo ubuntu-12.10

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

git push error"错误:src refspec xxx与any不匹配." 使用git flow

我曾经在我的私人git服务器上创建一个repo

git init --bare
Initialized empty Git repository in /home/poc/git_repo/local_display_multi_langs            .git/
Run Code Online (Sandbox Code Playgroud)

然后我试着add remote在我的mac上工作.

git remote add origin ssh://poc@172.19.16.101/home/poc/git_repo/local_display_multi_langs.git
Run Code Online (Sandbox Code Playgroud)

执行以下命令

  514  git flow init
  519  git flow feature start read_xml
  524  git ci -am "first ci"
Run Code Online (Sandbox Code Playgroud)

然后尝试将所有分支推送到我的私有git服务器的repo并获得如下例外

[src] $ git push origin feature
poc@172.19.16.101's password:
error: src refspec feature does not match any.
error: failed to push some refs to 'ssh://poc@172.19.16.101/home/poc/git_repo/local_display_multi_langs.git'
Run Code Online (Sandbox Code Playgroud)

我错过或误用了一些步骤吗?

如何将我的工作副本上的所有分支推送到远程服务器?

然后当我从我的git服务器克隆项目时.

如何获得新的克隆项目和原始项目是完全相同的.

谢谢

感谢@VonC

现在,我可以将本地工作副本上的所有分支推送到远程服务器

git push origin --all

但是当我ssh://poc@172.19.16.101/home/poc/git_repo/local_display_multi_langs.git 在另一个文件夹下执行git clone时.

[local_display_multi_langs] $ git …
Run Code Online (Sandbox Code Playgroud)

git github git-flow

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

如何从docstring生成html文档

我有一个 Python 项目,在函数中写了很多文档字符串,

如何通过一两步将这些 docstring 转换为 html 文档,

我只希望 Sphinx 可以充当 doxygen,只需将我所有的评论或文档转换为 html 文档。

sphinx-quickstartdocs文件夹下运行

然后

> autodoc: automatically insert docstrings from modules (y/n) [n]: y
Run Code Online (Sandbox Code Playgroud)

然后修改了conf.py long_term_streaming_monitor/docs/source/conf.py

sys.path.insert(0, os.path.abspath('../../src'))
Run Code Online (Sandbox Code Playgroud)

因为我所有的源代码都放在 long_term_streaming_monitor/src

生成的代码在这里下载

我遵循了教程,但是当我打开 index.html 时,我什么也没得到,html 文件链接上没有列出模块和方法

.
??? docs
?   ??? _build
?   ?   ??? doctrees
?   ?   ??? html
?   ?       ??? _sources
?   ?       ??? _static
?   ??? _static
?   ??? _templates
?   ??? html
??? src
    ??? long_term_streaming_monitor
    ? …
Run Code Online (Sandbox Code Playgroud)

python python-sphinx

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

不可读的zsh shell和backspace在Docker上的zsh shell上不起作用

我用过这个FROM rails:onbuild图片

  • 您可以在此处查看错误/不可读的编码

  • 当我在测试后键入退格键时,它不起作用,它在shell上添加了空格

这是环境变量,

任何关于bug的想法?

RUBY_MAJOR=2.2
RUBY_VERSION=2.2.2
RUBY_DOWNLOAD_SHA256=5ffc0f317e429e6b29d4a98ac521c3ce65481bfd22a8cf845fa02a7b113d9b44
GEM_HOME=/usr/local/bundle
BUNDLE_APP_CONFIG=/usr/local/bundle
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_ALL=en_US.UTF-8
HOME=/root
LOGNAME=root
SHLVL=1
PWD=/associate-app
OLDPWD=/associate-app
ZSH=/root/.oh-my-zsh
PAGER=less
LESS=-R
LSCOLORS=Gxfxcxdxbxegedabagacad
_=/usr/bin/env
Run Code Online (Sandbox Code Playgroud)

DOCEKRFILE(这是我的docker文件)

FROM rails:onbuild
RUN apt-get update && apt-get -y upgrade
RUN apt-get -y -qq --force-yes install \
        build-essential \
        tree \
        locales \
        ruby-dev \
        vim \
        vim-scripts \
        git \
        git-flow\
        curl \
        zsh \
        sudo



# Install Zsh
RUN git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh \
      && cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc \
      && …
Run Code Online (Sandbox Code Playgroud)

linux zsh docker boot2docker

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

Omniauth设计身份验证失败!csrf_detected:

我得到了 Authentication failure! csrf_detected: 所以我无法登录omniauth.

我按照本教程

我在这里发现了类似的问题,

但到目前为止我的问题没有运气.

有没有修复错误的想法?谢谢

E, [2015-06-27T10:40:06.028200 #18798] ERROR -- omniauth: (facebook) Authentication failure! csrf_detected: OmniAuth::Strategies::OAuth2::CallbackError, csrf_detected | CSRF detected
Run Code Online (Sandbox Code Playgroud)

宝石

  * devise (3.5.0)
  * omniauth (1.2.2)
  * omniauth-facebook (2.0.0)
  * omniauth-oauth2 (1.3.1)
Run Code Online (Sandbox Code Playgroud)

/app/controllers/application_controller.rb

   protect_from_forgery with: :exception
-
+  before_action :authenticate_user!
Run Code Online (Sandbox Code Playgroud)

/app/models/user.rb

   devise :database_authenticatable, :registerable,
+         :omniauthable, :omniauth_providers => [:facebook]
+  def self.from_omniauth(auth)
+    where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
+      binding.pry
+      user.provider = auth.provider
+      user.uid = auth.uid
+      user.email = …
Run Code Online (Sandbox Code Playgroud)

devise omniauth ruby-on-rails-4

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

Rails缓存将阻止客户端的请求

防止缓存阻止的请求并自动重新生成新缓存

我们可以轻松制作Rails cache,并设置过期时间

Rails.cache.fetch(cache_key, expires_in: 1.minute) do
    `fetch_data_from_mongoDB_with_complex_query`
end
Run Code Online (Sandbox Code Playgroud)

不知何故,当新请求进入时,会发生过期,并且请求将被阻止.我的问题是,我怎样才能避免这种情况?基本上,我希望在Rails进行缓存时将先前的缓存提供给客户端的请求.

如预期的行为图所示,第二个请求将获得cache 1但不是cache 2,尽管Rails正在制作cache 2.因此,用户不必花费太多时间来制作新的缓存.那么,如何在没有用户请求触发的情况下自动重新生成所有缓存?

预期的行为

缓存片段

     cache_key = "#{__callee__}"
     Rails.cache.fetch(cache_key, expires_in: 1.hour) do
       all.order_by(updated_at: -1).limit(max_rtn_count)
     end
Run Code Online (Sandbox Code Playgroud)

更新

我怎样才能获得命令中的所有缓存键?

因为缓存的查询可以通过的组合物中产生start_date,end_date,depature_at,arrive_at.

无法手动使所有缓存的密钥无效.

我怎样才能获得所有缓存键,然后在Rake任务中刷新

ruby-on-rails ruby-on-rails-4

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

我怎么能自动一个一个地提交远程分支

假设我在本地分支机构中有以下提交,

最古老的是17081fa,最新的是12ba64e

我怎么能一个接一个地将这些提交推送到远程git服务器.

举个例子,

I don't want to push all local commits at once.

the push order should be

17081fa -> 30854d2 -> ... -> 12ba64e
Run Code Online (Sandbox Code Playgroud)

这些提交已准备好推送到服务器,但需要逐个推送,

我需要知道命令可以让我这样做,谢谢

* 12ba64e 
* 0fdf1a6 
* 75428a3 
* 00f837f 
* da9d16d 
* 3f34af9 
* b6066e9 
* cdf2dbf 
* 0d5cc8b 
* db8744c 
* df564b9 
* 30854d2 
* 17081fa 
Run Code Online (Sandbox Code Playgroud)

git

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

我如何将块传递给 Python 中的函数,就像在 Ruby 中传递块的方式一样

在 Ruby 中,我可以将一段代码传递给一个方法。

例如,我可以将不同的代码块传递给get_schedules_with_retries方法。

并通过调用 black.call 调用块

我想知道如何在 Python 中实现该逻辑,

因为我有很多代码块,需要重试模式。

我不喜欢retry logic在许多代码块中复制粘贴

例子:

def get_schedules_with_retries(&block)
  max_retry_count = 3
  retry_count = 0
  while (retry_count < max_retry_count)
    begin
      schedules = get_more_raw_schedules
      block.call(schedules)
    rescue Exception => e
      print_error(e)
    end
    if schedules.count > 0
      break
    else
      retry_count+=1
    end
  end
  return schedules
end

get_schedules_with_retries do |schedules|
  # do something here
end

get_schedules_with_retries do |schedules|
  # do another thing here
end  
Run Code Online (Sandbox Code Playgroud)

python

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

如何处理反应表上的点击行事件

互联网上的所有示例都使用旧式>组件,我找不到任何示例来说明如何处理 row_click 事件。我尝试了下面的示例,但没有运气。它不会被const onRowClick = (state, rowInfo, column, instance) => {阻止,因为它应该是。

        import React from 'react'
        import {useTable, useSortBy, useTableState, usePagination} from 'react-table'

        function Table({getTrProps, columns, data}) {
            const tableState = useTableState({pageIndex: 2})
            const {
                getTableProps,
                getTrProps,
                ....
                state: [{pageIndex, pageSize}],
            } = useTable(
                {
                    getTrProps,
                    columns,
                    data,
                    state: tableState,
                },
                useSortBy,
                usePagination
            )



            // Render the UI for your table
            return (
                <>

                    <table {...getTableProps()}
                           className="table table-bordered"
                    >
                        <thead>
                        {headerGroups.map((headerGroup): any => (
                            <tr {...headerGroup.getHeaderGroupProps()}
                                className={`tx-10 …
Run Code Online (Sandbox Code Playgroud)

reactjs react-table

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