我试图读取以下2个函数的参数列表:
1. def foo(action: => String => String) = "bar"
2. def foo(action: => () => String => String) = "bar"
Run Code Online (Sandbox Code Playgroud)
我无法使用ui-typeahead在自定义模板中调用控制器函数:
<input typeahead="val for val in autoComplete($viewValue)"
typeahead-template-url="searchAutocompleteTpl.html"
ng-model="query"/>
<script type="text/ng-template" id="searchAutocompleteTpl.html">
<span ng-repeat="eqp in match.model.equipment"/>
<a href="" ng-click="showItem(eqp.model)">
found in: {{eqp.model}}
</a>
</script>
Run Code Online (Sandbox Code Playgroud)
问题是模板中似乎没有控制器的范围:
showItem(eqp.model)
永远不会被称为.我也尝试过:
$parent.showItem(eqp.model)
无济于事.
如何调用控制器范围内的函数/值呢?
我有许多范围对象需要合并,以便所有重叠范围消失:
case class Range(from:Int, to:Int)
val rangelist = List(Range(3, 40), Range(1, 45), Range(2, 50), etc)
Run Code Online (Sandbox Code Playgroud)
这是范围:
3 40
1 45
2 50
70 75
75 90
80 85
100 200
Run Code Online (Sandbox Code Playgroud)
完成后我们会得到:
1 50
70 90
100 200
Run Code Online (Sandbox Code Playgroud)
命令式算法:
要做到这一点必须要创建大量的临时变量,索引循环等.
所以我想知道是否有更实用的方法?
乍一看,源集合必须能够像Stack一样提供pop()PLUS,能够在迭代时通过索引删除项目,但之后就不再那么具有功能了.
如何让Akka知道Play的logback配置(application-logger.xml)?
在我的情况下,它完全被忽略:
class Dispatcher extends Actor with ActorLogging {
// prints to stdout ONLY:
log.error("[akka-logger] dispatch started...")
}
Run Code Online (Sandbox Code Playgroud)
play {
akka {
#log-config-on-start = on
loggers = ["akka.event.slf4j.Slf4jLogger"]
event-handlers = ["akka.event.slf4j.Slf4jEventHandler"]
loglevel = DEBUG
# and so on...
}
Run Code Online (Sandbox Code Playgroud)
<configuration>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>${application.home}/logs/application.log</file>
<encoder>
<pattern>%date - [%level] - from %logger in %thread %n%message%n%xException%n</ pattern>
</encoder>
</appender>
<!-- Using akka.event.slf4j.EventHandler does NOT make a difference here: -->
<logger name="akka.event.slf4j.Slf4jLogger" level="ERROR" additivity="false">
<appender-ref ref="FILE"/>
</logger> …Run Code Online (Sandbox Code Playgroud) Akka-2实例应保持无限循环,并每隔10分钟检查一次数据.
如何设计循环以便实例调用自身,检查要执行的工作然后休眠一段时间?
此外,我看到一个人不能再查询邮箱大小.只要工作任务(在这种情况下是调度功能)处于活动状态,您如何确保忽略消息?
case class Dispatch()
// Automatical start? The start function has been removed since Akka 2 ?
val dispatcher = system.actorOf(Props[MailDispatcher])
class MailDispatcher extends Actor {
private val interval = Config.getLong("mail.check.interval")
context.setReceiveTimeout(Duration(interval, TimeUnit.SECONDS))
def receive = {
case ReceiveTimeout => {
self ! Dispatch
}
case Dispatch => dispatch()
case e: Exception => Logger.error("unexpected Error: " + e)
}
def dispatch() {
// trigger mail-dispatch
}
}
Run Code Online (Sandbox Code Playgroud) 我有2个包含彩票实例的列表.
One List持有赢得特别奖的门票,另一个List包含获得最终数字命中的门票.
现在我必须删除带有冗余号码的票证并将奖品一起添加.
case class Ticket(number:Long, prize:Long)
val specialPrizes = List(Ticket(42, 1000), Ticket(66, 2000))
val finalDigitPrizes = List(Ticket(42, 50))
Run Code Online (Sandbox Code Playgroud)
这将产生一个包含合并门票的列表,这些门票本身包含累积的奖品:
val finalList = List(Ticket(42, 1050), Ticket(66, 2000))
Run Code Online (Sandbox Code Playgroud)
没有临时变量,索引计数器等,在功能上执行此操作的最有效方法是什么?
我通过$ .get()将一些html加载到Jquery-dialog-popup中.
单击新插入的html中的链接后,应触发某个功能.
这适用于live()但不适用于on().
这有效:
$(".remove").live("click", function () {
// enter ok
}
Run Code Online (Sandbox Code Playgroud)
这不是:
$("div").on("click", ".remove", function () {
// or $("#delete").on("click", ".remove", function () {
// or $(".remove").on("click", function () {
// never enters...
});
Run Code Online (Sandbox Code Playgroud)
HTML:
<div id="delete">
<a class="remove" href="#">link</a>
</div>
Run Code Online (Sandbox Code Playgroud)
on() - 函数适用于我直接从我的主模板调用它而不首先通过$ .get将内容加载到对话窗口中.
我有一张桌子,上面有一个bigint-field.现在我想用增量插入数百万行,所以我想出了这个过程:
CREATE PROCEDURE insertMe()
BEGIN
DECLARE i BIGINT DEFAULT 1;
WHILE (i <= 999999999) DO
INSERT INTO mytable values(i);
SET i=i+1;
END WHILE;
END;
Run Code Online (Sandbox Code Playgroud)
当然这种野兽需要太长时间,所以我通常会做以下事情:
INSERT INTO mytable values(1),(2),(3) etc
Run Code Online (Sandbox Code Playgroud)
但是我如何创建String然后也不会花太长时间?