小编ris*_*p89的帖子

简单的coffeescript网页

我已经看过coffescript教程,展示如何使用rails,nodejs甚至coffeescript REPL来学习coffeescript.

如何创建一个Web项目,我可以在HTML页面中编写一个cofeescript脚本,我的意思是

<script type ="text/coffeescript">
//some coffeescript code
</script>
Run Code Online (Sandbox Code Playgroud)

如何在开发网站时使用coffeescript?只是告诉包含输出javascript并测试它.但是,我不想这样做(我觉得它只是笨拙).

我也看过coffeescript网站,它有很少的方向,它说 -

在此输入图像描述

我试过了,我将这些脚本和jquery一起包含在内.但我的页面仍然是空白.有谁做过,你能提供一个示例代码吗?

谢谢.

coffeescript

5
推荐指数
1
解决办法
1557
查看次数

什么是DTD?

我在我的文档中多次使用过DTD,但我从来不知道它的意义.我也试过了解DTD的W3Schools教程.但我发现它太理论化了.

DTD究竟有什么重要意义,为什么类型定义如此重要?

xml dtd

4
推荐指数
1
解决办法
730
查看次数

如何识别用户代理是否是Windows 8平板电脑?

我有一个Web应用程序.我的JavaScript,我通过用户代理字符串识别设备如下:

_android = navigator.userAgent.toLowerCase().indexOf("android");

_iOS = navigator.platform.indexOf("iPhone");
Run Code Online (Sandbox Code Playgroud)

我的任务是确定设备是否是win8平板电脑?

我已经看过这篇文章了.但是,字符串"Windows NT"很可能出现在所有PC浏览器的useragent中.那么,我需要找出一种客户端方式来识别设备是否是win8平板电脑?

有什么想法吗?

javascript device-detection windows-8

4
推荐指数
2
解决办法
1万
查看次数

F#中的类型推断

在F#中,为什么我的add函数不添加两个浮点数

let add a b = a+b

(add 3 4) //returns 7
(add 3.5 5.5) //error
Run Code Online (Sandbox Code Playgroud)

还请解释F#中的类型推断是如何工作的.

谢谢.

f# type-inference

3
推荐指数
1
解决办法
248
查看次数

忽略Python中的异常

我在python中有try-except块,我想在发生异常时什么都不做.我的代码如下:

for i in range(len(grid)):
    for j in range(len(grid[i])):
        try:
            count = count > int(grid[i][j]) ? count : int(grid[i][j])
        except:
            //Do nothing here
Run Code Online (Sandbox Code Playgroud)

如果发现异常,我该怎么办?

谢谢.

python try-except

3
推荐指数
3
解决办法
1万
查看次数

javascript对象始终为null

这是我的代码:

myExt = {};
myExt.Panel = function (config){
    var d = document.createElement("div");
    /*Do something (a lot) with config and d here
    // a lot of code here
    */
    return
    {
        div:d,
        events:e,
        customattribs:ca
     };
}
Run Code Online (Sandbox Code Playgroud)

这是我的来电者:

var p = new myExt.Panel({
    id:'parent',
    events:{
        onload:function(){
            alert("onload");
        }
    },
    //more configs
});
Run Code Online (Sandbox Code Playgroud)

如果我做

console.log(p)
Run Code Online (Sandbox Code Playgroud)

我得到了.请帮我调试一下这个问题.

javascript object

3
推荐指数
1
解决办法
97
查看次数

spring data redis master slave config

以下是我的jedis配置

@Bean
public JedisConnectionFactory getJedisConnectionFactory() {
    JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
    jedisConnectionFactory.setUsePool(true);
    return jedisConnectionFactory;
}

@Bean
public RedisTemplate<String, Object> getRedisTemplate() {
    RedisTemplate<String, Object> redisTemplate = new RedisTemplate<String, Object>();
    redisTemplate.setConnectionFactory(getJedisConnectionFactory());
    return redisTemplate;
}
Run Code Online (Sandbox Code Playgroud)

当我有单个服务器时,此配置很有效.我想要做的是拥有1个redis master和多个redis slave.根据redis文档,读取应该从slave发生,写入应该从master发生.如何更改上述配置以使用master进行写入和slave进行读取?

可以说我的主人在192.168.10.10,奴隶在localhost.

谢谢!

java spring redis jedis spring-data-redis

3
推荐指数
2
解决办法
6374
查看次数

无法获得连接:一般错误

以下是我正在处理的堆栈跟踪。

2015-04-04 19:15:55,322 [qtp425995691-3536] WARN  org.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: null
2015-04-04 19:15:55,322 [qtp425995691-3536] ERROR org.hibernate.util.JDBCExceptionReporter - Cannot get a connection, general error
2015-04-04 19:15:55.323:WARN:oejs.ServletHandler:/accounts/api/login
org.hibernate.exception.GenericJDBCException: Cannot open connection
    at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140)
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52)
    at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:449)
    at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
    at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:161)
    at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1616)
    at org.hibernate.loader.Loader.doQuery(Loader.java:717)
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:270)
    at org.hibernate.loader.Loader.loadCollection(Loader.java:2082)
    at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:62)
    at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:628)
    at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:83)
    at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1853)
    at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:369)
    at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:111)
    at org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:186)
    at com.nim.domain.user.UserDetail.getAuthorities(UserDetail.java:379)
    at org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider.createSuccessAuthentication(AbstractUserDetailsAuthenticationProvider.java:186)
    at org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider.authenticate(AbstractUserDetailsAuthenticationProvider.java:165)
    at org.springframework.security.authentication.ProviderManager.doAuthentication(ProviderManager.java:120)
    at org.springframework.security.authentication.AbstractAuthenticationManager.authenticate(AbstractAuthenticationManager.java:48)
    at org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter.attemptAuthentication(UsernamePasswordAuthenticationFilter.java:97)
    at com.nim.store.security.NIMAuthenticationProcessingFilter.attemptAuthentication(NIMAuthenticationProcessingFilter.java:69) …
Run Code Online (Sandbox Code Playgroud)

java database spring hibernate jdbc

3
推荐指数
1
解决办法
5373
查看次数

MongoDB创建集合失败

我正在尝试

1.创建一个数据库

use testdb switched to db testdb
Run Code Online (Sandbox Code Playgroud)

2.创建集合

testdb.createCollection(testcollection)
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

2015-05-12T11:21:19.619-0700 E QUERY    ReferenceError: testdb is not defined
    at (shell):1:1
Run Code Online (Sandbox Code Playgroud)

mongodb

3
推荐指数
1
解决办法
3422
查看次数

Ruby 临时文件异常行为

这是我的窥探会话输出:

[1] pry(SomeTask)> epub
=> #<File:/somepath/tmp/x.epub>
[2] pry(SomeTask)> epub.size
=> 134
[3] pry(SomeTask)> File.size("/somepath/tmp/x.epub")
=> 44299
[4] pry(SomeTask)> epub.class
=> Tempfile
Run Code Online (Sandbox Code Playgroud)

我发现这会产生与Tempfile 实例的方法File.size不同的结果。size

这怎么可能?

ruby ruby-on-rails file temporary-files pry

3
推荐指数
1
解决办法
1185
查看次数