假设我有一个查找城市,州位置的表单.如果用户输入了错误的城市,状态,我希望表单能够根据用户输入检查数据库,并查看输入是否有效.如果不是,我希望用户提示.
因此,表单Validate是我的插件.
$("#form").validate({
rules: {
citystate: {
required: true,
myCustomAjaxSyncronousCheckAgainstDBRule: true
}
submitHandler: function(form) {
if ($("#form").valid()) {
form.submit();
}
}
});
Run Code Online (Sandbox Code Playgroud)
现在说这个表单必须在我的网站的4个不同的地方使用,所以很难重构myCustomAjaxSyncronousCheckAgainsDBRule(伪名称btw)并在我的网站上有4次相同的代码.这就是我在JS文件中创建自定义规则的原因.但有没有办法只能在提交时检查规则.因为如果用户输入无效,它将在每次击键时检查它,这可能非常麻烦.特别是因为我有jQuery.ui.autocomplete运行unjuction.
我有一个私人仓库,我想在我的package.json文件中安装.
"private-module": "git+ssh://git@bitbucket.org:private/private-module.git"
Run Code Online (Sandbox Code Playgroud)
默认情况下,npm使用您的默认私钥.我希望能够指定运行时npm应该使用哪个ssh键npm install.有没有办法做到这一点?
从ActionFilter中止/取消操作的最佳方法
我有这个ActionFilter,并且假设立即结束连接并返回401 Unauthroized:
public class SignInRequired : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
// User is verified, continue executing action
if (Acme.Web.CurrentUser != null)
{
return;
}
// End response with 401 Unauthorized
var response = HttpContext.Current.Response;
response.StatusCode = (int)HttpStatusCode.Unauthorized;
response.End();
// Prevent the action from actually being executed
filterContext.Result = new EmptyResult();
}
}
Run Code Online (Sandbox Code Playgroud)
我学会了如何通过在这里设置'context.Result = new EmptyResult()`来取消执行操作,但我不确定这是否是刷新响应和关闭连接的最佳方法.
public class A
{
public virtual string Go(string str) { return str; }
}
public class B : A
{
public override string Go(string str) {return base.Go(str);}
public string Go(IList<string> list) {return "list";}
}
public static void Main(string[] args)
{
var ob = new B();
Console.WriteLine(ob.Go(null));
}
Run Code Online (Sandbox Code Playgroud)
http://dotnetpad.net/ViewPaste/s6VZDImprk2_CqulFcDJ1A
如果我运行这个程序,我会将"list"发送到输出.为什么这不会在编译器中触发模糊的引用错误?
我正在运行node.js EB容器并尝试将JSON存储在环境变量中.JSON正确存储,但是当通过process.env.MYVARIABLE检索它时,将返回所有双引号被剥离.
例如,MYVARIABLE看起来像这样:
{ "prop": "value" }
当我通过process.env.MYVARIABLE检索它时,它的值是实际的{ prop: value},这是无效的JSON.我试图用'\'即{\"prop \":\"value \"}来逃避引号,这只会在字符串返回时添加更多奇怪的行为{\ \"prop\\":\ \"value\\" }.我也尝试用单引号包装整个东西,例如'{ "prop": "value" }',但它似乎也剥离了它们.
任何人都知道如何在环境变量中存储JSON?
编辑:更多信息,当您设置环境变量时,似乎某些字符被双重转义.例如,如果我用单引号包装对象.当我使用sdk获取它时的值变为:
\'{ "prop": "value"}\'
另外,如果我将引号保留,反斜杠会被转义,所以{"url": "http://..."}当我通过sdk查询对象看起来像结果时{"url": "http:\\/\\/..."}
它不仅会破坏文本,还会重新排列JSON属性,因此属性的显示顺序与我设置的顺序不同.
UPDATE
所以我认为这似乎是AWS中的一个错误,因为它似乎正在破坏提交的值.无论我使用node.js sdk还是Web控制台,都会发生这种情况.作为一种解决方法,我在部署期间用json对象上的单引号替换双引号,然后再在应用程序中再次使用.
SELECT
deal_woot.*,
site.woot_off,
site.name AS site_name
FROM deal_woot
INNER JOIN site ON site.id = site_id
WHERE site_id IN (2, 3, 4, 5, 6)
GROUP BY site_id
ORDER BY deal_woot.id DESC
LIMIT 5
Run Code Online (Sandbox Code Playgroud)
我想在分组之前先订购,我该如何做到这一点?
我有以下模型:Game 和 Pick。Game 和 Pick 之间存在一对多的关联。还有第三个模型叫做 Player,一个 Player 有很多 Picks。
Player 类中有一个方法可以为给定的游戏找到一个选择,或者如果它不存在则创建一个新的。
class Player < ActiveRecord::Base
has_many :picks
def pick_for_game(game)
game_id = game.instance_of?(Game) ? game.id : game
picks.find_or_initialize_by_game_id(game_id)
end
end
Run Code Online (Sandbox Code Playgroud)
我想急切地为每个选择加载游戏。但是,如果我这样做
picks.find_or_initialize_by_game_id(game_id, :include => :game)
Run Code Online (Sandbox Code Playgroud)
它首先在此查询运行时获取选择(该方法运行多次),然后在访问每个选择时获取游戏。如果我将 default_scope 添加到 Pick 类
class Pick < ActiveRecord::Base
belongs_to :game
belongs_to :player
default_scope :include => :game
end
Run Code Online (Sandbox Code Playgroud)
它仍然为每个选择生成 2 个选择语句,但现在它在选择后立即加载游戏,但它仍然没有像我期望的那样进行连接。
Pick Load (0.2ms) SELECT "picks".* FROM "picks" WHERE "picks"."game_id" = 1 AND ("picks".player_id = 1) LIMIT 1
Game Load (0.4ms) SELECT "games".* FROM "games" …Run Code Online (Sandbox Code Playgroud) 我在Fluent NHibernate地图上看到以下错误:
NHibernate.MappingException: Association references unmapped class: System.Guid
我发誓我之前已经做过这件事并且有效,所以我不确定是什么导致了这个问题.我正在使用FNH 1.1和SQLite数据库.这是我的班级和地图:
public class Photo
{
public virtual Guid Id { get; set; }
public virtual byte[] Data { get; set; }
public virtual string Caption { get; set; }
}
public class PhotoMap : ClassMap<Photo>
{
public PhotoMap()
{
Id(p => p.Id).GeneratedBy.Guid();
Map(p => p.Caption);
Map(p => p.Data);
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢您的帮助.
我指定了
gem 'haml'
gem 'rdiscount'
Run Code Online (Sandbox Code Playgroud)
在我的Gemfile中运行bundle install
相关代码是
.welcome-message
:markdown
Welcome **#{current_user.email}**
Run Code Online (Sandbox Code Playgroud)
当我访问页面时,我得到了
无法运行Markdown过滤器; 需要'rdiscount'或'peg_markdown'或'maruku'或'bluecloth',但没有找到
我正在使用rails 3.0.5,我错过了什么?
我的版本在Windows Server 2003,TeamCity 6.0.3上运行.git存储库存储在同一台服务器上,可以通过cygwin的sshd和gitd访问.我在TeamCity中的vcs配置如下:
获取URL:git:// server/Repo
推送URL:ssh:// server /〜/ Repo
验证设置
验证方法:密码
用户名:TeamCitySC(这是专门为标签设置的本地帐户)
密码:******
对于每个用户,在它们到存储库的主路径中有一个符号链接,因此是〜/ Repo路径.标签在大约100个版本中工作得很好,最近它定期开始抱怨以下消息:
root'git root'标记失败org.eclipse.jgit.api.errors.JGitInternalException:将ref refs/tags/build-108更新为Tag [03e70a74b39c1393f5ce684424194210513b4d48] = {object 0f6101df222f5370a17f5ce1c97eb2348d64970c type commit tag build-108 tagger PersonIdent [SYSTEM, SYSTEM @ server,Thu May 26 16:16:07 2011 -0600]}失败了.来自RefUpdate.update()的ReturnCode在org.eclipse.jgit.api.TagCommand.call(TagCommand.java:159)的jetbrains.buildServer.buildTriggers.vcs.git.GitVcsSupport.label(GitVcsSupport.java:1334)处被拒绝jetbrains.buildServer.vcs.impl.VcsLabeler.setLabel(VcsLabeler.java:80)at jetbrains.buildServer.vcs.impl.VcsLabeler.setLabel(VcsLabeler.java:1)at jetbrains.buildServer.serverSide.impl.FinishedBuildImpl.setLabel( FinishedBuildImpl.java:10)at jetbrains.buildServer.serverSide.impl.auth.SecuredBuildFactory $ SecuredFinishedBuildImpl.setLabel(SecuredBuildFactory.java:3)at jetbrains.buildServer.controllers.SetLabelAction.doProcess(SetLabelAction.java:11)at etc .. .
即使我手动尝试通过TeamCity标记构建(即在给定构建的"更改"选项卡中"标记此构建源"链接),它仍然会失败.
假设我有一堂课
public class MyClass
{
public string Type { get; set; }
public int Id { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我有一个集合类,它只是一个强类型列表
public class MyClassList : List<MyClass>
{
public MyClassList(IEnumerable<MyClass> enumerable) : base (enumerable) {}
}
Run Code Online (Sandbox Code Playgroud)
我希望MyClassList能够根据内容生成唯一的哈希码MyClassList。的哈希码MyClass应该基于这两个属性。即使对象的顺序不同,的哈希码也MyClassList应该相同。
为了处理排序问题,我想我可以在生成哈希码之前对列表进行排序,但我不确定如何生成列表的哈希码。
您好我尝试在nhibernate中使用存储过程,我发现了一些方法:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<sql-query name="CO_Visites_Treeview_Sel">
exec CO_Visites_Treeview_Sel :Idclient, :Idmagasin, :Autre, :Tous
</sql-query>
</hibernate-mapping>
Run Code Online (Sandbox Code Playgroud)
如果我想使用我将使用的数据:
var query = session.GetNamedQuery("CO_Visites_Treeview_Sel");
query.SetString("Idclient", lstClients.SelectedValue.ToString());
query.SetInt32("Idmagasin", 36);
query.SetBoolean("Autre", false);
query.SetBoolean("Tous", true);
var results = query.List();
Run Code Online (Sandbox Code Playgroud)
在那种情况下,我不会有智慧结果['colName']
我用另一种方法:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="NHibernate.DataAccess.Models.Visites_Treeview,NHibernate.DataAccess" lazy="true">
<id name="Idvisite" column="IDVISITE" type="string">
<generator class="assigned" />
</id>
<property column="NOMMAGASIN" name="Nommagasin" type="string" />
<property column="DATEVIS" name="Datevis" type="DateTime" />
<property column="INTERVENTION" name="Intervention" type="Boolean" />
<property column="IDFACTURE" name="Idfacture" type="string" />
<property column="STATUT" name="Statut" type="byte" />
<property column="NOFACTURE" …Run Code Online (Sandbox Code Playgroud) 我见过几个.NET项目(例如FluentNHibernate)使用Ruby的rake来运行他们的构建,而不是使用.Net工具,如NAnt或MSBuild.这样做有什么好处?我们正在开始一个新项目,并试图弄清楚是否坚持我们现有的NAnt构建或迁移到其他东西.任何意见,将不胜感激.
我们正在使用.Net 3.5,如果它有所作为.
c# ×3
git ×2
nhibernate ×2
node.js ×2
.net ×1
activerecord ×1
asp.net ×1
asp.net-mvc ×1
collections ×1
equality ×1
gethashcode ×1
haml ×1
jquery ×1
markdown ×1
msbuild ×1
mysql ×1
named-query ×1
nant ×1
npm ×1
rake ×1
rdiscount ×1
sql ×1
sqlite ×1
ssh ×1
teamcity ×1