小编CW *_* II的帖子

Perl中的"~~"是什么意思?

SO回答中, daxim指出:

@array ~~ $scalar is true when $scalar is in @array
Run Code Online (Sandbox Code Playgroud)

draegtun回复:

从5.10.1+开始,~~的顺序很重要.因此它需要是$ scalar ~~ @ array

关于~~源(s)的链接的小型入门如何包括以下具体问题:什么是~~?什么~~叫?为什么订单在一个版本中很重要但在之前的版本中却不重要?

请注意,一个好的摘要可能无法获得所有细节,可能很难写.引入或引用对于为不熟悉的人节省时间非常有用,~~同时扩展此Perlism的曝光度.

搜索字符串:non-word-tilde-tilde non-word-at-sign.

perl terminology smartmatch

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

完成C++ i18n gettext()"hello world"的例子

我正在寻找一个完整的i18n gettext()你好世界的例子.我已经使用 G. Mohanty的GNU gettext开始了一个基于本地语言支持的教程的脚本.我正在使用Linux和G ++.

码:

cat >hellogt.cxx <<EOF
// hellogt.cxx
#include <libintl.h>
#include <locale.h>
#include <iostream>
#include <cstdlib>
int main (){
    char* cwd = getenv("PWD");
    std::cout << "getenv(PWD): " << (cwd?cwd:"NULL") << std::endl;
    char* l = getenv("LANG");
    std::cout << "getenv(LANG): " << (l?l:"NULL") << std::endl;
    char* s = setlocale(LC_ALL, "");
    std::cout << "setlocale(): " << (s?s:"NULL") << std::endl;
    std::cout << "bindtextdomain(): " << bindtextdomain("hellogt", cwd) << std::endl;
    std::cout << "textdomain(): " << …
Run Code Online (Sandbox Code Playgroud)

c++ linux gettext internationalization

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

如何让模板功能有朋友(类似)访问?

如何修改以下代码以允许模板功能ask_runUI()使用s_EOF而不s_EOF公开?

#include <string>
#include <iostream>
#include <sstream>
#include <vector>
class AskBase {
protected:
    std::string m_prompt;
    std::string m_answer; 
    virtual bool validate(std::string a_response) = 0;
public:
    AskBase(std::string a_prompt):m_prompt(a_prompt){}
    std::string prompt(){return m_prompt;}
    std::string answer(){return m_answer;}
    static int const s_EOF = -99;
    static int const s_BACKUP = -1;
    static int const s_OK = 1;
    int ask_user();
};
template<typename T> class Ask : public AskBase{
public:
    Ask(std::string a_prompt):AskBase(a_prompt){}
    bool validate(std::string a_response);
};
template<> bool Ask<std::string>::validate(std::string a_response){return true;}
template<> bool …
Run Code Online (Sandbox Code Playgroud)

c++ templates function friend

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

C++"hello world"Boost tee示例程序

Boost C++库具有Function Template tee

类模板tee_filter和tee_device提供了两种分割输出序列的方法,以便将所有数据同时定向到两个不同的位置.

我正在寻找一个完整的C++示例,使用Boost tee输出到标准输出和像"sample.txt"这样的文件.

c++ boost-iostreams

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

什么是jQuery for Document.createElementNS()?

什么是jQuery for Document.createElementNS()?

function emleGraphicToSvg(aGraphicNode) {
  var lu = function luf(aPrefix){
    switch (aPrefix){
      case 'xhtml': return 'http://www.w3.org/1999/xhtml';
      case 'math':  return 'http://www.w3.org/1998/Math/MathML';
      case 'svg':   return 'http://www.w3.org/2000/svg';
      }
    return '';
    };
  var svg = document.evaluate("svg:svg",
    aGraphicNode, lu, XPathResult.FIRST_ORDERED_NODE_TYPE, null).
    singleNodeValue;
  $(svg).children().remove();
  rect = document.createElementNS(lu('svg'), "rect");
  rect.setAttribute("x", "35");
  rect.setAttribute("y", "25");
  rect.setAttribute("width", "200");
  rect.setAttribute("height", "50");
  rect.setAttribute("class", "emleGraphicOutline");
  svg.appendChild(rect);
  }
Run Code Online (Sandbox Code Playgroud)

该代码是Emle的简化片段- 电子数学实验室设备 JavaScript文件emle_lab.js.

Look-Up-Function luf()将完整引用映射到XPath字符串中的命名空间的缩短名称createElementNS().现有svg:svg的位置,删除并替换为新的矩形.

jquery xml-namespaces

11
推荐指数
2
解决办法
4972
查看次数

C++ 0x初始化列表示例

我想看看这个现有代码示例如何能够利用C++ 0x初始化列表功能.

Example0:

#include <vector>
#include <string>
struct Ask {
    std::string prompt;
    Ask(std::string a_prompt):prompt(a_prompt){}
};
struct AskString : public Ask{
    int min;
    int max;
    AskString(std::string a_prompt, int a_min, int a_max):
        Ask(a_prompt), min(a_min), max(a_max){}
};
int main()
{
    std::vector<Ask*> ui;
    ui.push_back(new AskString("Enter your name: ", 3, 25));
    ui.push_back(new AskString("Enter your city: ", 2, 25));
    ui.push_back(new Ask("Enter your age: "));
}
Run Code Online (Sandbox Code Playgroud)

它会支持这样的事情:

例1:

std::vector<Ask*> ui ={
    AskString("Enter your name: ", 3, 25),
    AskString("Enter your city: ", 2, 25),
    Ask("Enter your age: ") …
Run Code Online (Sandbox Code Playgroud)

c++ initializer-list c++11

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

OpenVMS下SAS中套接字的错误处理

我在OpenVMS上使用SAS 9.2通过一个用filename语句指定的套接字连接到外部数据源:

filename extsrc SOCKET "extserver:port" recfm=v;

data foo;
infile extsrc;
input;
.... some statements to read stuff ...;
run;
Run Code Online (Sandbox Code Playgroud)

99%的情况下(这应该)有效.但是,偶尔应该在远程端口上侦听的程序不是.目前,这会导致程序退出并显示错误:

Error: Connection refused.
Run Code Online (Sandbox Code Playgroud)

之后我们再试一次,它通常有效.然而,这变得乏味,所以我想在程序中检测到这个错误并在那里处理它.有人知道在SAS中检测此类错误的方法吗?

我已经尝试使用fileref()函数检查fileref extsrc的有效性,但这只返回-20005,这意味着fileref已分配但未指向本地文件(这是真的).当我在datastep中使用fileref时,错误才会变得明显,所以我想做的事情是:

data _null_;
rc=infile extsrc;
if rc=0 then do;
  //whatever I want to do;
end;
else do;
  //throw some error and try again later;
end;
run;
Run Code Online (Sandbox Code Playgroud)

[update1]我正在尝试下面的建议,但是在真正的heisenbug方式中,问题在过去几天没有出现,所以我不确定最终的解决方案是什么.[/ UPDATE1]

[update2]错误终于再次出现.根据cmjohns的回答,发生此错误后,syserr的值为1012.我现在将观察syserr的值,如果失败则再次尝试固定次数.[/ UPDATE2]

[update3]我已经有一些代码运行了几天,现在有效.另外一个问题是(当然)如果&syserr得到一个高于6的值,则出现错误情况,因此根据您的errorabend/noerrorabend设置,这会导致程序完全结束,或者导致程序继续obs=0处于syntaxchek模式.两者都不可取.解决方案是options noerrorabend nosyntaxcheck在产生此错误的datastep之前设置.此外,如果发生错误,我必须清除文件名extsrc并重新分配它.最后,一旦完成这段代码,我就恢复了errorabend.如果我恢复nosyntaxcheck,这会导致SAS检测到先前的错误情况并在该点切换到语法检查模式,这也是不合需要的.[/ UPDATE3]

sockets error-handling sas openvms

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

在zenity窗口中控制内容的大小?

我可以使用和参数控制zenity窗口的大小:--width--height

$ zenity --info --text="This is an information box." --width=600 --height=400
Run Code Online (Sandbox Code Playgroud)

有没有办法控制内容的大小?例如,我可以将用于显示文本的字体大小加倍吗?

user-interface zenity

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

Windows Azure Beast Exploit

我有一个客户端正在运行PCI兼容性扫描并获得以下内容:

BEAST (Browser Exploit Against SSL/TLS) Vulnerability
The SSL protocol encrypts data by using CBC mode with chained
initialization vectors. This allows an attacker, which is has gotten
access to an HTTPS session via man-in-the-middle (MITM) attacks or other means, to obtain plain text HTTP headers via
a blockwise chosen-boundary attack (BCBA) in conjunction with
Javascript code that uses the HTML5 WebSocket API, the Java
URLConnection API, or the Silverlight WebClient API. This
vulnerability is more commonly referred to as …
Run Code Online (Sandbox Code Playgroud)

azure

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

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