小编rub*_*ots的帖子

禁用Visual Studio 2013中的所有CAPS菜单项

在Visual Studio 2013中,Microsoft再次将UPPERCASE中的菜单显示为默认菜单.

这些可以修改为句子案吗?

visual-studio-2013

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

PHP中的关联数组的插值(双引号字符串)

在插入PHP的字符串索引数组元素(5.3.3,Win32)时,可能会出现以下行为:

$ha = array('key1' => 'Hello to me');

print $ha['key1'];   # correct (usual way)
print $ha[key1];     # Warning, works (use of undefined constant)

print "He said {$ha['key1']}"; # correct (usual way)
print "He said {$ha[key1]}";   # Warning, works (use of undefined constant)

print "He said $ha['key1']";   # Error, unexpected T_ENCAPSED_AND_WHITESPACE
print "He said $ha[ key1 ]";   # Error, unexpected T_ENCAPSED_AND_WHITESPACE
print "He said $ha[key1]";     # !! correct (How Comes?)
Run Code Online (Sandbox Code Playgroud)

无意中,最后一行似乎是正确的PHP代码.有什么解释吗?这个功能可以信任吗?


编辑:现在以粗体显示的发布点,以减少误解.

php associative-array

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

mysql 5中的多列子选择(5.1.42)

这个似乎是一个简单的问题,但我不能使它在单个选择或嵌套选择中工作.将论文(文章)的作者和(如果有的话)顾问检索到一行.

我为了解释这个问题,这里有两个数据表(伪)

papers (id, title, c_year)
persons (id, firstname, lastname)
Run Code Online (Sandbox Code Playgroud)

加上一个带有一个额外属性(伪)的链接表:

paper_person_roles(
  paper_id
  person_id
  act_role ENUM ('AUTHOR', 'ADVISER')
)
Run Code Online (Sandbox Code Playgroud)

这基本上是一份书面文件清单(表格:文件)和工作人员和/或学生名单(表格:人员)

我有一篇文章(1,N)作者.
一篇文章可能有(0,N)顾问.
一个人可以是"AUTHOR"或"ADVISER"角色(但不能同时).

应用程序最终会输出包含以下条目的表行:

TH: || Paper_ID  |  Author(s)          |   Title                 |   Adviser(s)  |
TD: ||   21334   |John Doe, Jeff Tucker|Why the moon looks yellow|Brown, Rayleigh|
...

我的第一种方法是:
在应用程序中选择/提取完整的文章列表,例如.

SELECT 
   q.id, q.title
FROM 
   papers AS q
ORDER BY 
   q.c_year
Run Code Online (Sandbox Code Playgroud) 并将查询结果保存到数组中(在应用程序中).在此步骤之后,循环返回的信息数组并通过链接表中的预准备语句(?是纸张的id)检索作者和顾问(如果有),如:
APPLICATION_LOOP(paper_ids in array)
  SELECT 
      p.lastname, p.firstname, r.act_role 
  FROM 
      persons AS p, paper_person_roles AS r
   WHERE 
      p.id=r.person_id AND r.paper_id …
Run Code Online (Sandbox Code Playgroud)

mysql sql subquery

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

在Perl中使用巨大的文本节点读取xml的可行方法

在遇到包含大文本节点的xml数据文件后,我找了一些方法来在我的数据处理脚本中读取和评估它们.

xml文件是用于分子建模应用程序的3D坐标文件,具有此结构(示例):

<?xml version="1.0" encoding="UTF-8"?>
<hoomd_xml version="1.4">
   <configuration>
      <position>
        -0.101000   0.011000  -40.000000
        -0.077000   0.008000  -40.469000
        -0.008000   0.001000  -40.934000
        -0.301000   0.033000  -41.157000
         0.213000  -0.023000  -41.348000
         ...
         ... 300,000 to 500,000 lines may follow  >>
         ...
        -0.140000   0.015000  -42.556000
      </position>

      <next_huge_section_of_the_same_pattern>
        ...
        ...
        ...
      </next_huge_section_of_the_same_pattern>

   </configuration>
</hoomd_xml>
Run Code Online (Sandbox Code Playgroud)

每个xml文件包含几个巨大的文本节点,大小在60MB到100MB之间,具体取决于内容.

我首先使用XML :: Simple尝试了naíveapproch,但加载器将永远需要最初解析文件:

...
my $data = $xml->XMLin('structure_80mb.xml');
...
Run Code Online (Sandbox Code Playgroud)

并停止" 内部错误:巨大的输入查找 ",所以这种方法不太实用.

下一个尝试是使用XML :: LibXML进行读取 - 但是在这里,初始加载器会立即挽救,并显示错误消息" 解析器错误:xmlSAX2Characters:huge text node ".

为了在stackoverflow上写这个主题,我为自己编写了一个q&d解析器并通过它发送文件(在将xx MB xml文件拖入标量之后$xml):

...
# …
Run Code Online (Sandbox Code Playgroud)

xml perl xml-parsing

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

VS2015.3/PTVS Python工具不再有效?

强大的文字我重新安装了VS 2015 Update 3(来自Web安装)w/Python Tools,但Python工具似乎不再起作用了.从ActivityLog.xml,错误是:

<record>494</record>
<time>2016/07/04 15:59:16.031</time>
<type>Error</type>
<source>VisualStudio</source>
<description>LegacySitePackage failed for package [Python Tools
             Package]Source:
&apos;Microsoft.VisualStudio.Composition&apos; 
Description: Expected 1 export(s) with contract name
&quot;Microsoft.PythonTools.Interpreter.IInterpreterOptionsService&quot;
but found 0 after applying applicable constraints.
#x000D;&#x000A;
Microsoft.VisualStudio.Composition.CompositionFailedException: 
Expected 1 export(s) with contract name 
&quot;Microsoft.PythonTools.Interpreter.IInterpreterOptionsService&quot; 
but found 0 after applying applicable constraints.&#x000D;&#x000A;   
Microsoft.VisualStudio.Composition.ExportProvider.GetExports
(ImportDefinition importDefinition)&#x000D;&#x000A;   at 
Microsoft.VisualStudio.Composition.ExportProvider.GetExports
[T,TMetadataView](String contractName, ImportCardinality 
cardinality)&#x000D;&#x000A;   at    
Microsoft.VisualStudio.Composition.ExportProvider.GetExport
[T,TMetadataView]       (String contractName)&#x000D;&#x000A;   at
Microsoft.VisualStudio.Composition.ExportProvider.GetExport[T]
(String   contractName)&#x000D;&#x000A;   at    
Microsoft.VisualStudio.Composition.ExportProvider.GetExport[T]
()&#x000D;&#x000A;   at   
Microsoft.VisualStudio.Composition.ExportProvider.GetExportedValue
[T]  ()&#x000D;&#x000A;   at 
Microsoft.VisualStudio.ComponentModelHost.ComponentModel.GetService
[T] …
Run Code Online (Sandbox Code Playgroud)

python-2.7 ptvs visual-studio-2015

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

std :: vector及其迭代器作为单个模板typename

为了获得索引生成函数std :: distance(a,b)的"易于记忆"的接口,我提出了更好地区分它的参数的想法(当使用它的基础时vector:vec.begin())通过使用向量及其迭代器调用模板化函数,如:

std::vector<MyType> vect;
std::vector<MyType>::const_iterator iter;
...
...
size_t id = vectorindex_of(iter, vect);
Run Code Online (Sandbox Code Playgroud)

从不混淆论点顺序的理由;-)

上述观点的明确表述将会读到.喜欢

 template <typename T>
 inline 
 size_t vectorindex_of( 
          typename std::vector<T>::const_iterator iter, 
          const std::vector<T>& vect ) {

  return std::distance( vect.begin(), iter ); 
 }
Run Code Online (Sandbox Code Playgroud)

......虽然有效,但看起来很尴尬.

我希望让模板机制隐式推导出类似(伪代码)的类型:

 template <typename T>
 inline 
 size_t vectorindex_of(T::const_iterator iter, const T& vect) {
    return std::distance( vect.begin(), iter ); 
 }
Run Code Online (Sandbox Code Playgroud)

......哪个不起作用.但为什么?

c++ iterator stl

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

PHP最近放弃了[[:POSIX:]]正则表达式的味道

在以后的PHP版本中删除了ereg函数及其POSIX正则表达式的味道?

在阅读了较旧的帖子"PHP ereg vs. preg"(2009年9月)关注此事 - 并阅读官方PHP声明后,我倾向于问这是关于什么的.随着PHP多年来的发展(以及在Perl和PHP上做了很多开发),我真的不确定这最终是不是一个糟糕的漂移.

我假设这里有一些PHP开发团队的成员,因此他们能够帮助我们更深入地了解这一点.

是否有计划的增强(未来)以[[:POSIX:]]样式完成preg-functions?或者后者会永远消失吗?这两项决定背后的理由是什么?

php regex posix posix-ere ereg

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

fclose()有什么意义?

从我读到的内容来看,fclose()基本上就像分配了内存时的free(),但我还读到操作系统会为你关闭该文件并冲掉它终止后打开的任何流.我甚至测试了一些没有fclose()的程序,它们似乎都运行良好.

c fclose

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