Facebook的状态更新输入(嗯,contenteditable div)检测链接.
键入链接时,它会等到按下空格键后才能获取URL.
粘贴链接时,它会立即获取URL.
我可以在按下空格键后解析URL ...但我不确定何时检测内容被粘贴.
任何解决方案都会很棒; 一个jQuery格式的解决方案将是最好的!
我们都知道Linq to SQL(和SQLmetal/exe)实际上是一个"原型"质量的产品(它缺少模式"刷新"和使用默认值检测空列的基本功能).
有没有办法自动创建我的.dbml(类似于LINQ to SQL或SQLmetal)并让它检测NOT NULL
具有默认值的列?
要求:它需要像linq-to-sql或sqlmetal一样"简单"生成.
澄清我需要它:
我有很多表DateCreated
和DateModified
字段以及一些默认值的bit
enum-like(int
)列; 所有这些应该是和not null
.
我需要在更改数据库后重新生成("刷新").dbml ...所以(重新)将自动生成(或自动同步)属性设置True
为不是我真正关心的几乎每个我更新架构的时间.
以下代码(基于使用LINQ to SQL处理缺省值):
namespace Project.Data
{
public partial class ProjectDataContext
{
partial void OnCreated()
{
if (this.DateCreated == null)
{
this.DateCreated = DateTime.UtcNow;
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
不编译(错误... does not contain a definition for 'DateCreated' ...
).我真的认为它没有理由应该编译......但我还是试了一下.也许我只是不理解他的例子中的代码的上下文.
该假想情景:
联盟会员通过向客户销售商品/服务/小部件来在我的网站上赚钱.您可以将其视为一个简单的联盟计划.这笔钱存储在一个帐户中,直到会员请求他们的钱.
关联公司不想等待支票来邮件; 他们想登录他们的管理部门(在我的网站上),然后点击神奇的"转移我的硬挣钱现在!傻瓜"按钮,并将他们的数百万美元直接存入他们的银行账户(此转账可能需要"3-4天"如果必须---联盟会员只是想让他们觉得他们总能控制自己的钱".
现在,PayPal已经做了"现在发送我的挣钱!傻瓜." 功能很好.他们的API甚至允许从一个Paypal账户转账到另一个账户; 它只是不允许存款到银行账户.联盟会员很懒,不想登录他们的Paypal账户来转账.
那么,开发人员可以做些什么呢?
.
// affiliate and crdentials are pulled from my database.
Affiliate affiliate = db.Affiliates.GetByID(123456);
Credentials creds = affiliate.GetBankCredentials();
// paymentAPI is, well, its an API.
Xml response = paymentAPI.InitiateMoneyTransfer({from: myAccountCrdentials, to: creds, amount: 123, currency: "USD"});
if(response.success){
print "Bling Bling! Transfer initiated";
}
else{
print response.msg;
}
Run Code Online (Sandbox Code Playgroud)
ps我在美国
c# language-agnostic currency payment-gateway payment-processing
基本上我有这样一个表:
CREATE TABLE Person(
PersonID int IDENTITY(1,1) NOT NULL,
FirstName nvarchar(512) NOT NULL,
LastName nvarchar(512) NULL
)
Run Code Online (Sandbox Code Playgroud)
我需要根据用户查询找到前n个结果,如下所示:
"Joh Smi"
Run Code Online (Sandbox Code Playgroud)
以下查询返回我需要的结果(我认为).只是不在相关的顺序.
SELECT
PersonID, FirstName, LastName
FROM
Person
WHERE
FirstName LIKE 'Joh%' OR
LastName LIKE 'Joh%' OR
FirstName LIKE 'Smi%' OR
LastName LIKE 'Smi%'
Run Code Online (Sandbox Code Playgroud)
如果以下名称在数据库中并且我们的用户查询是"Joh Smi",则名称应按以下顺序出现(或类似)
我希望它能像facebook的自动完成朋友搜索一样工作.
那么,如何在SQL Server 2008中返回前n个最相关的行?
我正在为asp.net应用程序创建自定义成员资格提供程序.我还创建了一个单独的类"DBConnect",它提供数据库功能,如执行SQL语句,执行SP,执行SP或查询以及返回SqlDataReader等等......
我在Global.asax的Session_Start中创建了DBConnect类的实例并存储到会话中.后来使用静态类我在整个应用程序中使用相同的单个会话提供数据库功能.简而言之,我从任何asp.net页面为所有数据库操作提供单点.
我知道我可以编写自己的代码来连接/断开数据库并从我需要覆盖的方法中执行SP.请看下面的代码 -
public class SGI_MembershipProvider : MembershipProvider
{
Run Code Online (Sandbox Code Playgroud)
......
public override bool ChangePassword(string username, string oldPassword, string newPassword)
{
if (!ValidateUser(username, oldPassword))
return false;
ValidatePasswordEventArgs args = new ValidatePasswordEventArgs(username, newPassword, true);
OnValidatingPassword(args);
if (args.Cancel)
{
if (args.FailureInformation != null)
{
throw args.FailureInformation;
}
else
{
throw new Exception("Change password canceled due to new password validation failure.");
}
}
.....
//Database connectivity and code execution to change password.
}
....
}
Run Code Online (Sandbox Code Playgroud)
我的问题 - 现在我需要的是从顶部描述的相同数据库点执行所有这些重写方法中的数据库部分.这是我必须将会话中存在的DBConnect实例传递给此类,以便我可以访问这些方法.
任何人都可以提供解决方案.可能有一些我不了解的更好的技术.我使用的方法可能是错的.您的建议随时欢迎.
感谢您分享宝贵的时间.
当 SO 允许时,我将增加 500 名我自己的代表作为赏金。
我正在使用wkhtmltopdf将 HTML 网页转换为 PDF。这在我的 32 位开发服务器上完美运行 [不幸的是,我无法运送我的机器 :-p ]。但是,当我部署到 Web 应用程序的 64 位服务器时,会显示以下错误:(从 cmd.exe 运行)
C:\>wkhtmltopdf http://www.google.com google.pdf
Loading pages (1/5)
QFontEngine::loadEngine: GetTextMetrics failed () ] 10%
QFontEngineWin: GetTextMetrics failed ()
QFontEngineWin: GetTextMetrics failed ()
QFontEngine::loadEngine: GetTextMetrics failed ()
QFontEngineWin: GetTextMetrics failed ()
QFontEngineWin: GetTextMetrics failed ()
QFontEngineWin: GetTextMetrics failed ()
QFontEngine::loadEngine: GetTextMetrics failed () ] 36%
QFontEngineWin: GetTextMetrics failed ()
QFontEngineWin: GetTextMetrics failed ()
// ...etc....
Run Code Online (Sandbox Code Playgroud)
并且 PDF 被创建并保存......只是没有文本。所有表单域、图像、边框、表格、div、跨度、ps 等都被准确呈现……完全没有任何文本。
服务器信息:
Windows …
Run Code Online (Sandbox Code Playgroud) UPDATE
这就是我想出的.我还没有测试它,因为它是仍然需要移植的更大代码段的一部分.
你能看到任何看起来不合适的东西吗?
private const string tempUserBlock = "%%%COMPRESS~USER{0}~{1}%%%";
string html = "some html";
int p = 0;
var userBlock = new ArrayList();
MatchCollection matcher = preservePatterns[p].Matches(html);
int index = 0;
StringBuilder sb = new StringBuilder();
int lastValue = 0;
foreach(Match match in matcher){
string matchValue = match.Groups[0].Value;
if(matchValue.Trim().Length > 0) {
userBlock.Add(matchValue);
int curIndex = lastValue + match.Index;
sb.Append(html.Substring(lastValue, curIndex));
sb.AppendFormat(tempUserBlock, p, index++);
lastValue = curIndex + match.Length;
}
}
sb.Append(html.Substring(lastValue));
html = sb.ToString();
Run Code Online (Sandbox Code Playgroud)
以下原始帖子:
这是原始的Java:
private static final …
Run Code Online (Sandbox Code Playgroud) 所以我有一个ConfigurationSection/ConfigurationElementCollection,其配置如下:
<mimeFormats>
<add mimeFormat="text/html" />
</mimeFormats>
Run Code Online (Sandbox Code Playgroud)
以下是我处理mimeFormats的方法:
public class MimeFormatElement: ConfigurationElement
{
#region Constructors
/// <summary>
/// Predefines the valid properties and prepares
/// the property collection.
/// </summary>
static MimeFormatElement()
{
// Predefine properties here
_mimeFormat = new ConfigurationProperty(
"mimeFormat",
typeof(MimeFormat),
"*/*",
ConfigurationPropertyOptions.IsRequired
);
}
private static ConfigurationProperty _mimeFormat;
private static ConfigurationPropertyCollection _properties;
[ConfigurationProperty("mimeFormat", IsRequired = true)]
public MimeFormat MimeFormat
{
get { return (MimeFormat)base[_mimeFormat]; }
}
}
public class MimeFormat
{
public string Format
{
get
{
return …
Run Code Online (Sandbox Code Playgroud) c# system.configuration configurationsection .net-4.0 type-conversion
以下代码无法正确克隆输入元素。单击/聚焦在克隆的输入上会在原始输入上打开日期选择器。
http://jsfiddle.net/musicisair/YUkZw/
<input>
<script>
var input = $("input").datepicker();
$("body").append("<br>Input 2: ").append(
input.clone(true);
);
</script>
Run Code Online (Sandbox Code Playgroud)
有没有正确的方法来克隆已与jQuery UI小部件绑定的元素?如果是这样,那是什么?
我的表面着色器的主要纹理是Google Maps图像图块,类似于:
.
我想用一个单独的纹理替换接近指定颜色的像素.现在正在做的是以下内容:
Shader "MyShader"
{
Properties
{
_MainTex("Base (RGB) Trans (A)", 2D) = "white" {}
_GrassTexture("Grass Texture", 2D) = "white" {}
_RoadTexture("Road Texture", 2D) = "white" {}
_WaterTexture("Water Texture", 2D) = "white" {}
}
SubShader
{
Tags{ "Queue" = "Transparent-1" "IgnoreProjector" = "True" "ForceNoShadowCasting" = "True" "RenderType" = "Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert alpha approxview halfasview noforwardadd nometa
uniform sampler2D _MainTex;
uniform sampler2D _GrassTexture;
uniform sampler2D _RoadTexture;
uniform sampler2D _WaterTexture;
struct Input
{
float2 …
Run Code Online (Sandbox Code Playgroud) c# ×5
jquery ×2
sql-server ×2
.net ×1
.net-4.0 ×1
32-bit ×1
32bit-64bit ×1
64-bit ×1
android ×1
clone ×1
currency ×1
datepicker ×1
facebook ×1
ios ×1
java ×1
javascript ×1
jquery-ui ×1
linq ×1
linq-to-sql ×1
opengl-es ×1
regex ×1
shader ×1
sql ×1
t-sql ×1
windows ×1
wkhtmltopdf ×1