Skip to content

Instantly share code, notes, and snippets.

@mandubian
Forked from playxamplez-admin/CODE
Last active September 30, 2021 20:03

Revisions

  1. mandubian revised this gist Jul 22, 2013. 3 changed files with 32 additions and 19 deletions.
    1 change: 0 additions & 1 deletion CODE
    Original file line number Diff line number Diff line change
    @@ -1 +0,0 @@
    <put your code here & change extension to your language>
    32 changes: 32 additions & 0 deletions CODE.scala
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    import play.api.libs.json._
    import play.api.libs.functional.syntax._

    sealed trait Shape

    case class Circle(c: (Float, Float), r: Float) extends Shape
    object Circle {
    // reader is covariant and can be implicit in inheriting caseclasses
    implicit val reader = Json.reads[Circle]
    // writer is contravariant and can't be implicit in inheriting caseclasses
    val writer = Json.writes[Circle]
    }

    case class Polygon(points: Seq[(Float, Float)]) extends Shape
    object Polygon {
    // reader is covariant and can be implicit in inheriting caseclasses
    implicit val reader = Json.reads[Polygon]
    // writer is contravariant and can't be implicit in inheriting caseclasses
    val writer = Json.writes[Polygon]
    }

    object Shape {
    // Note the map to convert into Shape because we want a Reads[Shape]
    // As we don't have any type indication, we can just use try/fail strategy
    implicit val shapeReads =
    __.read[Rect].map(x => x:Shape) orElse __.read[Circle].map(x => x:Shape)

    implicit val shapeWrites = Writes[Shape]{
    case circle: Circle => Circle.writer.writes(circle)
    case poly: Polygon => Polygon.writer.writes(poly)
    }
    }
    18 changes: 0 additions & 18 deletions _README.md
    Original file line number Diff line number Diff line change
    @@ -1,18 +0,0 @@
    ### [Play-Xamplez](http://play.xamplez.io) Root Gist

    How to create [Play Framework](http://www.playframework.org) code snippets?

    1. Fork this Root Gist to create a new snippet.
    2. Modify your gist according to following rules:
    1. **You MUST put a gist description** which summarizes your snippet as precisely as possible:
    * Words starting with `#` like `#tag` are indexed as hashtags.
    * Words starting with `@` like `@john` are highlighted as Twitter links (You can also precise `@twitter:john` or `@github:john`
    * URL will be highlighted in the description
    2. You can add as many files as you want in your gist
    3. File extensions are used to identify the language (e.g. `code.scala` -> scala)
    4. A code snippet shouldn't be too long (a few lines if possible) so don't hesitate to cut in several files
    5. If you want to explain precisely your code or provide usage examples, please use a Markdown file (e.g. `README.md`)
    6. You can put a License in `__LICENSE.txt` case your code need to be protected in anyway
    7. You can delete `_README.md` and any modification in it isn't taken into account
    3. Save it & wait for [Play Xamplez](http://play.xamplez.io) to index it.

  2. @playxamplez-admin playxamplez-admin revised this gist Jul 21, 2013. 4 changed files with 19 additions and 16 deletions.
    2 changes: 1 addition & 1 deletion CODE
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    <put your code here>
    <put your code here & change extension to your language>
    15 changes: 0 additions & 15 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,15 +0,0 @@
    ### [Play-Xamplez](http://play.xamplez.io) Root Gist

    How to create [Play Framework](http://www.playframework.org) code snippets?

    1. Fork this Root Gist to create a new snippet.
    2. Modify your gist according to following rules:
    * **You MUST put a gist description** which summarizes your snippet as precisely as possible.
    * All words starting in the description with a dash `#tag` are indexed as tags.
    * You can add as many files as you want in your gist
    * File extensions are used to identify the language (e.g. `code.scala` -> scala)
    * A code snippet shouldn't be too big (a few lines if possible) so don't hesitate to cut in several files
    * If you want to explain precisely your code or provide usage examples, please use a Markdown file (e.g. `README.md`)
    * You can put a License in case your code need to be protected in anyway
    3. Save it & wait for [&lt;Put Xamplez Instance URL Here&gt;](http://blablabla.blabla) to index it.

    18 changes: 18 additions & 0 deletions _README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    ### [Play-Xamplez](http://play.xamplez.io) Root Gist

    How to create [Play Framework](http://www.playframework.org) code snippets?

    1. Fork this Root Gist to create a new snippet.
    2. Modify your gist according to following rules:
    1. **You MUST put a gist description** which summarizes your snippet as precisely as possible:
    * Words starting with `#` like `#tag` are indexed as hashtags.
    * Words starting with `@` like `@john` are highlighted as Twitter links (You can also precise `@twitter:john` or `@github:john`
    * URL will be highlighted in the description
    2. You can add as many files as you want in your gist
    3. File extensions are used to identify the language (e.g. `code.scala` -> scala)
    4. A code snippet shouldn't be too long (a few lines if possible) so don't hesitate to cut in several files
    5. If you want to explain precisely your code or provide usage examples, please use a Markdown file (e.g. `README.md`)
    6. You can put a License in `__LICENSE.txt` case your code need to be protected in anyway
    7. You can delete `_README.md` and any modification in it isn't taken into account
    3. Save it & wait for [Play Xamplez](http://play.xamplez.io) to index it.

    File renamed without changes.
  3. @playxamplez-admin playxamplez-admin revised this gist Jul 20, 2013. 1 changed file with 7 additions and 7 deletions.
    14 changes: 7 additions & 7 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -4,12 +4,12 @@ How to create [Play Framework](http://www.playframework.org) code snippets?

    1. Fork this Root Gist to create a new snippet.
    2. Modify your gist according to following rules:
    1. **You MUST put a gist description** which summarizes your snippet as precisely as possible.
    2. All words starting in the description with a dash `#tag` are indexed as tags.
    3. You can add as many files as you want in your gist
    4. File extensions are used to identify the language (e.g. `code.scala` -> scala)
    5. A code snippet shouldn't be too big (a few lines if possible) so don't hesitate to cut in several files
    6. If you want to explain precisely your code or provide usage examples, please use a Markdown file (e.g. `README.md`)
    7. You can put a License in case your code need to be protected in anyway
    * **You MUST put a gist description** which summarizes your snippet as precisely as possible.
    * All words starting in the description with a dash `#tag` are indexed as tags.
    * You can add as many files as you want in your gist
    * File extensions are used to identify the language (e.g. `code.scala` -> scala)
    * A code snippet shouldn't be too big (a few lines if possible) so don't hesitate to cut in several files
    * If you want to explain precisely your code or provide usage examples, please use a Markdown file (e.g. `README.md`)
    * You can put a License in case your code need to be protected in anyway
    3. Save it & wait for [&lt;Put Xamplez Instance URL Here&gt;](http://blablabla.blabla) to index it.

  4. @playxamplez-admin playxamplez-admin revised this gist Jul 20, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ## [Play-Xamplez](http://play.xamplez.io) Root Gist
    ### [Play-Xamplez](http://play.xamplez.io) Root Gist

    How to create [Play Framework](http://www.playframework.org) code snippets?

  5. @playxamplez-admin playxamplez-admin revised this gist Jul 20, 2013. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,6 @@
    ## Play-Xamplez's Root Gist for [Play Framework](http://www.playframework.org) code snippets
    ## [Play-Xamplez](http://play.xamplez.io) Root Gist

    How to?
    ----------
    How to create [Play Framework](http://www.playframework.org) code snippets?

    1. Fork this Root Gist to create a new snippet.
    2. Modify your gist according to following rules:
  6. @playxamplez-admin playxamplez-admin revised this gist Jul 20, 2013. 1 changed file with 2 additions and 4 deletions.
    6 changes: 2 additions & 4 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,6 @@
    # Xamplez's Root Gist
    ## Play-Xamplez's Root Gist for [Play Framework](http://www.playframework.org) code snippets

    This is the Root Gist for `<PUT YOUR TOPIC HERE>` Xamplez's instance

    How to use
    How to?
    ----------

    1. Fork this Root Gist to create a new snippet.
  7. @xamplez-admin xamplez-admin revised this gist Jul 20, 2013. 1 changed file with 9 additions and 12 deletions.
    21 changes: 9 additions & 12 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -6,16 +6,13 @@ How to use
    ----------

    1. Fork this Root Gist to create a new snippet.
    2. Modify your gist according to Rules.
    3. Save it and wait for [&lt;Put Xamplez Instance URL Here&gt;](http://blablabla.blabla) to index it.
    2. Modify your gist according to following rules:
    1. **You MUST put a gist description** which summarizes your snippet as precisely as possible.
    2. All words starting in the description with a dash `#tag` are indexed as tags.
    3. You can add as many files as you want in your gist
    4. File extensions are used to identify the language (e.g. `code.scala` -> scala)
    5. A code snippet shouldn't be too big (a few lines if possible) so don't hesitate to cut in several files
    6. If you want to explain precisely your code or provide usage examples, please use a Markdown file (e.g. `README.md`)
    7. You can put a License in case your code need to be protected in anyway
    3. Save it & wait for [&lt;Put Xamplez Instance URL Here&gt;](http://blablabla.blabla) to index it.

    Rules
    -----

    1. **You MUST put a gist description** which summarizes your snippet as precisely as possible.
    2. All words starting in the description with a dash `#tag` are indexed as tags.
    3. You can add as many files as you want in your gist
    4. File extensions are used to identify the language (e.g. `code.scala` -> scala)
    5. A code snippet shouldn't be too big (a few lines if possible) so don't hesitate to cut in several files
    6. If you want to explain precisely your code or provide usage examples, please use a Markdown file (e.g. `README.md`)
    7. You can put a License in case your code need to be protected in anyway
  8. @xamplez-admin xamplez-admin revised this gist Jul 14, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ How to use

    1. Fork this Root Gist to create a new snippet.
    2. Modify your gist according to Rules.
    3. Save it and wait for [<Put Xamplez Instance URL Here>](http://blablabla.blabla) to index it.
    3. Save it and wait for [&lt;Put Xamplez Instance URL Here&gt;](http://blablabla.blabla) to index it.

    Rules
    -----
  9. @xamplez-admin xamplez-admin revised this gist Jul 14, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,13 @@
    # Xamplez's Root Gist

    This is the Root Gist for `PUT YOUR TOPIC HERE` Xamplez's instance
    This is the Root Gist for `<PUT YOUR TOPIC HERE>` Xamplez's instance

    How to use
    ----------

    1. Fork this Root Gist to create a new snippet.
    2. Modify your gist according to Rules.
    3. Save it and wait for [Put Xamplez Instance URL Here>](http://blablabla.blabla) to index it.
    3. Save it and wait for [<Put Xamplez Instance URL Here>](http://blablabla.blabla) to index it.

    Rules
    -----
  10. @xamplez-admin xamplez-admin revised this gist Jul 14, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,13 @@
    # Xamplez's Root Gist

    This is the Root Gist for <PUT YOUR TOPIC HERE> Xamplez's instance
    This is the Root Gist for `PUT YOUR TOPIC HERE` Xamplez's instance

    How to use
    ----------

    1. Fork this Root Gist to create a new snippet.
    2. Modify your gist according to Rules.
    3. Save it and wait for [<Put Xamplez Instance URL Here>]() to index it.
    3. Save it and wait for [Put Xamplez Instance URL Here>](http://blablabla.blabla) to index it.

    Rules
    -----
  11. @xamplez-admin xamplez-admin revised this gist Jul 14, 2013. 1 changed file with 3 additions and 9 deletions.
    12 changes: 3 additions & 9 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,11 @@
    # Xamplez's Root Gist of the Root Gists
    # Xamplez's Root Gist

    ## Instructions for Xamplez administrators
    When you create a new instance of Xamplez, you must first fork your configuration from the [Lord of the Gists]().
    Then, you create your Root Gist(s) by forking this Root Gist of the Root Gists.
    It just gives a default template that you can modify.
    Finally, make the configuration gist point to this/these Root Gist.

    ## Instructions for Xamplez code snippet creators
    This is the Root Gist for <PUT YOUR TOPIC HERE> Xamplez's instance

    How to use
    ----------

    1. Fork the Root Gist to create a new snippet.
    1. Fork this Root Gist to create a new snippet.
    2. Modify your gist according to Rules.
    3. Save it and wait for [<Put Xamplez Instance URL Here>]() to index it.

  12. @xamplez-admin xamplez-admin created this gist Jul 14, 2013.
    1 change: 1 addition & 0 deletions CODE
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    <put your code here>
    27 changes: 27 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    # Xamplez's Root Gist of the Root Gists

    ## Instructions for Xamplez administrators
    When you create a new instance of Xamplez, you must first fork your configuration from the [Lord of the Gists]().
    Then, you create your Root Gist(s) by forking this Root Gist of the Root Gists.
    It just gives a default template that you can modify.
    Finally, make the configuration gist point to this/these Root Gist.

    ## Instructions for Xamplez code snippet creators

    How to use
    ----------

    1. Fork the Root Gist to create a new snippet.
    2. Modify your gist according to Rules.
    3. Save it and wait for [<Put Xamplez Instance URL Here>]() to index it.

    Rules
    -----

    1. **You MUST put a gist description** which summarizes your snippet as precisely as possible.
    2. All words starting in the description with a dash `#tag` are indexed as tags.
    3. You can add as many files as you want in your gist
    4. File extensions are used to identify the language (e.g. `code.scala` -> scala)
    5. A code snippet shouldn't be too big (a few lines if possible) so don't hesitate to cut in several files
    6. If you want to explain precisely your code or provide usage examples, please use a Markdown file (e.g. `README.md`)
    7. You can put a License in case your code need to be protected in anyway
    13 changes: 13 additions & 0 deletions _LICENSE.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
    Version 2, December 2004

    Copyright (C) 2013 YOUR_NAME_HERE <YOUR_URL_HERE>

    Everyone is permitted to copy and distribute verbatim or modified
    copies of this license document, and changing it is allowed as long
    as the name is changed.

    DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

    0. You just DO WHAT THE FUCK YOU WANT TO.