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 seq = Seq(1, 2, 3, 4, 5) | |
val res0 = seq.foldLeft(0)(_ + _) | |
val res1 = seq./:(0)(_ + _) // (seq /:) (0)(_ + _) | |
assert(res0 == res1) |
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
bookingDao.findById(bookingId).flatMap { | |
case \/-(booking) if booking.professionalId != userProfileId => | |
-\/(Unauthorized).future | |
case success@ \/-(booking) if pendingStatuses.contains(booking.stateInfo.status) => | |
success.future | |
case \/-(booking) => | |
makeBookingData(userContext.deviceType, Booking.clientId)(booking).flatMapDisjunction { bookingData => -\/(Conflict(bookingData)) } | |
case s => | |
s.future | |
} |
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
/** | |
* @author Alexander Krasniansky | |
*/ | |
object RangeTest extends App { | |
import com.github.nscala_time.time.Imports._ | |
case class Event( | |
name : String, | |
startTime: DateTime, |
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 akka.actor._ | |
object Main extends App { | |
val system = ActorSystem("mySystem") | |
val input = system.actorOf(Props[Input]) | |
val output = system.actorOf(Props[Output]) | |
val state = system.actorOf(Props(classOf[State], input, output)) | |
class Output extends Actor { |
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 CodeCollisionService { | |
type CodeCollisionFunc = (String, Int) => Seq[Double] | |
def calculateCollision: CodeCollisionFunc | |
} | |
object CodeCollisionService extends CodeCollisionService { | |
import il.finkel.spark.CodeCollisionService.{ | |
CodeCollisionFunc => <%> | |
} |
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 <A extends B, B> void foo(A a, B b) { | |
b = a; | |
} |
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
function findPrime(array) { | |
var sieve = [], i, j, max = 1000000; | |
for (i = 2; i <= max; ++i) { | |
if (!sieve[i]) { | |
var parsed = ('' + i).split('').map(function (e) { | |
return parseInt(e, 10); | |
}); | |
if (JSON.stringify(parsed) === JSON.stringify(array)) { | |
return i; | |
} |
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 TimestampMap<V> extends HashMap<Timestamp, V> { | |
public static <T> TimestampMap<T> of(T... ts) { | |
return new TimestampMap<T>() { | |
@Override | |
public T put(Timestamp k, T v) { | |
for (T t : ts) { | |
this.put(now(), t); // potential SO (!) + useless initialization | will super.* fix the SO error? | |
} | |
return null; |
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
class User | |
object User { | |
type Aux[I, A] = User { | |
type IdType = I | |
type Address = A | |
} | |
} |
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 int foo(int v) { | |
int counter = 0; | |
switch (v) { | |
default: counter += 1; | |
case 1: counter += 2; | |
case 2: counter += 3; | |
} | |
return counter; | |
} |