小编Pok*_*u22的帖子

在GBDK c中使用采样音频播放时如何运行代码?

我正在为GBDK中的GameBoy制作游戏,我正在尝试为游戏添加声音.GBDK有一个从一组值中播放声音的功能,唯一的问题是,当它播放声音时,脚本的其余部分会冻结.有没有办法可以让它们同时运行?

c audio gameboy

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

如何让Log4j使用stdout?

我正在使用log4j在一些我正在进行调试的代码中.我一直在运行我的代码java -jar test.jar | tee file.txt来登录到一个文件,但现在我希望能够在我仍在运行时切换我正在登录的文件,这是tee无法做到的.现在我正在这样做

private static final Logger log = LoggerFactory.getLogger(Test.class);

public void main() {
File file = new File(/path/to/file);
System.setOut(new PrintStream(file));
System.out.println("hello world"); //This works.
log.info("hello world"); //this doesn't.
Run Code Online (Sandbox Code Playgroud)

由于某种原因,Logger输出不会进入我的文件,它会进入我的控制台,但println()工作正常.有谁知道为什么会这样,以及如何解决这个问题?

谢谢.

编辑:这是我的log4j.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

    <appender name="console" class="org.apache.log4j.ConsoleAppender">
        <layout class="org.apache.log4j.PatternLayout">
            <!--<param name="ConversionPattern" value="%d %-5p [%c] %m%n" />-->
            <param name="ConversionPattern" value="%d %-5p [%c:%L] %m%n" />
        </layout>
    </appender>
    <logger name="com.company">
        <level value="trace" />
    </logger>
    <logger name="org.springframework">
        <level …
Run Code Online (Sandbox Code Playgroud)

java log4j

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

如何检查Java源文件是否有效(没有错误)?

在我的代码我打开我的file.java和解析他JavaParser类.

FileInputStream in = new FileInputStream(".../file.java");

        CompilationUnit cu;

        try {
            // parse the file
            cu = JavaParser.parse(in);
        } finally {
            in.close();
        }

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

file.java:

public class File{

     public void ownMethod(){...}

     public static void main(String[] args){

          ownMethod(5); //Note the extra parameter

     }
}
Run Code Online (Sandbox Code Playgroud)

在file.java中有一个错误:该main方法ownMethod使用一个参数调用该方法,但ownMethod需要0个参数.JavaParser未检测到此错误,并使用此错误解析file.java.我怎么知道(在我的代码中)file.java是否没有错误?没有使用java编译器它是否可行?

java validation javaparser

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

https请求基本认证node.js

我真的很疯狂地在网络和 stackoverflow 上寻找这个。关于此主题的其他帖子讨论的是 http 请求,而不是 httpS。

我正在使用 node.js 编码服务器端,我需要向另一个网站发出 https 请求才能登录

如果我在 Chrome 中使用邮递员工具尝试使用https://user:pass@webstudenti.unica.it/es​​se3/auth/Logon.do一切正常并且我登录。

如果我在节点中使用请求库,我将无法登录,并且会收到一个页面,其中包含有关获取/发送数据中的错误的自定义错误消息。

也许我错误地设置了传递给请求的选项。

var request = require('request');
var cheerio = require('cheerio');
var user =  'xxx';
var pass = 'yyy';
var options = {
    url : 'https://webstudenti.unica.it',
    path : '/esse3/auth/Logon.do',
    method : 'GET',
    port: 443,
    authorization : {
        username: user,
        password: pass
    }
}

request( options, function(err, res, html){
    if(err){
        console.log(err)
        return
    }
    console.log(html)
    var $ = cheerio.load(html)
    var c = $('head title').text();
    console.log(c);
})
Run Code Online (Sandbox Code Playgroud)

http://jsfiddle.net/985bs0sc/1/

javascript authentication https node.js

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

在c中放置无限条件

我正在运行一个带有无限for循环的C程序:

for(;;)
{
    //Statement
}
Run Code Online (Sandbox Code Playgroud)

为什么它运行无限次数,即使我们没有指定循环的初始化,条件和增量?

"空白"值的含义是什么?

c infinite-loop

5
推荐指数
2
解决办法
117
查看次数

phpmyadmin将所选数据从SQL导出为ex​​cel

我有一个问题,我需要从我的phpmyadmin导出选定的数据,我正在使用XAMPP.

我有一个名为" Tbl_Records" 的表,我只需要获取2014年的所有数据或该表中的特定年份.

我试过了

Select * From Tbl_Records Where Year = 2014
Run Code Online (Sandbox Code Playgroud)

在Phpmyadmin只获取特定年份,然后导出数据,但它仍然导出所有内容.

php mysql database excel phpmyadmin

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

[Something]和[SomethingAttribute]之间有什么区别?

这可能已经被问到了,但很难找到.

[Something]和之间有什么区别[SomethingAttribute]

以下两个编译:

[DefaultValue(false)]
public bool Something { get; set; }
Run Code Online (Sandbox Code Playgroud)
[DefaultValueAttribute(false)]
public bool SomethingElse { get; set; }
Run Code Online (Sandbox Code Playgroud)

除了外观之外,它们之间是否有任何差异?它们使用的一般准则是什么?

c# .net-attributes

5
推荐指数
2
解决办法
167
查看次数

带有用户名令牌和客户端证书的WCF SOAP调用

我正在尝试使用用户名令牌(用户名/密码)和客户端证书来调用Web服务(不确定后端是什么写入).

简短版本:如果我有一个客户端证书和用户名/密码可以使用WCF代码/配置的组合来生成下面的SOAP标头?

长版

下面是由Visual Studio 2010中的"添加服务引用"生成的服务接口(名称/ URI已更改以保护无辜者):

 [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    [System.ServiceModel.ServiceContractAttribute(Namespace="http://servicenamespacehere", ConfigurationName="Service.Contract.ConfigName.Here")]
    public interface IBackendService {

        // CODEGEN: ...
        [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://servicenamespacehere#Method1")]
        [System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
        void Method1(Method1Params request);
Run Code Online (Sandbox Code Playgroud)

我需要生成的调用的SOAP安全标头如下所示:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
   <s:Header>
      <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
         <u:Timestamp u:Id="_0">
            <u:Created>2014-08-26T20:22:50.522Z</u:Created>
            <u:Expires>2014-08-26T20:27:50.522Z</u:Expires>
         </u:Timestamp>
         <o:UsernameToken u:Id="uuid-6f243c9c-fd85-4634-8b57-cb196aee3195-60591">
            <o:Username>myUser</o:Username>
            <o:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">somePwd</o:Password>
         </o:UsernameToken>
         <o:BinarySecurityToken u:Id="uuid-6f243c9c-fd85-4634-8b57-cb196aee3195-60592" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">BASE64TOKENHERE=</o:BinarySecurityToken>
         <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
            <SignedInfo>
               <CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
               <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
               <Reference URI="#_0">
                  <Transforms>
                     <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
                  </Transforms>
                  <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
                  <DigestValue>BASE64DIGESTHERE=</DigestValue>
               </Reference>
            </SignedInfo>
            <SignatureValue>BASE64SIGNATUREHERE=</SignatureValue>
            <KeyInfo>
               <o:SecurityTokenReference>
                  <o:Reference ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" URI="#uuid-6f243c9c-fd85-4634-8b57-cb196aee3195-60592"/>
               </o:SecurityTokenReference>
            </KeyInfo>
         </Signature>
      </o:Security>
   </s:Header>
   SOAP XML PAYLOAD …
Run Code Online (Sandbox Code Playgroud)

.net c# wcf ws-security soap

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

获取char代码点的方法是什么?

我需要用代码点和换行符做一些事情.我有一个带有char代码点的函数,如果\r它需要表现不同.我有这个:

if (codePoint == Character.codePointAt(new char[] {'\r'}, 0)) {
Run Code Online (Sandbox Code Playgroud)

但这非常难看,当然也不是正确的做法.这样做的正确方法是什么?

(我知道我可以对数字13(十进制标识符\r)进行硬编码并使用它,但这样做会让我不清楚我在做什么......)

java unicode char codepoint

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

单头文件,包含所有必需的#include语句

我目前正在处理包含大量源文件的程序.有时很难跟踪我已经拥有的库#include.从理论上讲,我可以创建一个单独的头文件Headers.h,它只包含#include我需要的所有语句,然后生成所有其他头文件#include "Headers.h".

为什么这是一个好/坏的主意?

c c++ header include

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