<?php
(E_ALL & ~E_NOTICE);
session_start();
// is the one accessing this page logged in or not?
if (!isset($_SESSION['db_is_logged_in']) || $_SESSION['db_is_logged_in'] !== true) {
// not logged in, move to login page
header('Location: login.php');
exit;
}
else {
echo "Welcome To The Test Page:";
echo $_SESSION['logname'];
}
if (isset($_POST['submit'])) {
test();
}
function test()
{
$var = rand(1, 5);
header("Location:{$var}.html");
exit;
}
<html>
<body>
<form action="<?=$_SERVER['PHP_SELF'];?>" method="post">
<input type="submit" name="submit" value="Take Test">
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
当点击"take test"按钮时,我需要5个html页面中的1个,即(在这种情况下为问题文件)显示给用户.因为我已经创建了从1到5的随机数.这些页面的名称是1.html,2.html等等......
谁能调试这段代码?
我想在列表上有一个反向列表视图(以类似的方式List#sublist提供列表上的子列表视图).是否有一些提供此功能的功能?
我不想制作任何类型的列表副本,也不想修改列表.
如果我在这种情况下至少可以在列表上获得反向迭代器就足够了.
另外,我知道如何自己实现这一点.我只是问Java是否已经提供了这样的东西.
演示实施:
static <T> Iterable<T> iterableReverseList(final List<T> l) {
return new Iterable<T>() {
public Iterator<T> iterator() {
return new Iterator<T>() {
ListIterator<T> listIter = l.listIterator(l.size());
public boolean hasNext() { return listIter.hasPrevious(); }
public T next() { return listIter.previous(); }
public void remove() { listIter.remove(); }
};
}
};
}
Run Code Online (Sandbox Code Playgroud)
我刚刚发现某些List实现具有descendingIterator()我需要的功能.虽然没有一般的这样的实现List.这有点奇怪,因为我看到的实现已经LinkedList足够通用了List.
我有一个变量值,说它是dim a as integer = 145.98
我试图采取Left(a,2)
但它返回错误而不是返回14我也尝试left(a.Tostring,2)
但错误是相同的.请帮我解决一下.
谢谢Furqan
所以我有大约16,000个75维数据点,并且对于每个点我想找到它的k个最近邻居(使用欧氏距离,如果这使得它更容易,则当前k = 2)
我的第一个想法是为此使用kd树,但事实证明,随着维数的增长,它们变得相当低效.在我的示例实现中,它仅比详尽的搜索稍快.
我的下一个想法是使用PCA(主成分分析)来减少维数,但我想知道:是否有一些聪明的算法或数据结构可以在合理的时间内完全解决这个问题?
algorithm nearest-neighbor computational-geometry data-structures dimensionality-reduction
我正在制作一个小型库(DLL)来管理用户及其角色/权限.该计划是能够将此dll添加到MVC项目并能够操纵用户/角色/等.所有数据都驻留在SQL数据库中.
我正在使用实体框架进行数据访问.
所以当我初始化一个新的RoleManager(这是我正在制作的lib中的主类的名称)时,我提供了一个connectionString,如下所示:
RoleManager roleManager = new RoleManager(string connectionString);
Run Code Online (Sandbox Code Playgroud)
然后在构造函数中我这样做:
db = new RoleManagerEntities(connectionString); //This is the EntityFramework
Run Code Online (Sandbox Code Playgroud)
我正在尝试提供此连接字符串(以及许多其他字符串)
"metadata=res://*/RoleManager.csdl|res://*/RoleManager.ssdl|res://*/RoleManager.msl;provider=System.Data.SqlClient;provider connection string='Data Source=localhost;Initial Catalog=Login;Integrated Security=True;Connection Timeout=60; multipleactiveresultsets=true'"
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.
Run Code Online (Sandbox Code Playgroud)
这个问题是尝试从我的新项目中实例化EF而不提供连接字符串并且我的应用程序配置中没有任何内容,因为它默认为.太糟糕了我现在无法删除它.
我听说新的Windows Phone 7上的应用程序开发只是C#.真的吗?我无法自己验证.你能提供一个链接吗?
如果是真的,是否有关于允许VB.Net创建应用程序的传言?
我在控制器中有一个功能,它接受一些规范并生成一个报告.在视图中调用此函数user_report:
<%= submit_to_remote'submit-button',"将报告导出到Excel",:url => {:controller =>:reports,:action =>:user_report,:print_state =>'print'}%>
在reports_controller中,我使用Spreadsheet插件在user_report函数中生成Excel文件.我想使用send_data将文件流式传输给用户,而不是先在服务器上创建它.我所做的研究表明,使用StringIO是可行的方法,如下所示.令人沮丧的是,当我调用send_data时没有任何反应.该插件似乎可以很好地创建一个文件并将其保存在服务器上,但在使用send_file时什么也不做,这表明问题不在于插件.但是我对send_file/send_data做错了什么?
该函数本身如下所示:
def user_report
if request.post?
unless params[:reports][:userid].blank?
@userid=params[:reports][:userid]
end
if params[:print_state]=='print'
report = Spreadsheet::Workbook.new
info = report.create_worksheet :name => 'User Information'
info.row(1).push 'User ID', @userid
@outfile = "Report_for_#{@userid}.xls"
require 'stringio'
data = StringIO.new ''
report.write data
send_data data.string, :type=>"application/excel", :disposition=>'attachment', :filename => @outfile
end
respond_to do |format|
format.js { }
end
end
Run Code Online (Sandbox Code Playgroud)
结束
日志文件读取2010-10-18 14:13:59 INFO - 发送数据Report_for_jjohnson.xls但没有在浏览器中开始下载.我之前在这个应用程序上成功使用了send_data,这令人困惑.
我在spreadsheet.rubyforge.org上使用Rails v2.3,Ruby v1.8.7和Spreadsheet v6.4.1.
我使用以下代码初始化加密...
Dim symmetricKey As New System.Security.Cryptography.RijndaelManaged()
With symmetricKey
.Key = Encoding.ASCII.GetBytes(Key)
.IV = Encoding.ASCII.GetBytes(IV)
.Mode = CipherMode.CBC
.BlockSize = 128
.KeySize = 128
.Padding = PaddingMode.PKCS7
End With
Run Code Online (Sandbox Code Playgroud)
要求是使用PKCS5.vb.net中的填充模式仅包括
所以我认为没有PKCS5的方法.有没有办法添加它,还是我需要自己编写加密方法?如果是这样 - 我该怎么写呢?是否有可靠的DLL支持它?
在Perl 5和Perl 6之间差异的总结中,注意到该wantarray功能已经消失:
wantarray()走了
wantarray走了.在Perl 6中,上下文向外流动,这意味着例程不知道它在哪个上下文中.
相反,你应该返回在每个上下文中做正确事情的对象.
有人可以举例说明如何创建这样的对象吗?