This file contains hidden or 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.{DatagramPacket, InetAddress, MulticastSocket, SocketTimeoutException} | |
| import java.lang.{Runnable, Thread} | |
| object TestUdpServer { | |
| class UdpServer(val address: String, val port: Int, val info: String) { | |
| val socket = new MulticastSocket(port) | |
| val multicastAddressGroup = InetAddress.getByName(address) | |
| socket.joinGroup(multicastAddressGroup) | |
| def execute: Unit = { |
This file contains hidden or 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.{DatagramPacket, InetAddress, MulticastSocket, SocketTimeoutException, ServerSocket, InetSocketAddress, Socket} | |
| import java.io.{InputStreamReader, BufferedReader} | |
| import java.util.{Timer, TimerTask, List, ArrayList, Date} | |
| object TestMulticastClient { | |
| class MulticastClient(val address: String, val port: Int) { | |
| private val socket = new MulticastSocket(port) | |
| private val group = InetAddress.getByName(address) | |
| socket.joinGroup(group) |
This file contains hidden or 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.{DatagramPacket, InetAddress, MulticastSocket, SocketTimeoutException, ServerSocket, InetSocketAddress, Socket} | |
| import java.io.{BufferedReader, OutputStreamWriter} | |
| import java.lang.{Runnable, Thread} | |
| object TestMulticastServer { | |
| class MulticastServer(val address: String, val port: Int) { | |
| val socket = new MulticastSocket(port) | |
| val multicastAddressGroup = InetAddress.getByName(address) | |
| socket.joinGroup(multicastAddressGroup) | |
| val serverSocket = new ServerSocket() |
This file contains hidden or 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
| object Wrappers { | |
| private class ElvisWrapper[T](alt: T){ | |
| def ?:[A >: T](pred: A) = if (pred == null) alt else pred | |
| } | |
| implicit def elvisOperator[T](alt: => T) = new ElvisWrapper(alt) | |
| } |
This file contains hidden or 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 WordState { | |
| def +(other: WordState): WordState | |
| def maybeWord(s: String) = if(s.isEmpty) List() else List(s) | |
| def processChar(c: Char): WordState = if(c == ' ') Segment("",List(),"") else Chunk(c.toString) | |
| def words(s: String) = { | |
| val l = s.toList | |
| l.map(c => processChar(c)).reduceLeft(_ + _) match { | |
| case Chunk(s) => maybeWord(s) | |
| case Segment(left, a, right) => maybeWord(left) ++ a ++ maybeWord(right) |
This file contains hidden or 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 Test { | |
| @Test | |
| public void shouldIncreaseSizeWhenAddingNewElement() throws Exception { | |
| // Arrange | |
| final ArrayList list = new ArrayList(); | |
| // Act | |
| list.add("one"); |
This file contains hidden or 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 ScannerTest { | |
| @Test | |
| public void shouldDisplayThePriceUsingTaxes() { | |
| Display display = mock(Display.class); | |
| Calculator calculator = mock(Calculator.class); | |
| Repository repository = mock(Repository.class); | |
| when(calculator.calculate("$100")).thenReturn("$119"); | |
| when(repository.getProductPrice("ABC123")).thenReturn("$100"); | |
| Scanner scanner = new Scanner(repository, calculator, display); | |
This file contains hidden or 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
| dyld: Library not loaded: /Users/alin/usr/local/homebrew/Cellar/glib/2.24.2/lib/libglib-2.0.0.dylib | |
| Referenced from: /Users/alin/usr/local/homebrew/Cellar/gettext/0.18.1.1/bin/msgfmt | |
| Reason: image not found | |
| /bin/sh: line 1: 20373 Trace/BPT trap /Users/alin/usr/local/homebrew/Cellar/gettext/0.18.1.1/bin/msgfmt -o test.mo ./de.po | |
| CCLD io-stream | |
| cp: test.mo: No such file or directory | |
| make[4]: *** [test.mo] Error 1 | |
| make[4]: *** Waiting for unfinished jobs.... | |
| make[3]: *** [all-recursive] Error 1 | |
| make[2]: *** [all] Error 2 |
This file contains hidden or 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
| You can install Homebrew anywhere you want, but some brews may only work | |
| correctly if you install to /usr/local. |
This file contains hidden or 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
| [color] | |
| branch = auto | |
| diff = auto | |
| status = auto | |
| [color "branch"] | |
| current = yellow reverse | |
| local = yellow | |
| remote = green | |
| [color "diff"] | |
| meta = yellow bold |