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
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script> | |
<script src="http://connect.facebook.net/fr_FR/all.js"></script> | |
<script> | |
// Replace the id by any other public page id | |
FB.api('170913076256527/feed', { limit: 3 }, function(result) { | |
$('#fb-feed').empty(); | |
$(result.data).each(function(i, post) { | |
entry = $('<div class="fb-item"></div>'); | |
if (post.icon) { | |
entry.append('<img class="icon" src="' + post.icon + '" />'); |
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 slick.lifted.TupleShape | |
import slick.driver.H2Driver.api._ | |
import scala.concurrent.Await | |
import scala.concurrent.duration.DurationInt | |
import scala.concurrent.ExecutionContext.Implicits.global | |
object Example { | |
val db = Database.forConfig("db") |
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
def show(article: Article) = Action { | |
Ok(views.html.article(article)) | |
} |
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 lambda; | |
public interface JFunction1<T1, R> { | |
R apply(T1 t); | |
} |
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
trait Iterable[A] { | |
// https://github.com/scala/collection-strawman/issues/221 | |
/** | |
* Returns a collection formed by the result of applying a function to each pair of corresponding elements | |
* from this collection and another collection. It is semantically equivalent to `(xs zip ys) map f`. | |
* If one of the two collections is longer than the other, its remaining elements are ignored. | |
*/ | |
def zipWith[B, C](that: Iterable[B])(f: (A, B) => C): Iterable[C] |
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 OK { | |
trait `*`[A] | |
trait Bar { | |
type Qux | |
implicit val `*`: `*`[Qux] | |
} | |
def foo(bar: Bar): `*`[bar.Qux] = { | |
import bar._ |
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 Main extends App { | |
// You can retrieve the application configuration from any place | |
val configuration = Configuration("conf/my-app.conf") | |
// You instantiate your controllers with their required configuration | |
val application = new MyAbstractController(configuration) with SomeEventualMixin | |
// You pass your controllers as parameters to a router factory | |
val router = Router("conf/routes", application) |
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
// Some data type definitions: the usual (and boring) zoo class hierarchy | |
abstract class Animal { } | |
abstract class Mammal extends Animal { } | |
class Giraffe extends Mammal { } | |
class Zebra extends Mammal { | |
num stripeCount; | |
Zebra(num stripeCount) { |
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 Ok { | |
trait Foo[A] | |
case class Bar(x: Int) | |
object Bar { | |
implicit class BarOps(bar: Foo[Bar]) { | |
val ok = "ok" | |
} | |
} | |
def usage(bar: Foo[Bar]) = bar.ok // Ok, the implicit conversion is found in the Bar companion object |
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
/** | |
* data (f :+: g) a = Inl (f a) | Inr (g a) | |
*/ | |
sealed trait Coproduct[F[+_], G[+_], A] | |
case class Inl[F[+_], G[+_], A](a: F[A]) extends Coproduct[F, G, A] | |
case class Inr[F[+_], G[+_], A](a: G[A]) extends Coproduct[F, G, A] | |
trait :+:[F[+_], G[+_]] { | |
type Apply[A] = Coproduct[F, G, A] | |
} |
NewerOlder