gem install – error : Connection reset by peer

sudo gem install cocoapods

ERROR:  Could not find a valid gem ‘cocoapods’ (>= 0), here is why:

          Unable to download data from https://rubygems.org/ – Errno::ECONNRESET: Connection reset by peer – SSL_connect (https://rubygems.org/latest_specs.4.8.gz)

上面这个错误可能是由于GFW引起了, 所以把source rubygems.org改成baobao.com就可以了

$ gem sources --remove https://rubygems.org/
$ gem sources -a https://ruby.taobao.org/
$ gem sources -l
*** CURRENT SOURCES ***

https://ruby.taobao.org

更多详情见 https://ruby.taobao.org/

php null empty

NULL

The special NULL value represents a variable with no value. NULL is the only possible value of type null.

A variable is considered to be null if:

  • it has been assigned the constant NULL.

  • it has not been set to any value yet.

  • it has been unset().


empty

emptyDetermine whether a variable is empty

Description

bool empty ( mixed $var )

Determine whether a variable is considered to be empty. A variable is considered empty if it does not exist or if its value equals FALSE. empty() does not generate a warning if the variable does not exist.

Returns FALSE if var exists and has a non-empty, non-zero value. Otherwise returns TRUE.

The following things are considered to be empty:

  • “” (an empty string)
  • 0 (0 as an integer)
  • 0.0 (0 as a float)
  • “0” (0 as a string)
  • NULL
  • FALSE
  • array() (an empty array)
  • $var; (a variable declared, but without a value)

how to assign var to php template view file

    the function below demo how to assign var to php template view file
    下面的函数显示怎么传递变量到模板文件里
    public function renderInternal($_viewFile_,$_data_=null,$_return_=false)
	{
		// we use special variable names here to avoid conflict when extracting data
		if(is_array($_data_))
			extract($_data_,EXTR_PREFIX_SAME,'data');
		else
			$data=$_data_;
		if($_return_)
		{
			ob_start();
			ob_implicit_flush(false);
			require($_viewFile_);
			return ob_get_clean();
		}
		else
			require($_viewFile_);
	}

watir takes long time to set long string, watir要很长的时间设置长字符串

watir takes long time to set long string, watir要很长的时间设置长字符串

watir is great, though if you want to set long string to text field or textarea,

it may take a long long time to finish it when you use statement as

$browser.text_field(:name => "comment").set('long long ...... string ...')
fortunately, you can use this statement to avoid it, it is fast to set the long string with watir
$browser.text_field(:name => "comment").value = ($comments)
watir是个不错的东东,但如果你用set方法去设置一个很长的字条串的话, 那就可能需要很长的时间才能执行完这个语句,
不用担心你可以用直接设置value的值, 这样就很快了, 根本不用等待,就执行完成了

安装watir gem install watir 出了好多错

安装watir   gem install watir 出了好多错

例如:too many connection resets

SocketError: getaddrinfo:

Unable to resolve dependencies:

the installation aborts because of the network issue, but i don’t know why, the only thing i can do is that retry over and over again, it finally install successfully,  below is my retry history

但有时好像又可以进行下去, 可能是由于网络的原因, 中途会失败,也不知道是为什么, 只能一次一次进重试,最终还是成功啦, 花了不少时间

C:\Users\guangjun>gem install watir
ERROR:  While executing gem … (Gem::RemoteFetcher::FetchError)
too many connection resets (http://production.cf.rubygems.org/gems/win32-a
-1.4.8-x86-mingw32.gem)

C:\Users\guangjun>gem install watir
ERROR:  While executing gem … (Gem::RemoteFetcher::FetchError)
SocketError: getaddrinfo: No such host is known.  (http://rubygems.org/gem
win32-api-1.4.8-x86-mingw32.gem)

C:\Users\guangjun>gem system –update
ERROR:  While executing gem … (RuntimeError)
Unknown command system

C:\Users\guangjun>gem update –system
Latest version currently installed. Aborting.
C:\Users\guangjun>gem install watir –no-ri –no-rdoc
Fetching: windows-pr-1.2.0.gem (100%)Fetching: windows-pr-1.2.0.gem
Fetching: win32-process-0.6.5.gem (100%)
Fetching: xml-simple-1.0.15.gem (100%)
Fetching: hoe-2.9.4.gem ( 37%)ERROR:  While executing gem … (Gem::RemoteFetc
r::FetchError)
too many connection resets (http://production.cf.rubygems.org/gems/hoe-2.9
.gem) Continue reading “安装watir gem install watir 出了好多错”