我正在构建一个自定义验证,用于检查银行帐号并使用外部API 对代码进行排序,以测试它们是否存在(即是一个合适的有效英国银行帐户).由于这是一项昂贵的操作,我不想打扰API,除非帐号和排序代码通过Rails内置的验证.
例如,我有这些基本验证:
validates_presence_of :sort_code, :account_number
validates_format_of :sort_code, :with => Regexes::SORT_CODE
validates_format_of :account_number, :with => Regexes::ACCOUNT_NUMBER
Run Code Online (Sandbox Code Playgroud)
然后我有自定义验证:
validate :check_valid_bank_account
def check_valid_bank_account
# code here is irrelevant, but essentially this hits the API
# if it's a valid UK bank account all is OK, if not we add an error
end
Run Code Online (Sandbox Code Playgroud)
我想要确保的是,只有在模型的其余部分有效时才执行自定义验证.当我能够自己解决这个问题时,没有任何一点支付25p被告知没有提供帐号!
我知道我可以编写一些逻辑来检查这两个属性是否为空,并将它们与正则表达式手动匹配...但这似乎不是一种非常Rails的方式.
我正在使用一个优秀的jquery插件来为我的网页表单选择生日日期.
在这里演示:http: //abecoffman.com/stuff/birthdaypicker/
我正在处理的问题是表单验证.我的表单验证重定向回到同一页面,我将丢失所选的日期.
有没有办法在日期选择器的javascript中添加一个选项:http: //abecoffman.com/stuff/birthdaypicker/bday-picker.js
这样我就可以设置"默认选定日期".配置可以工作如下:
$("#picker1").birthdaypicker({
chosenDay: 1;"
chosenMonth: 28;"
chosenYear: 2011;"
});
Run Code Online (Sandbox Code Playgroud)
这将把"选定"日期设置为2011年1月28日.
我想写ac#方法来检索当前页面.例如Default6.aspx我知道我可以做以下事情:
string url = HttpContext.Current.Request.Url.AbsoluteUri;
// http://localhost:1302/TESTERS/Default6.aspx
string path = HttpContext.Current.Request.Url.AbsolutePath;
// /TESTERS/Default6.aspx
string host = HttpContext.Current.Request.Url.Host;
// localhost
Run Code Online (Sandbox Code Playgroud)
但是我如何获得Default6.aspx?如果url是http:// localhost:1302/TESTERS /,我的方法应该返回default.aspx
我遇到了一个奇怪的问题.我正在对HTC EVO进行测试.我编写了一个针对2.2的演示相机应用程序,几乎一切都正常.问题是,在拍摄三到四张照片后,应用程序崩溃并给我以下消息:
D/QualcommCameraHardware( 64): takePicture(479)
D/QualcommCameraHardware( 64): val_ril_status = 0,val_wimax_status = 0,val_hotspot_status = 0,val_low_temp_limit = 10.000000,val_batt_temp = 29.799999,val_low_temp_limit = 15,val_batt_cap = 96
D/QualcommCameraHardware( 64): FLASHLIGHT is ENABLED
D/QualcommCameraHardware( 64): stopPreviewInternal E: 1
D/QualcommCameraHardware( 64): cancelAutoFocusInternal E
D/QualcommCameraHardware( 64): cancelAutoFocusInternal X: 0
I/QualcommCameraHardware( 64): deinitPreview E
D/QualcommCameraHardware( 64): launch_watchdog_thread:
D/QualcommCameraHardware( 64): watchdog_thread_id = 369048
I/QualcommCameraHardware( 64): register_buf: camfd = 35, reg = 1 buffer = 0x4153f000
I/QualcommCameraHardware( 64): register_buf: camfd = 35, reg = 1 buffer = 0x415bf000
I/QualcommCameraHardware( 64): register_buf: …Run Code Online (Sandbox Code Playgroud) 我在一个简单的django应用程序中有一个模型,记录了参加比赛的人的分数.我有两个模型对象,Entry和Person.每个条目都有一个人,一个人有多个条目.
我想生成一个页面,显示每个用户,他们的总分和他们的排名.
我到目前为止的命令如下:
Entry.objects.values('person__name').annotate(total=Sum('score')).order_by('-total')
Run Code Online (Sandbox Code Playgroud)
我可以使用for块很好地将结果输出到页面上.我唯一没有得到的是排名.
向每条记录添加记录的数字排名的最佳方法是什么,包括当两个分数相同时,排名反映这一点(即"4 =")?尝试使用forblock.counter和一些先行/后置机制在模板中执行此操作会更好,还是尝试将此字段用于查询本身?
简单的问题,如何在Jquery中完成此功能:测试鼠标是否悬停在上面 .myBox
if ($(".myBox").mouseleave = true) {
DO SOMETHING
} else {something else}
Run Code Online (Sandbox Code Playgroud)
要么
if ($(".myBox").mouseover = false) {
DO SOMETHING
} else {Something else}
Run Code Online (Sandbox Code Playgroud)
注意:我正在寻找IF声明
我正在尝试从ASP.Net Web应用程序通过命令提示符运行命令.我可以看到进程在Web服务器上的任务管理器中启动,但是进程只是位于那里并且从不退出也不运行我指定的命令.
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/C " +command;
startInfo.UserName = "myuser";
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.Domain = "mydomain";
startInfo.CreateNoWindow = true;
String pass = "mypass";
System.Security.SecureString secPass = new System.Security.SecureString();
foreach (char c in pass.ToCharArray())
{
secPass.AppendChar(c);
}
secPass.MakeReadOnly();
startInfo.Password = secPass;
process.StartInfo = startInfo;
process.Start();
//output = process.StandardOutput.ReadToEnd();
process.WaitForExit();
process.Close();
Run Code Online (Sandbox Code Playgroud)
我已经尝试过,无论是否读取标准输出.
应用程序将process.WaitForExit();一直持续到我通过任务管理器终止进程.
正如标题所示,我试图从私有github仓库安装一个python包.对于公共存储库,我可以发出以下命令,该命令工作正常:
pip install git+git://github.com/django/django.git
Run Code Online (Sandbox Code Playgroud)
但是,如果我尝试使用私有存储库:
pip install git+git://github.com/echweb/echweb-utils.git
Run Code Online (Sandbox Code Playgroud)
我得到以下输出:
Downloading/unpacking git+git://github.com/echweb/echweb-utils.git
Cloning Git repository git://github.com/echweb/echweb-utils.git to /var/folders/cB/cB85g9P7HM4jcPn7nrvWRU+++TI/-Tmp-/pip-VRsIoo-build
Complete output from command /usr/local/bin/git clone git://github.com/echweb/echweb-utils.git /var/folders/cB/cB85g9P7HM4jcPn7nrvWRU+++TI/-Tmp-/pip-VRsIoo-build:
fatal: The remote end hung up unexpectedly
Cloning into /var/folders/cB/cB85g9P7HM4jcPn7nrvWRU+++TI/-Tmp-/pip-VRsIoo-build...
----------------------------------------
Command /usr/local/bin/git clone git://github.com/echweb/echweb-utils.git /var/folders/cB/cB85g9P7HM4jcPn7nrvWRU+++TI/-Tmp-/pip-VRsIoo-build failed with error code 128
Run Code Online (Sandbox Code Playgroud)
我想这是因为我试图访问私有存储库而不提供任何身份验证.因此我尝试使用git + ssh希望pip使用我的ssh公钥进行身份验证:
pip install git+ssh://github.com/echweb/echweb-utils.git
Run Code Online (Sandbox Code Playgroud)
这给出了以下输出:
Downloading/unpacking git+ssh://github.com/echweb/echweb-utils.git
Cloning Git repository ssh://github.com/echweb/echweb-utils.git to /var/folders/cB/cB85g9P7HM4jcPn7nrvWRU+++TI/-Tmp-/pip-DQB8s4-build
Complete output from command /usr/local/bin/git clone ssh://github.com/echweb/echweb-utils.git /var/folders/cB/cB85g9P7HM4jcPn7nrvWRU+++TI/-Tmp-/pip-DQB8s4-build:
Cloning into /var/folders/cB/cB85g9P7HM4jcPn7nrvWRU+++TI/-Tmp-/pip-DQB8s4-build...
Permission denied (publickey).
fatal: The remote end hung …Run Code Online (Sandbox Code Playgroud) 您好
我有一个具有多个框架的应用程序作为表单.
当用户从某个帧移动时,我需要删除临时文件,当我按下OK或CANCEL时,我当前删除了该文件.
如果他们只是关闭应用程序我也想删除临时文件,但无法确定框架何时被销毁.
问候,彼得
c# ×2
jquery ×2
activerecord ×1
android ×1
camera ×1
cmd ×1
datepicker ×1
delphi ×1
destroy ×1
django ×1
exception ×1
frame ×1
git ×1
github ×1
hover ×1
java ×1
javascript ×1
mouseleave ×1
mouseover ×1
ondestroy ×1
pip ×1
process ×1
python ×1
rank ×1
request ×1
ruby ×1
url ×1
validation ×1
void ×1