This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function setjdk | |
if test -n "$JAVA_HOME" | |
removeFromPath "$JAVA_HOME/bin" | |
end | |
set -gx JAVA_HOME (/usr/libexec/java_home -v $argv[1]) | |
set -gx PATH $JAVA_HOME/bin $PATH | |
end | |
function removeFromPath | |
set -l idx 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.collection.AbstractIterator | |
case class Player(name: String, rank: Int) | |
case class Position(group: Char, index: Int, player: Player) | |
val 老猪 = Player("老猪", 1719) | |
val 邢罡 = Player("邢罡(外卡)", 1500) | |
val a剑 = Player("a剑", 1528) | |
val 阮鸣强 = Player("阮鸣强", 1478) | |
val 大通 = Player("大通", 1392) | |
val 简 = Player("简", 1429) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.collection.AbstractIterator | |
def forward_from(n: Int, e: Int) = Iterator.continually(1 to n).flatten.slice(e - 1, e - 1 + n).toVector | |
def backward_from(n: Int, e: Int) = Iterator.continually(n.to(1, -1)).flatten.slice(n - e, n - e + n).toVector | |
def beiger_even(player_count: Int): Iterator[(Vector[Int], Vector[Int])] = new AbstractIterator[(Vector[Int], Vector[Int])] { | |
var next_round = 1 | |
var flat = (1 to player_count).toVector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.snippets | |
import scala.collection.immutable.Stream.#:: | |
import scala.util.{Failure, Success, Try} | |
class InsufficientParametersException(message: String) extends RuntimeException(message) | |
object Tailrec2Fold { | |
type RpnModel = String | |
type CalculationState = (String, String) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val programmingScala = TreeNode("Scala 程序设计", Seq( | |
TreeNode("序"), | |
TreeNode("前言"), | |
TreeNode("第一章 零到六十: Scala简介", Seq( | |
TreeNode("1.1 为什么选择 Scala", Seq( | |
TreeNode("1.1.1 富有魅力的 Scala"), | |
TreeNode("1.1.2 关于 Java8") | |
)), | |
TreeNode("1.2 安装 Scala", Seq( | |
TreeNode("1.2.1 使用 SBT"), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.snippets | |
import scala.collection.mutable.ListBuffer | |
import scala.reflect.ClassTag | |
trait Event[T] { | |
} | |
trait EventListener[T] { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.redis._ | |
val redis = new RedisClient("localhost", 6379) | |
for{set <- redis.smembers("Odersky-Keys")} | |
for{opt <- set} | |
for{key <- opt} | |
redis.del(key) | |
redis.del("Odersky-Keys") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import util._ | |
trait Idiomatic { | |
def step1(s: String): Try[List[String]] | |
def step2(s: String): Option[String] | |
def logic(src: String) = { | |
for(data1 <- step1(src)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.snippets | |
object NormalizePage { | |
def solute(m: Int, n: Int): Option[Int] = { | |
var i = n | |
while(i <= m.min(2*n)) { | |
if(m % i + n <= i) return Some(i) | |
i += 1 | |
} | |
None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.snippets | |
import scala.concurrent.{Future, Promise} | |
class Test { | |
def test(): Function3[String, String, String, String] = { | |
new Function3[String, String, String, String] { | |
@throws(classOf[Exception]) | |
override def apply(arg1: String, arg2: String, arg3: String): Future[String] = { | |
Promise[String]().future |
NewerOlder