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
/* | |
* The MIT License (MIT) | |
* | |
* Copyright (c) 2013 Association du Paris Java User Group. | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy of | |
* this software and associated documentation files (the "Software"), to deal in | |
* the Software without restriction, including without limitation the rights to | |
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | |
* the Software, and to permit persons to whom the Software is furnished to do so, |
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
// Enum type based on Sum types (OR) | |
trait ADTEnum[A] { | |
import play.api.data.mapping.json.Writes._ | |
import play.api.data.mapping.json.Rules._ | |
val list: Seq[A] | |
def withName(name: String): Option[A] = { | |
list.find(_.toString.toLowerCase == name.toLowerCase) | |
} |
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 models | |
import scalaz._ | |
import Scalaz._ | |
import anorm._ | |
import org.postgresql.util.PGobject | |
import org.postgresql.jdbc4.Jdbc4Array | |
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
// --- Definition of a query string binder for type A using a Mapping[A] | |
object Binders { | |
implicit def mappingBinder[A](implicit mapping: Mapping[A]) = new QueryStringBindable[A] { | |
override def bind(key: String, params: Map[String, Seq[String]]): Option[Either[String, A]] = { | |
val data = for { | |
(k, ps) <- params | |
if k startsWith key | |
p <- ps.headOption | |
} yield (k.drop(key.length + 1), p) |
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 service | |
import play.api._ | |
import securesocial.core._ | |
import securesocial.core.providers.Token | |
import securesocial.core.UserId | |
import models._ | |
class SlickUserService(application: Application) extends UserServicePlugin(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
import play.api.libs.json._ | |
import play.api.data.validation._ | |
import play.api.libs.functional.syntax._ | |
val json = Json.obj( | |
"name" -> "John", | |
"email" -> "john.doe@company.com", | |
"password" -> "password", | |
"confirmPassword" -> "password" | |
) |
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
/** | |
* CloudExtension and factory for creating CloudExtension instances. | |
* Example: | |
* {{{ | |
* val application = CloudExtension(system, config) | |
* }}} | |
* | |
* @author Helena Edelson | |
*/ | |
object CloudExtension extends ExtensionId[CloudExtension] with ExtensionIdProvider { |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<profile><name>Default</name><language>java</language><rules><rule><repositoryKey>squid</repositoryKey><key>S1223</key><priority>MAJOR</priority></rule><rule><repositoryKey>squid</repositoryKey><key>S1318</key><priority>CRITICAL</priority></rule><rule><repositoryKey>squid</repositoryKey><key>S1312</key><priority>MAJOR</priority><parameters><parameter><key>format</key><value>LOG(?:GER)?</value></parameter></parameters></rule><rule><repositoryKey>squid</repositoryKey><key>S1319</key><priority>MAJOR</priority></rule><rule><repositoryKey>squid</repositoryKey><key>S1231</key><priority>MINOR</priority></rule><rule><repositoryKey>pmd</repositoryKey><key>CompareObjectsWithEquals</key><priority>MAJOR</priority></rule><rule><repositoryKey>squid</repositoryKey><key>S1217</key><priority>CRITICAL</priority></rule><rule><repositoryKey>squid</repositoryKey><key>S1219</key><priority>CRITICAL</priority></rule><rule><repositoryKey>squid</repositoryKey><key>S1210</key><priority>CRITICAL</p |
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 javax.crypto.spec.SecretKeySpec | |
import javax.crypto.Mac | |
object A { | |
def main(args: Array[String]): Unit = { | |
val secret = new SecretKeySpec("the_secret".getBytes, "HmacSHA1") | |
val mac = Mac.getInstance("HmacSHA1") | |
mac.init(secret) | |
val result: Array[Byte] = mac.doFinal("foo".getBytes) | |
println(result.map(_.toString).mkString(",")) |
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
// Create a session | |
s := session.New(aws.NewConfig().WithRegion("us-west-2")) | |
// Add a handler to print every API request for the session | |
s.Handlers.Send.PushFront(func(r *request.Request) { | |
fmt.Printf("Request: %s/%s\n", r.ClientInfo.ServiceName, r.Operation) | |
}) | |
// We want to start all instances in a VPC, so let's get their IDs first. | |
ec2client := ec2.New(s) | |
var instanceIDsToStart []*string | |
describeInstancesInput := &ec2.DescribeInstancesInput{ |
OlderNewer