小编Doo*_*Dah的帖子

php curl -k或--insecure,-X

使用PHP和curl,我需要通过代理连接到SSL安全站点,并忽略证书警告.我的curl命令行如下所示:

curl -k -u username:password -X GET https://someURL
Run Code Online (Sandbox Code Playgroud)

通过curl.php,我看到我认为正确的选项设置.有了它们,我最终会得到这样的结论:

  $ch = curl_init("https://someURL");
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // Ignore cert errors?
  curl_setopt($ch, CURLOPT_PROXY, true);           // Proxy true?
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");     
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);            
  curl_setopt($ch, CURLOPT_USERPWD, "username:password");      
  $result = curl_exec($ch);
Run Code Online (Sandbox Code Playgroud)

但是,$ result总是返回false.我的密码中有一个特殊的字符,"!".也许我需要逃避它?除此之外,还有其他想法吗?

php curl

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

ctypes卸载DLL

我正在加载一个像这样的ctypes的DLL:

lib = cdll.LoadLibrary("someDll.dll");
Run Code Online (Sandbox Code Playgroud)

当我完成库,我需要卸载它以释放它使用的资源.我在文档中找到有关如何执行此操作的任何内容时遇到问题.我看到这个相当古老的帖子:如何在Python中使用ctypes卸载DLL?.我希望有一些显而易见的东西,我没有找到,而不是一个黑客.

python ctypes

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

Eclipse,Spring,Wildfly log4j日志记录

我在WildFly 8.0上运行Spring框架3.2.2.RELEASE.我正在尝试登录工作.我曾尝试阅读几个教程,但是,似乎无法获得任何输出到控制台或日志.我正在查看Eclipse中的控制台,以及wildfly/standalone/log/server.log中的日志.任何帮助记录日志的人都表示赞赏.

以下是一些有趣的代码:

SRC /主/资源/的log4j.xml:

<!-- Appenders -->
<appender name="console" class="org.apache.log4j.ConsoleAppender">
    <param name="Target" value="System.out" />
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="%-5p: %c - %m%n" />
    </layout>
</appender>

<!-- Application Loggers -->
<logger name="com.myCompany.myPackage">
    <level value="info" />
</logger>
    <!-- 3rdparty Loggers 
         omitted
    -->
<!-- Root Logger -->
<root>
    <priority value="warn" />
    <appender-ref ref="console" />
</root>
Run Code Online (Sandbox Code Playgroud)

wildfly /独立/配置/ standalone.xml:

        <subsystem xmlns="urn:jboss:domain:logging:2.0">
            <console-handler name="CONSOLE">
                <level name="INFO"/>
                <formatter>
                    <named-formatter name="COLOR-PATTERN"/>
                </formatter>
            </console-handler>
            <periodic-rotating-file-handler name="FILE" autoflush="true">
                <formatter>
                    <named-formatter name="PATTERN"/>
                </formatter>
                <file relative-to="jboss.server.log.dir" path="server.log"/>
                <suffix value=".yyyy-MM-dd"/>
                <append …
Run Code Online (Sandbox Code Playgroud)

java spring wildfly

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

Symfony2,twig和JavaScript

我需要做些什么才能让twig处理JavaScript文件?我有一个使用JavaScript twig的html.twig.像这样的东西:

{% extends 'BaseBundle::layout.html.twig' %}

{% block javascripts %}
    {{ parent() }}
    {% javascripts
        '@BaseBundle/Resources/js/main.js.twig'
    %}
    {% endjavascripts %}
{% endblock %}

< more template omitted >
Run Code Online (Sandbox Code Playgroud)

和main.js.twig的部分内容:

function testFunction()
{
    alert('{{VariableFromPHP}}');
}
Run Code Online (Sandbox Code Playgroud)

和控制器:

/**
 * @Route("/",name="home")
 * @Template("MyBundle:Default:index.html.twig")
 */
public function indexAction()
{
   return array( 'VariableFromPHP' => 'Hello World');
}
Run Code Online (Sandbox Code Playgroud)

我希望JavaScript在运行时看起来像这样:

alert('Hello World');
Run Code Online (Sandbox Code Playgroud)

但是,代码没有变化.我有什么想法我做错了吗?

谢谢,斯科特

php symfony twig

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

"语法错误:解析时出现意外的EOF",同时在PDB中迭代字典

pdbGET请求中设置了跟踪.我想打印请求对象的所有属性.我在pdb中尝试以下内容:

(Pdb) request
<GET /foo HTTP/1.1>
(Pdb) for d in dir(request):
*** SyntaxError: unexpected EOF while parsing (<stdin>, line 1)
Run Code Online (Sandbox Code Playgroud)

我相信我在这里缺少一些基本的东西.

python twisted pdb

9
推荐指数
2
解决办法
5275
查看次数

cx-freeze没有找到所有依赖项

我有一个python脚本(2.7),顶部有一些"有趣"的导入.我最初想用py2exe将它编译成一个我可以更容易分发的exe(py2exe找不到所有依赖项).

我放弃了,并试图使用cx-freeze代替.但是,我也有问题.问题似乎是我添加到Python(jinja2和restkit)的库.我在我的python目录中看到它们./Lib/site-packages/Jinja2-2.6-py2.7.egg/jinja2和这里./Lib/site-packages/restkit-4.2.1-py2.7.egg/restkit.

以下是我脚本中的导入:

import datetime
from jinja2 import Environment, PackageLoader
from optparse import OptionParser
from datetime import date, timedelta
from restkit import Resource, BasicAuth, request
Run Code Online (Sandbox Code Playgroud)

我正在使用带有cx-freeze的setup.py.这是setup.py:

from cx_Freeze import setup, Executable


packages  = ["restkit", "jinja2" , "restkit.client" ]
includes = []
includefiles = []
eggsacutibull = Executable(
    script = "myScript.py",
    initScript = None,
    targetName = "myScript.exe",
    compress = True,
    copyDependentFiles = True,
    appendScriptToExe = False,
    appendScriptToLibrary = False,
    icon = None
    )

setup(
        name = "myScript",
        version = …
Run Code Online (Sandbox Code Playgroud)

python cx-freeze

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

WPF FixedDocument分页

如何让FixedDocument自动分页?我有以下代码可用于将美化面板放入DocViewer.当Panel扩展到单个页面时会发生此问题.现在,我们只是剪辑.基本上,我想创建一种相当通用的方式来打印用户正在查看的内容.我的方法合理吗?

    public void CreateReport(Panel details)
    {
        FixedDocument fixedDoc = new FixedDocument();
        PageContent pageContent = new PageContent();
        FixedPage fixedPage = new FixedPage();

        fixedPage.DataContext = this.DataContext;
        fixedPage.Margin = new Thickness(10);

        fixedPage.Children.Add(details);
        ((System.Windows.Markup.IAddChild)pageContent).AddChild(fixedPage);
        fixedDoc.Pages.Add(pageContent);

        // This makes the array of controls invisibile, then climbs the details structure
        // and makes the controls within details appropriate for the DocumentViewwer (i.e. TextBoxes are
        // non-editable, no borders, no scroll bars, etc).
        prePrintPrepare(details, fixedPage, new FrameworkElement[] { controlToMakeInvisible });

        _dv = new DocViewer();
        _dv.documentViewer1.Document = fixedDoc; …
Run Code Online (Sandbox Code Playgroud)

wpf pagination fixeddocument

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

使用jquery设置输入html字符串的值

我在这样的字符串中有HTML片段:

var htmlString = '<input type="text" id="someID" name="someID">';
Run Code Online (Sandbox Code Playgroud)

我如何使用jQuery设置其值,以便HTML最终如下:

'<input type="text" id="someID" name="someID" value="newValue">';
Run Code Online (Sandbox Code Playgroud)

谢谢,斯科特

javascript jquery

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

Postgres SQL in子句和setArray()

我使用的是Java 1.7和JDBC 4以及Postgres.我试图使用带有数组的PreparedStatement来填充SQL in子句.但是,生成的SQL似乎有"{"和"}".这是代码:

PreparedStatement ptmt = 
      connection.prepareStatement("select * from foo where id in (?)");
String[] values = new String[3];
values[0] = "a";
values[1] = "b";
values[2] = "c";
ptmt.setArray(1, connection.createArrayOf("text", values));
Run Code Online (Sandbox Code Playgroud)

生成的SQL如下所示:

select * from foo where id in ('{"a","b","c"}')
Run Code Online (Sandbox Code Playgroud)

哪个,不行.它应该是这样的:

select * from foo where id in ("a","b","c")
Run Code Online (Sandbox Code Playgroud)

要么

select * from foo where id in ('a','b','c')
Run Code Online (Sandbox Code Playgroud)

我在这里错过了什么?

java postgresql jdbc

7
推荐指数
3
解决办法
5679
查看次数

列表的XML序列化

我正在将对象序列化为XML.我有这样的事情:

Class A
{
   public string propertyA1  { get; set; }
   public List<B> bList { get; set; }
}

Class B
{
   public string num {get; set;}
   public string propertyB1  { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

当我将它序列化为XML时,我希望它看起来像这样:

<A>
  <propertyA1>someVal</propertyA1> 
  <B num=1>
     <propertyB1>someVal</propertyB1> 
  </B>
  <B num=2>
     <propertyB1>someVal</propertyB1> 
  </B>
</A>
Run Code Online (Sandbox Code Playgroud)

但是,它看起来像这样:

<A>
  <propertyA1>someVal</propertyA1> 
  <bList>
     <B num=1>
        <propertyB1>someVal</propertyB1> 
     </B>
     <B num=2>
        <propertyB1>someVal</propertyB1> 
     </B>
  </bList>
</A>
Run Code Online (Sandbox Code Playgroud)

知道怎么摆脱输出中的bList吗?如果需要,我可以提供更多示例代码

谢谢,斯科特

.net c# xml xml-serialization

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