This file contains 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
test("easy test") { | |
val urlCal = new URL("https://www.google.com/calendar/ical/u74t" + | |
"b1k9n53bnc5qsg3694p2l4%40group.calendar.google.com/private-4b" + | |
"4d566cd18fd63d76c6cc6ea84086cf/basic.ics") | |
val builder = new CalendarBuilder(); | |
val cal = builder.build(urlCal.openStream()); | |
val components: ComponentList = cal.getComponents(Component.VEVENT) | |
This file contains 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 SingleEvent { | |
private final Tupple<KeyType, String> basicatId; | |
private final Tupple<EventType, String> eventId; | |
private final String xmlData; | |
private final Boolean acquitted; | |
private SingleEvent( final Tupple<KeyType, String> basicatId, final Tupple<EventType, String> eventId, final String xmlData, final Boolean acquitted ) { | |
this.basicatId = basicatId; | |
this.eventId = eventId; | |
this.xmlData = xmlData; |
This file contains 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
http://www.fotopedia.com | |
# MONGO | |
casbah official scala driver | |
dsl que requete sympa | |
mais pas sympa pour travailler sur les objets récupérés DBObject = Option[String] ou d'autres trucs | |
salat DRM document relationel model | |
map to immutable case class only | |
mapping - grating ?? grater[Picture].asObject(pictureCasbahObject) |
This file contains 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
/** | |
* Exercise 1 | |
*/ | |
def pascal(c: Int, r: Int): Int = { | |
if (c == 0 || c == r) 1 // si r == c alors la décomposition en dessous tombe forcement sur pascal(c>r) et c'est impossible | |
else pascal(c - 1, r - 1) + pascal(c, r - 1) | |
} | |
/** | |
* Exercise 2 |
This file contains 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 MyApp extends App { | |
case class Bag[+A](value: A) { // covariance | |
//override def toString = "toto" | |
//def copy | |
//equals | |
//hashcode | |
// + elem de Product | |
// functor dans la théorie des catégories | |
def map[B](f: A => B): Bag[B] = Bag(f(value)) |
This file contains 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
implicit val venueReader: Reads[Venue] = ( | |
(__ \ "address").readNullable[String] and | |
(__ \ "address_2").readNullable[String] and | |
(__ \ "city").readNullable[String] and | |
(__ \ "region").readNullable[String] and | |
(__ \ "country").readNullable[String] and | |
(__ \ "postal_code").readNullable[String] | |
)(Venue) | |
implicit val eventbriteEventReader: Reads[EventbriteEvent] = |
This file contains 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 scalawebapp | |
import com.sun.net.httpserver.{HttpExchange, HttpHandler, HttpServer} | |
import java.net.InetSocketAddress | |
import scala.concurrent.Future | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import scala.util.{Failure, Success} | |
class MyHttpServer(port: Int = 8080) { |
This file contains 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 scala.concurrent.duration._ | |
trait DurationTestTools { | |
implicit def duration2DurationCompare(duration: Duration): DurationCompare = DurationCompare(duration) | |
case class DurationCompare(duration: Duration) { | |
def shouldBeMinusThan(expectedDuration: Duration) { assert(duration.compare(expectedDuration) < 0, s"$duration was not minus than $expectedDuration") } | |
def shouldBeMinusOrEqualThan(expectedDuration: Duration) { assert(duration.compare(expectedDuration) <= 0, s"$duration was not minus or equal than $expectedDuration") } | |
def shouldBeGreaterThan(expectedDuration: Duration) { assert(duration.compare(expectedDuration) > 0, s"$duration was not greater than $expectedDuration") } | |
def shouldBeGreaterOrEqualThan(expectedDuration: Duration) { assert(duration.compare(expectedDuration) >= 0, s"$duration was not greater or equal than $expectedDuration") } |
This file contains 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 concurrent.Await | |
import akka.pattern.gracefulStop | |
import akka.actor.ActorSystem | |
trait ActorTestingTools { | |
def closeDummyActors(actorsName: String*)(implicit system: ActorSystem) { | |
import scala.concurrent.duration._ | |
actorsName.map( actorName => gracefulStop(system.actorFor(system / actorName), 1 seconds) ) | |
.map( Await.result(_, 1 seconds) ) |
This file contains 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 AClassUsingActor(myClass: MyClass) { | |
def useActor = myClass.ref ! message | |
} | |
object CreateActorClass { | |
val system = ActorSystem("system") | |
val classUsingActor = new AClassUsingActor(new MyClass(system)) | |
classUsingActor.useActor | |
} |
OlderNewer