This gist contains data taken from http://www.doogal.co.uk/UKPostcodes.php in case it wouldn't be accessible latter. Gist was referenced from here: http://stackoverflow.com/q/15460607/298389
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
# SBT | |
boot/ | |
lib_managed/ | |
target/ | |
.history | |
# Eclipse | |
.cache | |
.classpath | |
.project |
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
package com.github.lazyval; | |
public class JavaApi { | |
public static String foo() { | |
return "123"; | |
} | |
} |
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
package kafka.perf | |
import java.util.concurrent.{CountDownLatch, Executors} | |
import java.util.concurrent.atomic.AtomicLong | |
import kafka.producer._ | |
import org.apache.log4j.Logger | |
import kafka.message.{CompressionCodec, Message} | |
import java.text.SimpleDateFormat | |
import kafka.serializer._ | |
import java.util._ |
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
Epidemy Simulation | |
In this part, you are going to write an epidemy simulator based on the simulation framework seen in lecture and used in the circuit simulation. | |
The scenario is as follows: the world (“Scalia”) consists of regular grid of 64 rooms (8x8) where each room is connected to four neighbouring rooms. Each room may contain an arbitrary number of persons. Scaliosis – a vicious killer virus – rages with a prevalence rate of 1% among the peaceful population of Scalia. It spreads with a transmissibility rate of 40%. By prevalence rate, we mean that a certain portion of the population is infected to begin with. The transmissibility rate refers to the probability of one person to be infected. | |
In the beginning, 300 people are equally distributed among the rooms. Each step of the simulation corresponds to one simulated day. The disease and behaviour of people is simulated according to the following rules. | |
Rules | |
After each move (and also after the beginning of the simulation), a person moves to one of thei |
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
val l1 = LinkedList(1) | |
l1.append(LinkedList(7)) | |
l1 | |
// res14: scala.collection.mutable.LinkedList[Int] = LinkedList(1, 7) | |
val l0 = LinkedList[Int]() | |
l0.append(LinkedList(7)) | |
l0 | |
// res16: scala.collection.mutable.LinkedList[Int] = LinkedList() |
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 os | |
import os.path | |
buffer_in_bytes = 10 * 100 * 100 | |
class RotatingFile: | |
def __init__(self, filename, max_files, lines_per_file): | |
self.file = open(filename, mode='w', buffering=buffer_in_bytes) | |
self.filename = filename | |
self.max_files = max_files |
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
// it's good style to mark such objects/classes with sealed to guide complier | |
// so it will check if match is exhaustive (all possible cases covered) | |
sealed abstract class Response | |
sealed abstract class Reason | |
abstract class TokenType | |
case class Token(t: TokenType) extends Response | |
case class Problem(reason: Reason) extends Response | |
case object InvalidResponse extends Reason |
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
JVM types are ZBSCIJFDL |
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
require 'formula' | |
class Ant < Formula | |
homepage 'http://ant.apache.org/' | |
url 'http://www.apache.org/dyn/closer.cgi?path=ant/binaries/apache-ant-1.9.0-bin.tar.gz' | |
sha1 '791418e7e80e3f28d6347528e8992a14f09058e7' | |
def install | |
rm Dir['bin/*.{bat,cmd,dll,exe}'] | |
libexec.install Dir['*'] |