我遇到的问题包括在我的NodeJs项目中执行的文件.
我在同一目录中有两个文件:
a.js
var test = "Hello World";
Run Code Online (Sandbox Code Playgroud)
和
b.js
require('./a.js');
console.log(test);
Run Code Online (Sandbox Code Playgroud)
我执行b.js node b.js并得到错误ReferenceError: test is not defined.
我查看了文档http://nodejs.org/api/modules.html#modules_file_modules
我错过了什么?提前致谢.
我需要在类中定义IP地址,System.Net.IPAddress但方法是:
IPAddress ipaddress = IPAddress.Parse("127.0.0.1"); //127.0.0.1 as an example
Run Code Online (Sandbox Code Playgroud)
不起作用,还有另一种方法吗?
如何定义IP地址?
让我们说这是我的HTML:
<div id="foo">
<input id="goo" value="text" />
<span id="boo">
</span>
</div>
Run Code Online (Sandbox Code Playgroud)
我希望能够确定哪个标签属于html元素.
id为"foo"的示例元素= div,"goo"= input,"boo"= span...
所以像这样:
function getTag (id) {
var element = document.getElementById(id);
return element.tag;
}
Run Code Online (Sandbox Code Playgroud) 我需要通过shell执行带参数的php文件.
这是我将如何运行PHP文件:
php -q htdocs/file.php
我需要通过和传递参数'show'
php -q htdocs/file.php?show = show_name
不起作用
如果有人能告诉我执行什么命令以使用set参数执行php文件,那将非常感激.如果没有,试着引导我正确的方向.
每次我用rand()它运行程序都会给我相同的结果.
示例:
#include <iostream>
#include <cstdlib>
using namespace std;
int random (int low, int high) {
if (low > high) return high;
return low + (rand() % (high - low + 1));
}
int main (int argc, char* argv []) {
for (int i = 0; i < 5; i++) cout << random (2, 5) << endl;
}
Run Code Online (Sandbox Code Playgroud)
输出:
3
5
4
2
3
Run Code Online (Sandbox Code Playgroud)
每次运行程序时,每次都输出相同的数字.有没有解决的办法?
我很好奇Java的类和double的原始类型之间的性能差异.所以我创建了一个小基准测试,发现类类型比基本类型慢3x-7x.(在本地机器OSX上为3倍,在ideone上为7倍)
这是测试:
class Main {
public static void main(String args[]) {
long bigDTime, littleDTime;
{
long start = System.nanoTime();
Double d = 0.0;
for (Double i = 0.0; i < 1432143.341; i += 0.1) {
d += i;
}
long end = System.nanoTime();
bigDTime = end - start;
System.out.println(bigDTime);
}
{
long start = System.nanoTime();
double d = 0.0;
for (double i = 0.0; i < 1432143.341; i += 0.1) {
d += i;
}
long end = System.nanoTime();
littleDTime …Run Code Online (Sandbox Code Playgroud) 我已升级到VS2010并正在寻找vbuild可执行文件.对于VS2008,它位于:
C:\ Program Files(x86)\ Microsoft Visual Studio 9.0\VC\vcpackages\vcbuild.exe
VS2010在哪里?它不在:
C:\ Program Files(x86)\ Microsoft Visual Studio 10.0\VC\vcpackages\vcbuild.exe
我正在构建一个.net C#控制台程序,以将文件部署到Windows文件共享服务器(正在共享的文件夹).路径是::\\192.168.0.76\htdocs\public
在运行时我收到错误:
[09:35:29]: [Step 1/3] Unhandled Exception: System.UnauthorizedAccessException: Access to the path '\\192.168.0.76\htdocs\public' is denied.
[09:35:29]: [Step 1/3] at DeployFileShare.Program.CopyDir(String source, String dest, String[] exclude, Boolean overwrite)
[09:35:29]: [Step 1/3] at DeployFileShare.Program.Deploy(String num, String source)
[09:35:29]: [Step 1/3] at DeployFileShare.Program.Main(String[] args)
[09:35:29]: [Step 1/3] Process exited with code -532459699
Run Code Online (Sandbox Code Playgroud)
我想我需要对自己进行身份验证.我遇到过这个:
AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
WindowsIdentity idnt = new WindowsIdentity(username, password);
WindowsImpersonationContext context = idnt.Impersonate();
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
AppDomain.CreateDomain("192.168.0.76").SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
WindowsIdentity idnt = new WindowsIdentity("user", "pass");
WindowsImpersonationContext context = idnt.Impersonate();
Run Code Online (Sandbox Code Playgroud)
我不知道如何使用它.当我运行应用程序时,我得到:
C:\Users\Administrator>DeployFileShare 1 R:\BuildOutput\_PublishedWebsites\Web 2 …Run Code Online (Sandbox Code Playgroud) 我正在使用C#.NET和PHP,需要一些标准的方法来记录两者之间的时间.我希望自1970年以来使用秒= <?php echo time(); ?>因为我已经在我的项目中使用了一些php的酷函数,如:date()和strtotime()..net中有什么东西相当于PHP time()吗?
提前致谢.
我知道这可以获得数组的第一项
string aString = @"hello/all\this\is/a\test";
string firstItemOfSplit = aString.Split(new char[] {'\\', '/'})[0];
//firstItemOfSplit = hello
Run Code Online (Sandbox Code Playgroud)
有没有办法获得最后一项?就像是
string aString = @"hello/all\this\is/a\test";
string lastItemOfSplit = aString.Split(new char[] {'\\', '/'})[index.last];
//lastItemOfSplit = test
Run Code Online (Sandbox Code Playgroud)