作为标题哪个更好,为什么?这样做的任何弱点?我听说Jquery/Javascript检查不好并建议使用PHP,但不知何故不知道为什么....
需要一些推荐你们.提前致谢.
任何人都会看到这是好还是坏:
<input type="file" name="task_doc" class="task_doc" onChange="checkext();"/>
function checkext(){
var permittedFileType = ['pdf', 'doc', 'docx', 'xls', 'xlsx'];
var fext = $(".task_doc").val().split('.').pop().toLowerCase();
var resultFile = validate_filetype(fext, permittedFileType);
if(resultFile === false){
$(".task_doc").replaceWith("<input type='file' name='task_doc' class='task_doc' onChange='checkext();'>");
alert("Invalid Extension");
}
else{
alert("Success");
}
}
function validate_filetype(fext, ftype)
{
for(var num in ftype)
{
if(fext == ftype[num])
return true;
}
return false;
}
Run Code Online (Sandbox Code Playgroud) 我在colors.xml中定义了一堆颜色.我需要得到他们的int表示而不是他们的资源ID,以便我可以操纵代码中的alpha和颜色.我怎样才能做到这一点?
mColor = R.color.blue; // gets resource id not the actual color as an int.
mColor &= ~0xFF000000;
Run Code Online (Sandbox Code Playgroud) 当手机使用双SIM卡适配器时,有没有人有编程选择SIM卡的经验?
谢谢,STeN
后来添加: 我在Android Market上找到了MultiSim应用程序,该应用程序在其描述中写道" ...模拟双SIM卡适配器用户可以切换他们的SIM卡...... ",Android中也有一些API SDK,允许SIM卡切换/选择?
很简单; 我似乎找不到任何关于PHP preg_replace()支持命名反向引用的确定性:
// should match, replace, and output: user/profile/foo
$string = 'user/foo';
echo preg_replace('#^user/(?P<id>[^/]+)$#Di', 'user/profile/(?P=id)', $string);
Run Code Online (Sandbox Code Playgroud)
这是一个简单的例子,但我想知道这种语法(?P=name)是否完全不受支持.语法问题,还是不存在的功能?
我希望能够将"元"信息添加到模型中,基本上是用户定义的字段.所以,举个例子,让我们想象一下User模型:
我为名字,姓氏,年龄,性别定义字段.
我希望用户能够定义一些"元信息",基本上可以进入他们的个人资料页面并分享其他信息.因此,一个用户可能想要添加"爱好","职业"和"家乡",而另一个用户可能想要添加"爱好"和"教育".
所以,我希望能够为这种东西提供一个标准视图,所以例如在视图中我可以做一些像(在HAML中):
- for item in @meta
%li
%strong= item.key + ":"
= item.value
Run Code Online (Sandbox Code Playgroud)
通过这种方式,我可以确保始终如一地显示信息,而不仅仅是向用户提供可以格式化所有不同方式的降价文本框.
我也很想能够点击meta并看到其他用户已经给出相同的东西,所以在上面的例子中,两个用户都定义了"爱好",能够说我希望看到用户是很好的有共同的爱好-甚至更好,我想看看如果用户的爱好是_ __.
因此,由于我不知道用户希望提前定义哪些字段,因此提供这种功能的选项有哪些?
是否有一个gem来处理这样的模型上的自定义元信息,或者至少有类似的东西?有没有人遇到过这种问题?如果是这样,你是如何解决的?
谢谢!
我正在尝试进行身份验证,然后使用Spring LDAP和Spring安全性查询我们的公司LDAP.我设法使身份验证工作,但当我尝试运行搜索时,我总是得到以下异常
为了执行此操作,必须在连接上完成成功绑定
经过大量研究后,我得到了一个理论,即在我进行身份验证之后,在我可以查询之前,我需要绑定到连接.我只是不知道是什么以及如何?
提一下 - 我可以使用JXplorer成功浏览和搜索我们的LDAP,所以我的参数是正确的.
这是我的securityContext.xml的一部分
<security:http auto-config='true'>
<security:intercept-url pattern="/reports/goodbye.html"
access="ROLE_LOGOUT" />
<security:intercept-url pattern="/reports/**" access="ROLE_USER" />
<security:http-basic />
<security:logout logout-url="/reports/logout"
logout-success-url="/reports/goodbye.html" />
</security:http>
<security:ldap-server url="ldap://s140.foo.com:1389/dc=td,dc=foo,dc=com" />
<security:authentication-manager>
<security:authentication-provider ref="ldapAuthProvider">
</security:authentication-provider>
</security:authentication-manager>
<!-- Security beans -->
<bean id="contextSource" class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
<constructor-arg value="ldap://s140.foo.com:1389/dc=td,dc=foo,dc=com" />
</bean>
<bean id="ldapAuthProvider"
class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider">
<constructor-arg>
<bean class="foo.bar.reporting.server.security.ldap.LdapAuthenticatorImpl">
<property name="contextFactory" ref="contextSource" />
<property name="principalPrefix" value="TD\" />
<property name="employee" ref="employee"></property>
</bean>
</constructor-arg>
<constructor-arg>
<bean class="foo.bar.reporting.server.security.ldap.LdapAuthoritiesPopulator" />
</constructor-arg>
</bean>
<!-- DAOs -->
<bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
<constructor-arg ref="contextSource" />
Run Code Online (Sandbox Code Playgroud)
这LdapAuthenticatorImpl …
当用户将鼠标悬停在我的一个列表项按钮上时,是否可以使用HTML5发出声音?当用户将鼠标悬停在导航按钮上时,我想一次播放非常短的咔嗒声/唧唧声.我意识到它不会在每个浏览器或设备上兼容,只要它优雅地降级就可以了.出于某种原因,为此使用Flash会更好吗?
编辑
另外,如果可以这样做,我会对一些示例代码感兴趣,包括javascript(如果需要javascript).我对HTML很好,但对Javascript不太方便.
我正在做:
button.setLayoutParams(new GridView.LayoutParams(65, 65));
根据文档,宽度和高度的单位(上面都是65)是"像素".你如何强制这是设备无关的像素,或"dp"?
我正在使用python 2.7
我想创建一个围绕fcntl.flock()的包装函数,它将在设置的间隔后超时:
wrapper_function(timeout):
Run Code Online (Sandbox Code Playgroud)
我试过调用另一个线程并使用thread.join(超时),但似乎fcntl.flock()继续阻塞:
def GetLock(self, timeout):
"""Returns true if lock is aquired, false if lock is already in use"""
self.__lock_file = open('proc_lock', 'w')
def GetLockOrTimeOut():
print 'ProcessLock: Acquiring Lock'
fcntl.flock(self.__lock_file.fileno(), fcntl.LOCK_EX)
print 'ProcessLock: Lock Acquired'
thread = threading.Thread(target=GetLockOrTimeOut)
thread.start()
thread.join(timeout)
if thread.isAlive():
print 'GetLock timed out'
return False
else:
return True
Run Code Online (Sandbox Code Playgroud)
我已经研究了终止线程的解决方案,最流行的解决方案似乎是对threading.thread进行子类化并添加一个功能来引发线程中的异常.但是,我遇到一个链接,说这个方法不适用于本机调用,我很确定fcntl.flock()正在调用本机函数.建议?
上下文:我使用文件锁来创建单个实例应用程序,但我不希望应用程序的第二个实例坐下来并挂起,直到第一个实例终止.
我找不到任何与如何使用rails 2.3的mysql2相关的内容.是否可以将这两者结合使用?我想使用mysql2,因为我认为这将有助于我的rails 2.3应用程序的性能.
android ×3
php ×2
bind ×1
html5 ×1
html5-audio ×1
javascript ×1
jquery ×1
ldap ×1
metamodel ×1
mysql2 ×1
preg-replace ×1
python ×1
regex ×1
resources ×1
scaling ×1
spring-ldap ×1
upload ×1