Skip to content

Instantly share code, notes, and snippets.

View kmizu's full-sized avatar

Kota Mizushima kmizu

View GitHub Profile
package sample
import akka.actor._
object Main{
def main (args: Array[String]) {
val system = ActorSystem("aaa")
system.eventStream.subscribe(system.actorOf(Props[DeadLetterLogger]), classOf[DeadLetter])
val a = system.actorOf(Props[Parent], "parent")
Thread.sleep(3000)
import javafx.application.Application
import javafx.event.EventHandler
import javafx.scene.input.MouseEvent
import javafx.stage.Stage
import javafx.scene.{Scene, Group}
import javafx.scene.control.Button
import scalaz.concurrent.Future
class GUI extends Application {
@gseitz
gseitz / .sbt
Created July 22, 2011 19:01
Separate global plugins/settings folder per sbt version
## Note: the system property `sbt.global.base` was introduced in 0.10.1
## sbt-0.10.0 still uses the default global directory in ~/.sbt
gseitz@QBallz ~/.sbt % find . -name '*target*' -prune -o -print
.
./0.10.1
./0.10.1/plugins
./0.10.1/plugins/build.sbt
./0.10.1/plugins/project
def foo[A,B](in:Option[A])(valid:PartialFunction[Option[A],Either[B,A]])(invalid:PartialFunction[Option[A],Either[B,A]])(other: =>Either[B,A]) = {
if(!valid.isDefinedAt(in) && !invalid.isDefinedAt(in)) {
other
}else{
(valid orElse invalid)(in)
}
}
def getFirstData(id:String) = {
foo(Cache.get(id)){
@teamon
teamon / app.coffee
Created May 15, 2012 20:36
Backbone.js jQuery file upload with autosave
# This will automatically create or update model
onRender: =>
[method, url] = if @model.isNew()
["POST", mymodels_path()]
else
["PUT", model_path(@model.id)]
@$(".upload").fileupload(
dataType: 'json'
import language.experimental.macros
import language.implicitConversions
import scala.reflect.macros.Context
import scala.reflect.runtime.universe.Tree
class ReflectiveClosure[A, B](val tree: Tree, fn: Function1[A, B]) extends Function1[A, B] {
def apply(x: A) = fn(x)
}
object ReflectiveClosure {
@xuwei-k
xuwei-k / log.txt
Created February 4, 2013 17:50
Scala 2.10.0 compiler crash
[error]
[error] last tree to typer: term $outer
[error] symbol: value $outer (flags: <synthetic> <paramaccessor> <triedcooking> private[this])
[error] symbol definition: private[this] val $outer: unit.ScalateHelperSpec
[error] tpe: <notype>
[error] symbol owners: value $outer -> anonymous class $anonfun -> value <local ScalateHelperSpec> -> class ScalateHelperSpec -> package unit
[error] context owners: value u -> value $anonfun -> value $anonfun -> method apply -> anonymous class $anonfun$apply$4 -> method apply -> anonymous class $anonfun$1 -> value <local ViewSpec> -> class ViewSpec -> package functional
[error]
[error] == Enclosing template or block ==
[error]
@kmizu
kmizu / log.txt
Created February 5, 2013 05:04 — forked from xuwei-k/log.txt
[error]
[error] last tree to typer: term $outer
[error] symbol: value $outer (flags: <synthetic> <paramaccessor> <triedcooking> private[this])
[error] symbol definition: private[this] val $outer: unit.ScalateHelperSpec
[error] tpe: <notype>
[error] symbol owners: value $outer -> anonymous class $anonfun -> value <local ScalateHelperSpec> -> class ScalateHelperSpec -> package unit
[error] context owners: value u -> value $anonfun -> value $anonfun -> method apply -> anonymous class $anonfun$apply$4 -> method apply -> anonymous class $anonfun$1 -> value <local ViewSpec> -> class ViewSpec -> package functional
[error]
[error] == Enclosing template or block ==
[error]
@eed3si9n
eed3si9n / Mediterranean-Diet.md
Last active December 20, 2015 01:48
Primary Prevention of Cardiovascular Disease with a Mediterranean Diet http://www.nejm.org/doi/suppl/10.1056/NEJMoa1200303/suppl_file/nejmoa1200303_appendix.pdf

The general guidelines to follow the Mediterranean diet that dietitians provided to participants included the following positive recommendations:

  • abundant use of olive oil for cooking and dressing dishes;
  • consumption of ≥ 2 daily servings of vegetables (at least one of them as fresh vegetables in a salad), discounting side dishes;
  • ≥ 2-3 daily servings of fresh fruits (including natural juices)
  • ≥ 3 weekly servings of legumes;
  • ≥ 3 weekly servings of fish or seafood (at least one serving of fatty fish);
  • ≥ 1 weekly serving of nuts or seeds;
  • select white meats (poultry without skin or rabbit) instead of red meats or processed meats (burgers, sausages);
(defn points [^BufferedImage image ^BufferedImage screen]
(let [width (.getWidth image)
height (.getHeight image)
xrange (range width)
yrange (range height)]
(for [points
(for [sx (range (- (.getWidth screen) width))
sy (range (- (.getHeight screen) height))]
(for [tx xrange
ty yrange]