// Lambda's / delegates in different languages
##Java < 8
Adder adder = new Adder(){
@Override
public int add(int a, int b){
return a + b;
}
})
import akka.actor.IO._ | |
import akka.actor.{Props, IO, IOManager, Actor, ActorSystem} | |
import akka.event.Logging | |
import akka.util.ByteString | |
import java.net.InetSocketAddress | |
class TCPEchoServer(port: Int) extends Actor { | |
val log = Logging(context.system, this) | |
val state = IterateeRef.Map.async[IO.Handle]()(context.dispatcher) |
commit = (cb) -> exec "git commit -am 'auto-v#{pkg.version}'", cb | |
upgrade = (cb) -> exec "npm version patch", cb | |
build = (cb) -> exec "cordova build", cb | |
copy = (cb) -> exec "cp ./platforms/android/ant-build/LDWorkorder-debug.apk ./#{dir}/#{pkg.name}-#{pkg.version}.apk", cb | |
commit -> upgrade -> build -> copy -> done |
import javax.sound.sampled.ReverbType | |
import Cell.Percent | |
import scala.util.Random | |
trait Revealable { | |
var caster: Option[Cell] = None | |
def reveal()(implicit isBomb : Boolean, bombCount : Int) | |
def subscribe(caster:Cell): Unit ={ |
package services | |
import reactivemongo.bson.BSONObjectID | |
// Not unused at all. Do not delete | |
import play.modules.reactivemongo.json.BSONFormats._ | |
object JsonFormats { | |
import play.api.libs.json.Json |
db.getAllRemembered(function (err, remembered){ | |
db.getDriversCount(function (err, driversCount) { | |
db.getFreeDriversCount(function (err, freeDriversCount) { | |
db.getFinishedRidesCount(function (err, finishedRidesCount) { | |
db.getRides(function (err, rides) { | |
db.getMessages(0,-1,function (err, messages) { | |
db.getHeat(function (err, heat) { | |
var arr = []; | |
for (var driverId in rides) { | |
var driver = driver_list.getDriver(driverId); |
object Helpers { | |
def time[R](block: => R): (R, Long) = { | |
val t0 = System.nanoTime() | |
val result = block // call-by-name | |
val t1 = System.nanoTime() | |
(result, t1 - t0) | |
} | |
} | |
case class Memoize[-T , +R : ClassTag](duration : Duration, refreshOnGet : Boolean = false)(f: T => R) | |
(implicit app : Application) extends (T => R) { |
object Helpers { | |
def time[R](block: => R): (R, Long) = { | |
val t0 = System.nanoTime() | |
val result = block // call-by-name | |
val t1 = System.nanoTime() | |
(result, t1 - t0) | |
} | |
} | |
case class Memoize[-T , +R : ClassTag](duration : Duration, refreshOnGet : Boolean = false)(f: T => R) | |
(implicit app : Application) extends (T => R) { |
val x = 10 | |
val k = 2 | |
val iloscKul = 3 | |
var suma = 0.0 | |
var mnożnik = 1000 | |
do { | |
suma = k*mnożnik * (1- Math.pow(2,iloscKul)) / (-1) | |
mnożnik/=2 | |
} while(suma > x*1000) |
// Lambda's / delegates in different languages
##Java < 8
Adder adder = new Adder(){
@Override
public int add(int a, int b){
return a + b;
}
})
final Vibrator v = (Vibrator) MainActivity.getInstance().getSystemService(Context.VIBRATOR_SERVICE); | |
new Thread(new Runnable() { | |
@Override | |
public void run() { | |
while(true) { | |
v.vibrate(100); | |
try { | |
Thread.sleep(1000); | |
} catch (InterruptedException e) { | |
e.printStackTrace(); |