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 com.spinoco.dojo | |
import scalaz.concurrent.Task | |
import scalaz.stream.{ process1, Process } | |
import Process._ | |
import scala.concurrent.duration._ | |
import scalaz.stream.io | |
/* | |
Time to put it all together. |
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 com.spinoco.dojo | |
import scalaz.stream.Process | |
import Process._ | |
import scalaz.concurrent.Task | |
import scala.util.Random | |
object Dojo extends Dojo | |
trait Dojo { |
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
private static final FormMapping<Registration> registrationForm = | |
Forms.automatic(Registration.class, "registration") | |
.nested(Forms.automatic(Address.class, "contactAddress", | |
Forms.factoryMethod(Address.class, "getInstance")).build()) | |
.build(); |
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
private static final FormMapping<RegDate> regDateMapping = | |
Forms.basic(RegDate.class, "regDate").fields("month", "year").build(); | |
private static final FormMapping<Registration> registrationForm = | |
Forms.basic(Registration.class, "registration") | |
// whitelist of properties to bind | |
.fields("attendanceReasons", "cv", "interests", "email") | |
.nested(Forms.automatic(UploadedFileWrapper.class, "certificates", | |
null, MappingType.LIST).build()) | |
.nested(Forms.basic(Address.class, "contactAddress", | |
Forms.factoryMethod(Address.class, "getInstance")) |
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
private static final FormMapping<Person> personForm = | |
Forms.automatic(Person.class, "person").build(); | |
… | |
FormData<Person> formData = new FormData<Person>(person, null); | |
FormMapping<Person> filledForm = personForm.fill(formData); | |
// push filledForm to template … | |
… | |
FormData<Person> formData = personForm.bind( | |
new HttpServletRequestParams(request)); | |
if (formData.isValid()) { |
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
/** | |
* Dumps (possibly large) database table to SQL file or more files | |
* according to MaxRecordsPerFile parameter. | |
* @author Radek Beran | |
*/ | |
import java.io._ | |
import java.sql._ | |
// --- SCRIPT PARAMETERS --- | |
val DriverName = "com.mysql.jdbc.Driver" |
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
val parSeq: ParSeq[Int] = List(3, 4, 5).par |
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
(for { | |
m <- models.view // vytvoří non-strict view pamatující si lazy vykonávané operace | |
if m.carMaker == CarMaker.Porsche | |
price <- m.price // transformace na kolekci obsahující ceny | |
} yield price).sum |
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
val parSeq: ParSeq[Int] = List(3, 4, 5).par |
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
// Posčítání cen automobilů, jejichž výrobcem je Porsche: | |
case class CarModel(carMaker: CarMaker.Value, name: String, price: Option[Int]) | |
val models: List[CarModel] = List(...) | |
models.view.filter(_.carMaker == CarMaker.Porsche).map(_.price.getOrElse(0)).sum |
OlderNewer