package com.codesimples.jdbc
import com.typesafe.scalalogging.Logger
import org.springframework.transaction.support.{TransactionCallbackWithoutResult, TransactionTemplate}
import org.springframework.transaction.{PlatformTransactionManager, TransactionStatus}
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
#!/bin/bash | |
mkdir OpenCVInstall | |
cd OpenCVInstall | |
rm -rf last_stable_x264.tar.bz2 | |
rm -rf x264-snapshot-20140930-2245-stable | |
rm -rf ffmpeg-2.4.1.tar.bz2 |
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
case class UserMeasures(state: Map[String,Any]) { | |
def gender : String = { | |
state.getOrElse("usr_genero", "").asInstanceOf[String] | |
} | |
def measures: List[Map[String,Any]] = { | |
state.getOrElse("measures", List[Map[String,Any]]()).asInstanceOf[List[Map[String,Any]]] | |
} |
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
post("/") { | |
contentType = "application/json" | |
authenticated { jsonObject => | |
val entityManager = entityManagerFactory.createEntityManager() | |
val userRepository = new UserRepository(entityManager) | |
val userPersistenceAdapter = new NewUserPersistenceAdapterJPA(userRepository) | |
val usecase = new NewUserUsecase(userPersistenceAdapter) | |
val savedUser = usecase.save( User( jsonObject ) ) |
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.opportunity.simple.restapi.user | |
import com.opportunity.simple.restapi.basic.BasicBehaviour | |
class UserSpec extends BasicBehaviour { | |
"The user endpoint" should { | |
args(sequential=true) | |
"Create new user" ! userEndpointForTest().executeTestCreateNewUser() | |
"Try create a user with same email" ! userEndpointForTest().executeTestTryCreateAUserWithSameEmail() |
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 main(args: Array[String]) { | |
val port = restApiConfig.getInt("port") | |
println(restApiConfig.getString("resourceBase")) | |
val server = new Server(port) | |
val context = new WebAppContext() | |
context setContextPath "/" | |
context.setResourceBase(restApiConfig.getString("resourceBase")) | |
context.setInitParameter(ScalatraListener.LifeCycleKey, "com.opportunity.simple.restapi.ScalatraBootstrap") | |
context.addEventListener(new ScalatraListener) |
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
Code.eval_quoted( | |
quote do: unquote(1) + unquote(1 + 1) | |
) | |
#code to be parsed 1 + (1 + 1) | |
#result of execution {3, []} |
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
/** | |
* https://blog.8thlight.com/uncle-bob/2012/08/13/the-clean-architecture.html | |
* https://vimeo.com/43612849 | |
* https://etorreborre.github.io/specs2/guide/SPECS2-3.7/org.specs2.guide.Matchers.html | |
* | |
**/ | |
package com.opportunity.objectives.usecases.user | |
import com.opportunity.objectives.exceptions.UserInvalidException | |
import com.opportunity.objectives.model.{Friend, User} |
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.opportunity.objectives.usecases.user | |
import com.opportunity.objectives.exceptions.UserInvalidException | |
import com.opportunity.objectives.model.{Friend, User} | |
import com.opportunity.objectives.persistence.adapter.user.NewUserPersistenceAdapter | |
class SaveNewFriendsUsecase(persistenceAdapter: NewUserPersistenceAdapter) { | |
def save(user:User, friends:List[Friend]): User = { | |
persistenceAdapter.findUserById(user.id) match { |
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.opportunity.simple.restapi | |
import javax.persistence.EntityManagerFactory | |
import com.opportunity.objectives.model.User | |
import com.opportunity.objectives.usecases.user.{ListUsersUsecase, LoginByFacebookUserUsecase, SaveNewUserUsecase} | |
import com.opportunity.simple.restapi.response.ProtocolResponse | |
import com.typesafe.config.Config | |
class UserAPI(val apiConfig: Config, val entityManagerFactory: EntityManagerFactory) extends Respondable with Authenticable with PersistibleUser { |