Skip to content

Instantly share code, notes, and snippets.

@lazyval
lazyval / .gitignore
Last active August 29, 2015 14:01
uaagent compilation issues
# SBT
boot/
lib_managed/
target/
.history
# Eclipse
.cache
.classpath
.project
@lazyval
lazyval / JavaApi.java
Last active August 29, 2015 14:01
toLong for java string
package com.github.lazyval;
public class JavaApi {
public static String foo() {
return "123";
}
}
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._
@lazyval
lazyval / assignment.txt
Created November 21, 2013 18:08
epidemy
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
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()
@lazyval
lazyval / rotating_file.py
Created June 28, 2013 11:47
Rotating file implementation for python. I'm ignoring any error handling and proper closing here
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
// 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
@lazyval
lazyval / gist:5203258
Created March 20, 2013 08:57
JVM types are ZBSCIJFDL
JVM types are ZBSCIJFDL
@lazyval
lazyval / README.md
Last active December 15, 2015 01:39
UK postcodes to geo coordinates
@lazyval
lazyval / ant.rb
Last active December 14, 2015 20:29
Homebrew formula for ant 1.9.0
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['*']