Skip to content

Instantly share code, notes, and snippets.

val mass: Mass[Double] = 4.0 kg
val length: Length[Int] = 5 m
val time: Time[Int] = 1 s
val temperature: Temperature[BigDecimal] = BigDecimal("22.22") k
val speed = length / time
val area = length * length
val volume: Volume[Int] = (23 m) * (1 m) * (1 m)
val accel = (10.0 m) / ((1.0 s) * (1.0 s))
import scala.swing._
import java.awt.Color
import javax.swing.ImageIcon
import java.lang.Thread
object Main extends SimpleSwingApplication {
def top = new MainFrame {
title = "Foo"
minimumSize = new Dimension(800, 640)
def stop() {
if (loopThread != null) {
loopThread.stop()
loopThread = null
}
if (loadThread != null) {
loadThread.stop()
loadThread = null
}
package oxnrtr.chat
import collection.mutable.{ArrayBuffer, HashSet, Buffer}
import akka.actor.{ActorRef, Actor}
import akka.event.EventHandler
sealed trait Event
/**Join tells the peer that there is a new peer and requests a list of known peers and messages. */
case class Join(user: String, ipAddress: String) extends Event
package oxnrtr.chat
import collection.mutable.{ArrayBuffer, HashSet}
import akka.actor.Actor
sealed trait Event
/**Join tells the peer that there is a new peer and requests a list of known peers and messages. */
case class Join(user: String, ipAddress: String) extends Event
val myActor = Actor.actorOf(new ChatPeer(localName, localIp)).start()
var abort = false
while (!abort) {
val input = Console.readLine("Send message (or type `:log` for the log): ")
if (input.trim() == ":log")
myActor ! Message(localName, System.currentTimeMillis(), input)
else
(myActor ? GetChatLog).as[ArrayBuffer[Message]].foreach(println)
}
Enter name: soc2
Enter IP adress: 127.0.0.1
Enter port number: 2002
Send message (or type `:log` for the log): Foo
Send message (or type `:log` for the log): :join soc 127.0.0.1 2000
Actor[chat:service:00b6a1b0-fb96-11e0-8f8c-0019d2b208ca]
(05:37:20) soc2: Foo
Send message (or type `:log` for the log): Foo
Send message (or type `:log` for the log): [GENERIC] [21.10.11 05:37] [RemoteClientError(java.net.ConnectException: Connection refused,akka.remote.netty.NettyRemoteSupport@663257b8,/127.0.0.1:2000)]
[GENERIC] [21.10.11 05:37] [RemoteClientError(java.net.ConnectException: Connection refused,akka.remote.netty.NettyRemoteSupport@663257b8,/127.0.0.1:2000)]
object UnitsTest extends App {
import metascala.Units._
val length1 = m(23)
val length2 = m(17)
val area: Area = length1 * length2 // Works, Quantity[_2, _0]
val time = s(42)
val foo: Foo = time * length1 // Works, Quantity[_1, _1]
package metascala.test
object UnitsTest extends App {
import metascala.Units._
val length1 = m(23)
val length2 = m(17)
val area: Area = length1 * length2 // Works, Quantity[_2, _0]
val time = s(42)
package metascala
object Units {
import Integers._
import Addables._
import Subtractables._
trait Unit {
type M <: MInt
type S <: MInt