I've been trying to understand how to setup systems from
the ground up on Ubuntu. I just installed redis
onto
the box and here's how I did it and some things to look
out for.
To install:
package org.snippets | |
import rx.lang.scala._ | |
import rx.lang.scala.subjects.ReplaySubject | |
import scala.concurrent.Promise | |
import scala.concurrent.ExecutionContext.Implicits.global | |
object MergedSubject { |
package org.snippets | |
object RegexMatch { | |
val LOCATION_JU_MAIN_CAT_PREFIX = "a" | |
val LOCATION_JU_WAP_CAT_PREFIX = "b" | |
val LOCATION_JU_TAOBAO_CAT_PREFIX = "c" | |
val LOCATION_JU_TMALL_CAT_PREFIX = "d" | |
val juCatRE = s"$LOCATION_JU_MAIN_CAT_PREFIX([0-9]+)".r |
import shapeless._ | |
import poly._ | |
import shapeless.ops.tuple.FlatMapper | |
import syntax.std.tuple._ | |
object Flatten { | |
trait LowPriorityFlatten extends Poly1 { | |
implicit def default[T] = at[T](Tuple1(_)) | |
} | |
object flatten extends LowPriorityFlatten { |
object Yadsun { | |
trait SubColumnStatus | |
case object Disabled extends SubColumnStatus | |
case object Enabled extends SubColumnStatus | |
type SubColumns = Map[String, SubColumnStatus] | |
case class SysColumn(columnId: Int, columnText: String, subColumns: SubColumns) { | |
def addSubColumn(text: String) = commonOp(text)(_ => subColumns, txt => subColumns.updated(txt, Enabled)) |
object HKind { | |
trait Monad[M[_]] { | |
def flatMap[T, U](m: M[T], f: T => M[U]): M[U] | |
def map[T, U](m: M[T], f: T => U): M[U] | |
} | |
implicit class MonadSyntax[X, M[_] : Monad](sx: M[X]) { | |
def flatMap[U](f: X => M[U]): M[U] = implicitly[Monad[M]].flatMap(sx, f) |
import java.io.NotSerializableException | |
import play.api.libs.json._ | |
/** | |
* Created by xiefei on 15/11/11. | |
*/ | |
trait Jsonable | |
case class Config(name: String) |
import scalaz.{idInstance => _, _} | |
import std.scalaFuture._ | |
import syntax.applicative._ | |
import shapeless._ | |
import UnaryTCConstraint.*->* | |
import poly._ | |
import ops.hlist._ | |
object HListSequence { |
Everyone knows what Halloween is and how children love it. Children in costumes travel from house to house asking for treats with a phrase "Trick or treat". After that, they divide the treats equally among all. This year, they collected tons of candies, and need your help to share everything equally. You know that children receive different number of candies depending on their costume: vampire gets 3 candies from one house, zombie – 4 candies, and witch – 5 candies. That is, three children in three different costumes get 3+4+5=12 candies from one house.
The first argument is a path to a file. Each line includes a test case with number of vampires, zombies, witches, and houses that they visited.
For example:
import monocle.macros.Lenses | |
import language.higherKinds | |
@Lenses("_") case class Street(name: String) | |
@Lenses("_") case class Address(street: Street) | |
@Lenses("_") case class Company(addresses: Seq[Address]) | |
@Lenses("_") case class Employee(company: Company) | |
object ILens { | |
val employee = Employee(Company(Seq( |