我是Rails的新手,我正在尝试部署我的第一个项目.我正在使用rails 3,ruby 1.8.7,Passanger,Mysql和Git
我按照很多教程来学习使用capistrano进行部署,并且有一个我无法弄清楚的问题.在教程中他们从不谈论schema.rb如果这个文件负责我已经完成的迁移以及我们部署应用程序时,capistrano将所有文件复制到"当前"文件夹(schema.rb to),它怎么能在生产服务器上进行正确的迁移.我应该告诉capistrano为"current"文件夹制作一个simlink到正确的schema.rb文件吗?如果是的话我该怎么做?TNKS.
嗨,我需要更改我的hsqldb的用户名密码.那么在哪里以及如何更改我的用户名密码?请帮我解决这个问题.
谢谢
我在python中有以下情况:我正在解析本体,我想跟踪本体的一些属性并构建具有以下特征的数据结构:
- 只需一个密钥即可访问每个值
- 该值将是另一个具有以下3个内容的键值数据结构:
'x':[]一个简单的列表
'y':[{'name':value,'type':value}]包含特定dictioanry键值的列表
'z':[{'name':value,'type':value}]包含特定字典键值的列表
根据上面的最终数据结构,我是:
ontology={'': [{'y': {'type': '','name':''}}],'x':[],'z':[ {'type': '', 'name': ''}]}
Run Code Online (Sandbox Code Playgroud)
最后我想要这个dinctionary的多个条目.我不想使用列表,因为索引将是一个整数,我想通过一个键索引我的数据.
我将在3个不同的for循环中填充此数据结构.
在第一个循环中,我将仅使用键名称填写本体词典.我认为如下:
ontology['a']={'a': [{'y': {'type': '','name':''}}],'x':[],'z':[ {'type': '', 'name': ''}]}
Run Code Online (Sandbox Code Playgroud)
但是这个东西是用'python'标准方式做的.有没有其他更方便的方法这样做,因为在我看来有些奇怪.
最后我会有这样的事情:
ontology['a']={'a':[{'y': {'type': '','name':''}}],'x':[],'z':[ {'type': '', 'name': ''}]}
ontology['b']={'b':[{'y': {'type': '','name':''}}],'x':[],'z':[ {'type': '', 'name': ''}]}
ontology['c']={'c':[{'y': {'type': '','name':''}}],'x':[],'z':[ {'type': '', 'name': ''}]}
ontology['d']={'d':[{'y': {'type': '','name':''}}],'x':[],'z':[ {'type': '', 'name': ''}]}
Run Code Online (Sandbox Code Playgroud)
在基于键的第二个循环中,我将填充x:[]值,这本身就是另一个字典
在第三个for循环中,我将填充y和z键.
这对于这个数据结构来说这是一个很好的方法吗?我还想过使用Classes来使我的代码更加"结构化",但我想我会使用更多的代码行
我有一个非常大的html表单(包含行的表,其中包含多个输入),我需要通过POST请求提交给PHP脚本.问题是PHP的$ _POST超全局中没有一些值没有出现.
我检查(使用Firebug扩展),这些值实际上是由浏览器发送到服务器的.
$ _POST被填充,但有些值只是缺失.
我检查了什么是原始请求使用:
$raw_post = file_get_contents('php://input');Run Code Online (Sandbox Code Playgroud)
并且返回的字符串具有值.它们只是没有解析成$ _POST数组.我注意到的奇怪的是,似乎php://输入值在一定长度后被切断,其余的字符串不会通过$ _POST.
我想到了post_max_size和memory_limit并将它们设置为大值:
memory_limit = 256M
post_max_size = 150M
但根据php文档,如果请求的大于post_max_size,$ _POST不应包含任何值.
由于形式和请求的大尺寸我不能在这里发布,但我可以发布用于调试问题的PHP脚本:
var_dump($file = file_get_contents('php://input'));
var_dump($_POST);
//... then i parsed the $file
Run Code Online (Sandbox Code Playgroud)
服务器版本:Apache/2.2.9(Debian)
PHP版本:PHP 5.3.2-0.dotdeb.2
可以enyone解释这种奇怪的PHP行为的原因,我应该怎么做(更改PHP设置,代码?)在处理表单时使用$ _POST数组?
编辑:要明确:不仅缺少价值观.$ _POST也不包含这些键.
原始帖子的片段:
t_dodparam%5B198%5D=&t_dodparam2%5B198%5D=&t_kolejnosc%5B198%5D=199&n_indeks=201&n_wartosc=testtesttestRun Code Online (Sandbox Code Playgroud)
密钥't_dodparam'在post中,它有密钥198.缺少其余的参数(ex t_dodparam2在post中,但它没有198这样的密钥,并且$ _POST中没有n_wartosc这样的密钥)
假设我有一个基本的Python脚本,test.py:
#!/usr/bin/python
print "Content-type: text/html\n\n"
print "<html>Hello world!</html>"
Run Code Online (Sandbox Code Playgroud)
如何确定脚本是否在本地执行,例如:
python test.py
Run Code Online (Sandbox Code Playgroud)
或通过网络浏览器调用,例如访问:
http://example.com/test.py
Run Code Online (Sandbox Code Playgroud)
这似乎没有在cgi模块的文档中解决.我认为结果可能有所不同,cgi.FieldStorage()但似乎没有.
我能想到的唯一方法是:
#!/usr/bin/python
import os
print "Content-type: text/html\n\n"
print "<html>Hello world!</html>"
if 'REQUEST_METHOD' in os.environ :
print "This is a webpage"
else :
print "This is not a webpage"
Run Code Online (Sandbox Code Playgroud)
这是最好和/或最理想的方法吗?为什么/为什么不呢?
我正在尝试X509Certificate2使用以下代码导出证书的公钥:
X509Store certificateStore = new X509Store(StoreName.My, StoreLocation.CurrentUser);
certificateStore.Open(OpenFlags.ReadOnly);
var exportCertificates = certificateStore.Certificates.Find(X509FindType.FindByThumbprint, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", false);
certificateStore.Close();
// Get Base64 string of the public key
byte[] arr = exportCertificates[0].PublicKey.EncodedKeyValue.RawData;
string b64ExportCertificate = Convert.ToBase64String(arr);
// Import the certificate
X509Certificate2 importCertificate = new X509Certificate2(Convert.FromBase64String(b64ExportCertificate));
Run Code Online (Sandbox Code Playgroud)
当我在最后一行执行时抛出以下异常:
System.Security.Cryptography.CryptographicException
Cannot find the requested object
Run Code Online (Sandbox Code Playgroud)
有谁知道如何解决这个问题?
注意:上面的代码示例是"功能"但它是伪代码.实际上,我将证书导出到一个应用程序中,然后传输到另一个应用程序以进行数字签名(因此只发送公钥)
我有这个代码:
window.onload = function() {
document.cookie = 'foo=bar; expires=Sun, 01 Jan 2012 00:00:00 +0100; path=/';
var xhr = new XMLHttpRequest();
xhr.open("GET", "/showcookie.php",true);
xhr.setRequestHeader("Cookie", "foo=quux");
xhr.setRequestHeader("Foo", "Bar");
xhr.setRequestHeader("Foo", "Baz");
xhr.withCredentials = true;
var pre = document.getElementById('output');
xhr.onreadystatechange = function() {
if (4 == xhr.readyState) {
pre.innerHTML += xhr.responseText + "\n";
}
};
xhr.send(null);
};
Run Code Online (Sandbox Code Playgroud)
这个/showcookie.php
<?php
print_r($_COOKIE);
?>
Run Code Online (Sandbox Code Playgroud)
它总是显示出来
Array
(
[Host] => localhost
[User-Agent] =>
[Accept] =>
[Accept-Language] => pl,en-us;q=0.7,en;q=0.3
[Accept-Encoding] => gzip,deflate
[Accept-Charset] => ISO-8859-2,utf-8;q=0.7,*;q=0.7
[Keep-Alive] => 115
[Connection] …Run Code Online (Sandbox Code Playgroud) 我发现以下HTML代码在Android上不起作用(它只使用默认字体:Droid Sans.在桌面上它正如预期的那样工作.
<p style='font-family: "Droid Sans",sans-serif;'>vând whisky ?i tequila, pre? fix.</p>
<p style='font-family: "Droid Sans Mono",monospace;'>vând whisky ?i tequila, pre? fix.</p>
<p style='font-family: "Droid Serif",serif;'>vând whisky ?i tequila, pre? fix.</p>
Run Code Online (Sandbox Code Playgroud) 我在覆盖一些插件CSS方面遇到了问题.直接编辑CSS实际上不是一个选项,因为它会使更新插件更具风险.
问题:元素具有绝对定位,并且在原始元素中具有顶部:0px.我想通过底部覆盖它:0px.
为了举个例子
.element {position:absolute; top:0;}
/* in another file */
.my .element {bottom:0;}
Run Code Online (Sandbox Code Playgroud)
在Firefox上这个工作正常(底部:0是应用的样式),但safari/chrome似乎没有超过顶部:0.
我可以解决这个问题,但提出一个干净的解决方案会很好.
我必须编写一个应用程序来观察另一个应用程序并从窗口中提取信息。从其他应用程序访问窗口并从其控件获取数据的最佳方式是什么?
python ×2
.net ×1
.net-3.5 ×1
android ×1
c# ×1
capistrano ×1
cgi ×1
cookies ×1
cryptography ×1
css ×1
css-position ×1
export ×1
font-face ×1
font-family ×1
fonts ×1
hsqldb ×1
javascript ×1
php ×1
post ×1
schema.rb ×1
webkit ×1
winapi ×1
windows ×1
winforms ×1