对于登录成功,有一个参数use_referer: true
.对于登录失败只有failure_path
,这不是我正在寻找的.
第二件事:如何做到并传递错误信息?
第三件事:退出后如何返回推荐人?
我正在练习算法,我的任务之一是计算给定0 <n <= 10 ^ 6个数字的所有最长增长子序列的数量.解决方案O(n ^ 2)不是一个选项.
我已经实现了查找LIS及其长度(LIS算法),但是该算法将数字切换到尽可能低的数字.因此,我不可能确定具有先前数字(较大的数字)的子序列是否能够实现最长的长度,否则我可以计算这些开关.
任何关于如何在O(nlogn)中得到这个的想法?我知道它应该使用动态编程来解决.
我实现了一个解决方案,它运行良好,但它需要两个嵌套循环(i in 1..n)x(j in 1..i-1).
所以它是O(n ^ 2)我认为,但它太慢了.
我试图甚至那些从数字阵列移动到一个二叉树(因为在每次我迭代i寻找所有更小的数字,然后数[I] -经历元件I-1..1),但它是更慢.
示例测试:
1 3 2 2 4
result: 3 (1,3,4 | 1,2,4 | 1,2,4)
3 2 1
result: 3 (1 | 2 | 3)
16 5 8 6 1 10 5 2 15 3 2 4 1
result: 3 (5,8,10,15 | 5,6,10,15 …
Run Code Online (Sandbox Code Playgroud) 我从Crashlytics收到有关我的Xamarin.Forms项目中的以下崩溃的通知:
Fatal Exception: java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.xxx.xxx/xxxxx.MainActivity}:
java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to
android.widget.CompoundButton$SavedState
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2957)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032)
at android.app.ActivityThread.-wrap11(Unknown Source)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6944)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Caused by java.lang.ClassCastException:
android.view.AbsSavedState$1 cannot be cast to android.widget.CompoundButton$SavedState
at android.widget.CompoundButton.onRestoreInstanceState(CompoundButton.java:619)
at android.view.View.dispatchRestoreInstanceState(View.java:18884)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3936)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3936)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3936)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3936)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3936)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3936)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3936)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3936)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3936)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3936)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3936)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3936)
at android.view.View.restoreHierarchyState(View.java:18862)
at com.android.internal.policy.PhoneWindow.restoreHierarchyState(PhoneWindow.java:2248)
at android.app.Activity.onRestoreInstanceState(Activity.java:1153) …
Run Code Online (Sandbox Code Playgroud) 使用doctrine,symfony2更新数据库中的多个记录的最佳方法是什么?
我收到了一些记录ID,我必须更新.
我想为每个记录分配从接收到的数组到列show_order的索引.所以,如果我收到数组$ array = array(22,1,5,10),那么我想做
$i = 0;
foreach($array as $a) {
$record = $this->getDoctrine->getRepository('AcmeBundle:SomeEntity')->findOneById($a);
if ($record != null) $record->setOrder($i++);
}
$this->getDoctrine()->getEntityManager()->flush();
Run Code Online (Sandbox Code Playgroud)
但这是可怕的方式,因为对于每个记录我做一个SELECT,所以查询数量是O(n).
怎么做得更好?
我在表中有两个外键.我们假设该表被调用News
并具有外键,updatedById
并且createdById
两者都指向userId
表中Users
.
现在我想在NULL
删除用户时设置外键,但是当我尝试设置ON DELETE SET NULL
该关系时,我得到:
在表'新闻'上引入FOREIGN KEY约束'FK_News_Users'可能会导致循环或多个级联路径.指定ON DELETE NO ACTION或ON UPDATE NO ACTION,或修改其他FOREIGN KEY约束.
我不明白为什么两个外键都不能设置为null?
我想要具有相同名称的分支特定文件.我需要能够从我的开发分支合并到master,而不需要在此文件中进行更改.
例如:
假设我想要两个不同的readme.md
文件.在一个我希望有内容:MASTER
在另一个DEV
.但是如果我尝试这样做,在创建pull-request时GitHub会尝试合并这个文件,这正是我的问题.每次进行更改时,我都不希望GitHub合并此文件.
解决这个问题的最佳方法是什么?
我想知道DispatchQueue.asyncAfter(deadline:execute:)
在进入后台时的行为方式。我试图在文档中找到更多信息,但什么也没有。
让我们假设我调用的情况:
DispatchQueue.main.asyncAfter(deadline: .now() + 60.0) { ... }
对我来说最有趣的部分是知道计时器何时倒计时 60 秒停止和恢复。
寻找DispatchQueue.asyncAfter(deadline:execute:)
与DispatchQueue.asyncAfter(wallDeadline:execute:)
我之间的差异,我从 Apple Staff(来源)那里找到了这个信息,它实际上回答了这个问题:
顺便说一句,你知道为什么 Swift Dispatch 库中提供了这两种 distict 类型吗?
这些模型模拟了墙时间(由 gettimeofday 返回)和马赫绝对时间(由 mach_absolute_time 返回)之间的差异。后者与系统时钟变化无关,但会在您睡觉时停止。在 C API 中,一切都被扁平化到马赫绝对时间,这意味着您会丢失关键信息。考虑一下如果您在将来安排一个计时器 1 秒,然后系统休眠 2 秒会发生什么。
明确DispatchQueue.asyncAfter(deadline:execute:)
使用绝对时间并根据此DispatchQueue.asyncAfter(wallDeadline:execute:)
使用gettimeofday
(墙壁时间)。
这是另一个来源:dispatch_time 和 dispatch_walltime 之间有什么区别,在什么情况下最好使用一个或另一个?
基于此,我准备了一个测试来确认:
override func viewDidLoad() {
super.viewDidLoad()
self.textView.text.append(
"expected times: \n1. \(Date().addingTimeInterval(60.0 …
Run Code Online (Sandbox Code Playgroud) 我正在玩lldb
,我正在尝试调用我的快速静态函数。我能够在图像中找到它的详细信息,但是我不知道如何调用它并传递参数。
我的输出:
(lldb) image lookup -vs $S5project19ViewControllerUtilsC07setRootbC010storyboard13withAnimationySo12UIStoryboardC_SbtFZ
1 symbols match '$S5project19ViewControllerUtilsC07setRootbC010storyboard13withAnimationySo12UIStoryboardC_SbtFZ' in /Users/user/Library/Developer/CoreSimulator/Devices/DC7A5199-424E-4E38-A8A8-CB99C7D8CF82/data/Containers/Bundle/Application/BE7BB249-DB64-4228-B64E-EB430BCCE29E/project.app/project:
Address: project[0x00000002000fc970] (project.__TEXT.__text + 1027840)
Summary: project`static project.ViewControllerUtils.setRootViewController(storyboard: __C.UIStoryboard, withAnimation: Swift.Bool) -> () at ViewControllerUtils.swift:7
Module: file = "/Users/user/Library/Developer/CoreSimulator/Devices/DC7A5199-424E-4E38-A8A8-CB99C7D8CF82/data/Containers/Bundle/Application/BE7BB249-DB64-4228-B64E-EB430BCCE29E/project.app/project", arch = "x86_64"
CompileUnit: id = {0x00000000}, file = "/Users/user/mobile/company/iOS/project/project/Utils/ViewControllerUtils.swift", language = "swift"
Function: id = {0x7700000075}, name = "static project.ViewControllerUtils.setRootViewController(storyboard: __C.UIStoryboard, withAnimation: Swift.Bool) -> ()", mangled = "$S5project19ViewControllerUtilsC07setRootbC010storyboard13withAnimationySo12UIStoryboardC_SbtFZ", range = [0x000000010bd0c780-0x000000010bd0c82e)
FuncType: id = {0x7700000075}, byte-size = 8, decl = ViewControllerUtils.swift:7, compiler_type = "(UIKit.UIStoryboard, Swift.Bool) …
Run Code Online (Sandbox Code Playgroud) 我在我的控制器中生成动态图形:
如果不存在文件(唯一文件名),则生成图形并保存
return RedirectResponse($ url)
(3.我也尝试过:
$fp = fopen($url, "rb");
$str = stream_get_contents($fp);
fclose($fp);
$response = new Response($str, 200);
$response->headers->set('Content-Type', 'image/png');
return $response;
Run Code Online (Sandbox Code Playgroud)
)
我需要它为用户动态生成用户栏[在此图形上,如果在我的网站上进行一些更改,一些文本将自动更新].
所以对我来说这个脚本运行速度很快并且不会杀死我的服务器/ bandwitch对我很重要.为了实现这一点,我已经制作了缓存,其中存储了所有生成的图形.但是我的速度有问题,我上面描述的解决方案非常慢,当我使用开发人员工具(F12)在chrome中测试它然后它告诉我两个解决方案(2.和3.)需要大约〜1s(当相同的图形[没有控制器等只是直接url到.png]加载44毫秒).
因此,如果仅对我而言,每个图形大约需要1个,那么如果例如1000个用户将同时生成此图形,那么我认为它可能会减慢我的网站速度.
请帮忙,你知道更快的方法吗?
PS.重定向不是我最想要的东西,因为我更喜欢保留url,例如smth/username/userbar/insted of smth/img/userbars/cache/blabla.png.但如果它会快得多,那么我可以忍受它:).
编辑:要明确:我不是在寻找缓存图像的解决方案,我的问题是通过控制器返回图像(已生成的图像,仅来自ftp)需要大约1秒,通常情况下,如果您这样做
<img src="direct_url_to_png">
Run Code Online (Sandbox Code Playgroud)
它需要大约44毫秒.
我想知道使用VS C#2010 Express Edition创建数据库应用程序的最佳方法是什么,我有两个问题:
我应该选择哪些Microsoft SQL Server 2008或SQL Server Compact 3.5?在用户的桌面上安装2008似乎更复杂.如果我是对的,使用Compact只需安装此服务器,之后该应用程序就可以使用数据库文件了.
我应该在我的包中包含什么,.dll文件就足够了,还是我需要整个例如Sql Server Compact安装程序?
optimization ×2
sql-server ×2
swift ×2
symfony ×2
algorithm ×1
android ×1
c# ×1
cascade ×1
constraints ×1
database ×1
debugging ×1
doctrine ×1
foreign-keys ×1
git ×1
git-branch ×1
github ×1
image ×1
ios ×1
lis ×1
lldb ×1
login ×1
numbers ×1
objective-c ×1
php ×1
redirect ×1
referer ×1
response ×1
subsequence ×1
symfony1 ×1
t-sql ×1
xamarin ×1