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 user.demo | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import scala.concurrent.duration._ | |
import scala.concurrent.{Await, Future} | |
/** | |
* Scala console app which handles user's input asynchronously. | |
* Each user answer should be set to default value by timeout. | |
*/ |
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 java.net.URI | |
import org.scalatest._ | |
import scala.concurrent.duration._ | |
class UnshortTest extends FlatSpec with Matchers { | |
def unshort(u: String, w: Duration): Option[URI] = { | |
import dispatch._, Defaults._ | |
import scala.concurrent.Await |
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 fastlookup | |
import java.io.File | |
import akka.actor._ | |
object FileFinder { | |
case class Scan(val dir: File, val name: 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
import edu.princeton.cs.algs4.Point2D; | |
import edu.princeton.cs.algs4.RectHV; | |
import edu.princeton.cs.algs4.SET; | |
import edu.princeton.cs.algs4.StdDraw; | |
public class KdTree { | |
private static class Node { | |
private Point2D p; // the point | |
private RectHV rect; // the axis-aligned rectangle corresponding to this node |
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
public class MissingElement { | |
public int solution(int[] A) { | |
if (A == null) return 1; | |
else if (A.length == 0) return 1; | |
else { | |
java.util.Arrays.sort(A); | |
return evaluate(A, 0, A.length - 1); | |
} | |
} |
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 mireyn; | |
import java.util.concurrent.ForkJoinPool; | |
import java.util.concurrent.ForkJoinTask; | |
import java.util.concurrent.RecursiveAction; | |
public class ForkJoinArrayEvaluator { | |
private static final int CPU = Runtime.getRuntime().availableProcessors(); | |
public static int THRESHOLD = CPU * 16; |
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
sealed trait Localizator { | |
def apply(s: State): String | |
} | |
sealed trait State { | |
def name(implicit loc: Localizator): String = loc.apply(this) | |
} | |
sealed trait OkState extends State | |
sealed trait ErrorState extends State |
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.xml._ | |
import java.util.Date | |
import java.lang.ThreadLocal | |
import java.text.SimpleDateFormat | |
import scala.collection.immutable._ | |
/** | |
* Simple XmlTv format parser | |
* http://wiki.xmltv.org/index.php/XMLTVFormat | |
*/ |
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 java.net.InetAddress | |
import java.nio.ByteBuffer | |
object InetUtils { | |
private[this] val Radix = 16 | |
// Fast Hex converters | |
private[this] val HexChars: Array[Char] = "0123456789ABCDEF".toCharArray |
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
/** | |
* Join list of lists by order of elements | |
* val a = List(3, 5, 6) | |
* val b = List(1, 2, 7, 8) | |
* val expected = List(3, 1, 2, 5, 6, 7, 8) | |
* | |
* @param lists list of lists of elements | |
* @return list of elements | |
*/ | |
def join[A](lists: List[List[A]]): List[A] = { |
OlderNewer