我正在尝试通过使用正则表达式验证日期输入.
if(!preg_match("/^[0-9]{4}\/[0-9]{2}\/[0-9]{2}$/", $_POST['variant']['sales_start'])) {
echo "invalid";
}
Run Code Online (Sandbox Code Playgroud)
我试图输入的字符串是2011-02-03,但它失败了,我似乎无法弄清楚原因.
有人可以告诉我我做错了什么吗?
提前致谢
我正在使用Navigator和jqGrid,我重复一遍又一遍的设置,例如:
savekey: [true, 13],
closeOnEscape: true,
closeAfterAdd: true
Run Code Online (Sandbox Code Playgroud)
如何在当前页面上为我的所有网格全局定义这些设置?
我知道如何在全局范围内进行jqGrid设置,但是我遇到Navigator问题.我的示例Navigator定义如下所示:
$("#dictionaryElementsGrid").navGrid(
"#dictionaryElementsPager",
{
search: false,
edit: true,
add: true,
del: true
},
{
// Edit options:
savekey: [true, 13],
closeOnEscape: true,
closeAfterEdit: true
},
{
// Create options:
savekey: [true, 13],
closeOnEscape: true,
closeAfterAdd: true
}
);
Run Code Online (Sandbox Code Playgroud) 我在不同的在线站点中看到不同数量的顶点来表示OpenGL ES中的同一个多维数据集.例如,这是一个:
float vertices[] = { -width, -height, -depth, // 0
width, -height, -depth, // 1
width, height, -depth, // 2
-width, height, -depth, // 3
-width, -height, depth, // 4
width, -height, depth, // 5
width, height, depth, // 6
-width, height, depth // 7
};
short indices[] = { 0, 2, 1,
0, 3, 2,
1,2,6,
6,5,1,
4,5,6,
6,7,4,
2,3,6,
6,3,7,
0,7,3,
0,4,7,
0,1,5,
0,5,4
};
Run Code Online (Sandbox Code Playgroud)
这是另一个:
float vertices[] = {
//Vertices according to faces
-1.0f, -1.0f, 1.0f, …Run Code Online (Sandbox Code Playgroud) 我有两个盐,每个用户都有一个独特的盐,与数据库中的用户信息一起存储.第二种盐是网站特有的盐.两者都需要哈希密码.
问题是我不知道我应该在哪里保持我的网站盐.现在它驻留在运行散列算法的PHP方法中.我应该将它保存在/ var/www /之外的文件中并打开PHP并读取文件吗?我不想将它存储在数据库中,因为如果我的数据库受到损害,那将会破坏两种盐的目的.
有什么建议?
我正在使用XSLT处理我的ASP.Net web.config文件以插入一些额外的log4net配置.它由NANT标准任务应用<style>.在成功插入新内容的同时,它会将许多自动关闭标记转换为空配对标记.例如,部分web.config在此之前如下所示:
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<configSections>
<section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<appSettings>
<add key="SomeKey" value="SomeValue"/>
</appSettings>
Run Code Online (Sandbox Code Playgroud)
应用样式表后,<section>和<add>标签(以及所有其他标签)不再自动关闭:
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<configSections>
<section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net">
</section>
</configSections>
<appSettings>
<add key="SomeKey" value="SomeValue">
</add>
</appSettings>
Run Code Online (Sandbox Code Playgroud)
我的样式表看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<!-- This stylesheet is applied to web.config files to insert log4net appender
filters that will prevent logging messages resulting from pages requested by
AIS monitoring systems. -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
exclude-result-prefixes="msxsl">
<xsl:output method="xml" indent="yes" />
<xsl:preserve-space …Run Code Online (Sandbox Code Playgroud) 我正在编写一个目前有以下脚本的脚本:
my @files = `$some_command`;
print @files;
chomp @files;
foreach my $file (@files)
{
process($file);
}
Run Code Online (Sandbox Code Playgroud)
它工作正常,但该some_command部分占用了脚本的大部分时间.在此期间,stdout上没有任何内容,因为Perl已重定向输出some_command以填充@files数组.它只在some_command完成后打印并且Perl移动到print @files;.
是否有一些聪明的方法来更改此代码,以便输出在some_command执行时出现?我可以尝试使用以下方法tee(1):
my $tmpfile = File::Temp->new();
system("$some_command | tee " . $tmpfile->filename);
my @files;
{ local $/ = undef; @files = split /\s/, <$tmpfile>; }
Run Code Online (Sandbox Code Playgroud)
但是如果有一个更简单的解决方案,我宁愿避免使用临时文件.
这是TextView的扩展.getTextSize()并setTextSize()没有被覆盖,我没有扩展这些方法.编程1.6,API级别4.
此代码中的循环导致每次迭代时大小乘以1.5,例如,如果大小最初从200读取getTextSize,则setTextSize(size)调用,getTextSize再次调用则读回300.
public void shrinkTest() {
float size = this.getTextSize();
while (size > 8) {
this.setTextSize(size);
size = this.getTextSize();
}
}
Run Code Online (Sandbox Code Playgroud)
为什么是这样?
尝试使用java.util.Scanner中的nextLine()方法时遇到了麻烦.
这是我尝试过的:
import java.util.Scanner;
class TestRevised {
public void menu() {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a sentence:\t");
String sentence = scanner.nextLine();
System.out.print("Enter an index:\t");
int index = scanner.nextInt();
System.out.println("\nYour sentence:\t" + sentence);
System.out.println("Your index:\t" + index);
}
}
Run Code Online (Sandbox Code Playgroud)
示例#1:此示例按预期工作.String sentence = scanner.nextLine();在继续之前,该行等待输入输入System.out.print("Enter an index:\t");.
这会产生输出:
Enter a sentence: Hello.
Enter an index: 0
Your sentence: Hello.
Your index: 0
Run Code Online (Sandbox Code Playgroud)
// Example #2
import java.util.Scanner;
class Test {
public void menu() {
Scanner scanner …Run Code Online (Sandbox Code Playgroud) 我有一张表格
Category Time Qty
A 1 20
B 2 3
A 3 43
A 4 20
B 5 25
Run Code Online (Sandbox Code Playgroud)
我需要在MySQL中按类别计算运行总计.结果看起来像这样:
Category Time Qty Cat.Total
A 1 20 20
B 2 3 3
A 3 43 63
A 4 20 83
B 5 25 28
Run Code Online (Sandbox Code Playgroud)
知道如何在MySQL中有效地做到这一点吗?我搜索的范围很广,但我能找到的是有关如何在MySQL中插入一个单独运行总计的信息.我想知道是否有任何方法可以使用GROUP BY或类似的构造来实现这一目标.
在我的本地仓库中,我有一个提交错误的提交消息.
我已经发布了错误的提交消息git push.
现在远程仓库(GitHub托管)也有不正确的提交消息.
我已经尝试了git commit --amend,但发现在这种情况下它对我不起作用,因为我已经做了额外的提交,因为不正确的提交.
你会如何解决这种情况?