Skip to content

Instantly share code, notes, and snippets.

View piercelamb's full-sized avatar

Pierce Lamb piercelamb

View GitHub Profile
package models
import org.mindrot.jbcrypt.BCrypt
import scalikejdbc._
case class Account(id: Int, email: String, password: String, name: String, role: Role)
case class newAccount(email: String, password: String, firstName: String, role: String)
object Account extends SQLSyntaxSupport[Account] {
def addAccount(title: String, name: String) = StackAction(AuthorityKey -> Administrator) { implicit request =>
val user = loggedIn
accountForm.bindFromRequest.fold(
formWithErrors => BadRequest(html.Admin.landing.create(formWithErrors, title, name)),
newAccount => {
val id = addNewAccount(newAccount.email, newAccount.password, newAccount.firstName, Role.valueOf(newAccount.role))
Redirect(controllers.auth.routes.Landing.createUser(name)).flashing("success" -> "Account %s has been created".format(newAccount.firstName))
}
)
}
@(form: Form[newAccount], title: String, name: String)(implicit flash: play.api.mvc.Flash)
@views.html.Admin.fullTemplate(name, title) {
<main>
<section class="hero create">
<div class="container">
<h1>Create User</h1>
<p>"Administrator" or "NormalUser"</p>
@piercelamb
piercelamb / in
Last active September 7, 2016 20:48
in root/app/binders.scala:
package binders
import controllers.CloudData
import play.api.mvc.QueryStringBindable
/**
* Created by plamb on 9/7/16.
*/
//case class CloudData(clusterName: String, keyPair: String, instance: String, storage: String, volumeSize: Int)
import net.ruippeixotog.scalascraper.browser.HtmlUnitBrowser
/**
* Created by plamb on 9/16/16.
*/
class HtmlUnitBrowserFactory{
}
val csvDF = snContext.read
.format("com.databricks.spark.csv") // Custom data source which can read from a CSV file
.option("header", "true") // Use first line of all files as header
.option("inferSchema", "true") // Automatically infer data types
.load("filePath")
snappyContext.createTable(rowTable, "row", csvDF.schema, Map.empty[String, String])
snappyContext.sql("CREATE TABLE PR_TABLE1(OrderId INT NOT NULL,description String, OrderRef INT)" +
"USING row " +
"options " +
"(" +
"PARTITION_BY 'OrderId, OrderRef',"+
"BUCKETS '113')")
snappyContext.sql("CREATE TABLE PR_TABLE2(OrderId INT NOT NULL,description String, OrderRef INT)" +
"USING row " +
"options " +
"(" +
"PARTITION_BY 'OrderId,OrderRef',"+
"BUCKETS '113')")
snappyContext.sql(s"select P.OrderRef, P.description from " +
s"PR_TABLE1 P JOIN PR_TABLE2 R ON P.OrderId = R.OrderId AND P.OrderRef = R.OrderRef")