这有什么问题?如果$ forwardformat不为空,则运行"if语句"中的代码,但如果$ forwardformat为空,则"else"代码不会运行.有任何想法吗?!
while ($row = mysql_fetch_array($forwardresult)) {
$forward = $row["id"];
$forwardformat = str_replace(" ","",$forward);
if (!empty($forwardformat)) {
echo 'Exploring moves us <a href="casestudy.php?id=';
echo $forwardformat;
echo '">forward</a>';
}
else {
echo "forward";
}
}
Run Code Online (Sandbox Code Playgroud) 在Win32中没有用于本机C/C++的"高级"HTTP库,或者我只是在错误的地方寻找?
"高级"是指一种API,它允许我使用与.NET框架"大致相同"的抽象级别在C++中执行HTTP Web请求/响应(但请注意,使用C++/CLI不是我的选择).
如何在不使用.NET的情况下在Win32中的C/C++中执行此类操作(具有大约相同数量的代码)?作为参考,我提供了一个代码示例来说明我是如何在C#中完成的.
byte[] fileBytes = null;
bool successfulDownload = false;
using (WebClient client = new WebClient())
{
WebProxy proxy = WebProxy.GetDefaultProxy();
client.Proxy = proxy;
tryAgain:
try
{
fileBytes = client.DownloadData(fileUrl);
successfulDownload = true;
}
catch (WebException wEx)
{
if (wEx.Response != null && wEx.Response is HttpWebResponse)
{
string username = null, password = null;
bool userCanceled = false;
HttpStatusCode statusCode = ((HttpWebResponse)wEx.Response).StatusCode;
switch (statusCode)
{
case HttpStatusCode.ProxyAuthenticationRequired:
// This is just a convenience function defined elsewhere
GetAuthenticationCredentials(fileUrl, true, …Run Code Online (Sandbox Code Playgroud) 我们有一个Web应用程序,它使用Spring-Hibernate将注册用户数据保存在Oracle数据库中.该应用程序在开发环境中运行良好,但是当我们在具有更多数据的实时环境中复制它时,它失败了.最初应用程序正常启动,但在几次操作之后发生'PermGen out of space'异常.
我已经开始在Google,Spring和Hibernate论坛上搜索,但它没有帮助.关于这个错误有很多讨论,但是对于每个解决方案,都有人说:"它有效"而其他人说'它没有'.
例如,许多人提出增加-XX:MaxPermSizeJVM参数,其他人说它不起作用.有帖子说需要使用javassist库和其他库以及cglib库的问题.其他人说问题出在cglib上.
我们使用Java1.5_0_09,Spring 2.5和javaassist3.4.GA,Tomcat 5.5作为web容器,Oracle 10g作为数据库.
任何人都能解释一下导致这个问题的原因以及如何解决这个问题?
我正在查看一个greasemonkey用户脚本的来源,并在他们的css中注意到以下内容:
.even { background: #fff url(data:image/gif;base64,R0lGODlhBgASALMAAOfn5+rq6uvr6+zs7O7u7vHx8fPz8/b29vj4+P39/f///wAAAAAAAAAAAAAAAAAAACwAAAAABgASAAAIMAAVCBxIsKDBgwgTDkzAsKGAhxARSJx4oKJFAxgzFtjIkYDHjwNCigxAsiSAkygDAgA7) repeat-x bottom}
Run Code Online (Sandbox Code Playgroud)
我可以理解,一个greasemonkey脚本想要在源代码中捆绑任何东西而不是在服务器上托管它,这是显而易见的.但由于我以前没有看过这种技术,我考虑过它的使用,看起来很有吸引力有很多原因:
考虑到IE6(例如)有背景图像缓存问题,这似乎不是最糟糕的想法......
那么,这是一个好的或坏的做法,为什么你不使用它,你会使用什么工具base64编码图像?
更新 - 测试结果
用图像测试:http://fragged.org/dev/map-shot.jpg - 133.6Kb
专用的CSS文件: http://fragged.org/dev/base64.css - 178.1Kb
GZIP编码服务器端
结果发送给客户端的大小(YSLOW组件测试):59.3Kb
保存发送到客户端浏览器的数据:74.3Kb
不错,但我认为它对于较小的图像会稍微有用.
更新:谷歌的软件工程师Bryan McQuade正在研究PageSpeed,他在ChromeDevSummit 2013上表达了数据:CSS中的uris被认为是一种渲染阻止反模式,用于在他的演讲中提供关键/最小的CSS
#perfmatters: Instant mobile web apps.请参阅http://developer.chrome.com/devsummit/sessions并记住这一点 - 实际幻灯片
我有ubuntu + x11 + gnome.
我想以另一个用户身份运行图形应用程序.
但是,当我从命令行启动它时,sudo -u otheruser app我得到错误"No protocol specified".
我怎么能在这周围工作?
是否可以从C#XML注释中引用构造函数而无需使用显式前缀(如M:或T :)?
例如,以下产生编译警告,因为编译器不喜欢".ctor".尝试"PublishDynamicComponentAttribute.#ctor"并不好,
"PublishDynamicComponentAttribute.PublishDynamicComponentAttribute"也不好.
/// <summary>
/// Constructs a new <see cref="PublishEntityAttribute"/> instance.
/// </summary>
/// <seealso cref="PublishDynamicComponentAttribute..ctor(Type)"/>
public PublishEntityAttribute(Type entityFactoryType) :
base(entityFactoryType)
{
}
Run Code Online (Sandbox Code Playgroud)
我确信类型本身是可见的.
因此,我将使用显式前缀M:,这将删除编译器验证,因此当移动/重命名类型时,cref将无效.
有什么建议?
是什么区别NSTimer,NSTask,NSThread而且NSRunloop,是有关于何时使用它们中的每一个准则?
下面称为UserCanAccessThisPage的方法基于以下逻辑:每个用户和每个页面都有一个组列表.如果其中任何一个匹配,则用户可以访问该页面.
下面的代码做了我想要的,但我的解决方案是非常C#1(或C#2,至少我没有使用ArrayList).
任何人都可以重构这一点,这样更直接,例如使用lambdas来消除这两种方法吗?我只是无法获得语法来做到这一点.
using System;
using System.Collections.Generic;
using System.Linq;
namespace TestCompare2343
{
class Program
{
static void Main(string[] args)
{
string anonymousUserAccessGroups = "loggedOutUsers";
string normalUserAccessGroups = "loggedInUsers, members";
string developerUserAccessGroups = "loggedInUsers, members, administrators, developers";
string loginPageAccessGroups = "loggedOutUsers";
string logoutPageAccessGroups = "loggedInUsers";
string memberInfoPageAccessGroups = "members";
string devPageAccessGroups = "developers";
//test anonymousUser
Console.WriteLine(StringHelpers.UserCanAccessThisPage(anonymousUserAccessGroups, loginPageAccessGroups));
Console.WriteLine(StringHelpers.UserCanAccessThisPage(anonymousUserAccessGroups, logoutPageAccessGroups));
Console.WriteLine(StringHelpers.UserCanAccessThisPage(anonymousUserAccessGroups, memberInfoPageAccessGroups));
Console.WriteLine(StringHelpers.UserCanAccessThisPage(anonymousUserAccessGroups, devPageAccessGroups));
Console.WriteLine("---");
//test anonymousUser
Console.WriteLine(StringHelpers.UserCanAccessThisPage(normalUserAccessGroups, loginPageAccessGroups));
Console.WriteLine(StringHelpers.UserCanAccessThisPage(normalUserAccessGroups, logoutPageAccessGroups));
Console.WriteLine(StringHelpers.UserCanAccessThisPage(normalUserAccessGroups, memberInfoPageAccessGroups));
Console.WriteLine(StringHelpers.UserCanAccessThisPage(normalUserAccessGroups, devPageAccessGroups));
Console.WriteLine("---"); …Run Code Online (Sandbox Code Playgroud) 基本上,我想在foreach循环中删除列表中的项目.我知道在使用for循环时这是可能的,但出于其他目的,我想知道使用foreach循环是否可以实现这一点.
在python中,我们可以通过执行以下操作来实现此目的:
a = [1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in a:
print i
if i == 1:
a.pop(1)
Run Code Online (Sandbox Code Playgroud)
这给出了以下输出
>>>1
3
4
5
6
7
8
9
Run Code Online (Sandbox Code Playgroud)
但是当在c#中做类似的事情时,我得到一个InvalidOperationException,我想知道是否有办法解决这个问题,而不仅仅是使用for循环.
我抛出异常时使用的c#代码:
static void Main(string[] args)
{
List<string> MyList = new List<string>(new string[] { "1", "2", "3", "4", "5", "6", "7", "8", "9"});
foreach (string Item in MyList)
{
if (MyList.IndexOf(Item) == 0)
{
MyList.RemoveAt(1);
}
Console.WriteLine(Item);
}
}
Run Code Online (Sandbox Code Playgroud)
提前致谢