Skip to content

Instantly share code, notes, and snippets.

View patientplatypus's full-sized avatar

patientplatypus patientplatypus

View GitHub Profile
case class QuoteArticleBlogDummy(var article_id: Int=0, var blog_id: Int=0,var linktable_blog_id: Int=0,var linktable_id: Int=0)
object QuoteArticleBlogDummy{
implicit var QuoteArticleBlogDummyWrites = new Writes[QuoteArticleBlogDummy] {
def writes(response: QuoteArticleBlogDummy) = {
Json.obj(
"article_id"-> response.article_id,
"blog_id" -> response.blog_id,
"linktable_blog_id" -> response.linktable_blog_id,
"linktable_id" -> response.linktable_id
)
//I have the following code
val password_hash_db = Future{
database.db.withConnection { implicit connection =>
SQL("SELECT * FROM user WHERE username = {username}").on("username"->newAdmin.username)
// .as(SqlParser.str("user.password_hash").single)
}
}(ec)
//when the `.as` statement is included I get the following error:
//I have the following scala code that I'm trying to use an onComplete to unwrap (to access the option)
//it seems to be the way you're supposed to do it but I keep getting a type mismatch error
//What is the proper way to access the id after writing the SQL?
[error] /Users/patientplatypus/Documents/platypusNEST/blog_scala_play/blog/app/models/Commands.scala:44:16: constructor cannot be instantiated to expected type;
[error] found : anorm.Success[A]
[error] required: scala.util.Try[Option[Long]]
[error] case Success(e) => println("inside success")
[error] ^
//this is borked
//specifically this.state.wasm.handle_mouse_down_stroke is getting back a Uint8ClampedArray which I can console.log
//unfortunately adding this data to canvas using
let newWASMclamped = Uint8ClampedArray.from(newWASM);
var imgData = new ImageData(newWASMclamped, this.canvasRefWASM.current.width, this.canvasRefWASM.current.height)
this.ctxWASM.putImageData(imgData, 0, 0);
//isnt working.
//on the other hand the this.state.wasm.handle_mouse_down_spray function *is* working.
//why?
context.state.navBarHeight: 34 3.chunk.js:843:15
INSIDE HANDLE_MOUSE_DOWN 5.chunk.js:248:11
inside handle_mouse_down and x: 615, and y: 572 5.chunk.js:248:11
1 5.chunk.js:248:11
2 5.chunk.js:248:11
3 5.chunk.js:248:11
4 5.chunk.js:248:11
5 5.chunk.js:248:11
6 5.chunk.js:248:11
7 5.chunk.js:248:11
context.state.navBarHeight: 34 2 3.chunk.js:843:15
INSIDE HANDLE_MOUSE_DOWN 5.chunk.js:248:11
inside handle_mouse_down and x: 396, and y: 492 5.chunk.js:248:11
1 5.chunk.js:248:11
2 5.chunk.js:248:11
3 5.chunk.js:248:11
4 5.chunk.js:248:11
5 5.chunk.js:248:11
guard_var has been dropped~ 5.chunk.js:248:11
value of newWasm:
mouseDown = () => {
let tryFunc = (x, y) => {
try{
let newWASM = this.state.wasm.handle_mouse_down(
this.state.sprayImg.width,
this.state.sprayImg.height,
this.canvasRefWASM.current.width,
this.canvasRefWASM.current.height,
x,
y,
//the following does not work and i have no idea why
//the error i get is:
//there was an error: RuntimeError: "unreachable executed"
// handle_mouse_down http://localhost:3000/static/js/5.chunk.js:139
// mouseDown http://localhost:3000/static/js/3.chunk.js:1207
// mouseMove http://localhost:3000/static/js/3.chunk.js:1222
//3.chunk.js:1210:17
mouseDown = (event) => {
var mousePosition = {x: 0, y: 0};
let rect = this.canvasRefWASM.current.getBoundingClientRect()
const ctx = this.canvasRefWASM.current.getContext('2d');
mousePosition.x = event.clientX - rect.left;
mousePosition.y = event.clientY - rect.top;
this.dragArray.push(mousePosition);
const update = () => {
//send image to WASM, get back frame and update WASMcanvas
if(this.dragArray.length>0){
//I have the following in React that responds to a mousedown event.
//Unfortunately I don't know how to use requestAnimationFrame on this as I want to update the whole canvas
//and use putImageData from a WASM file.
//does anyone have any ideas?
mouseDown = (event) => {
var mousePosition = {x: 0, y: 0};
let rect = this.canvasRefWASM.current.getBoundingClientRect()
const ctx = this.canvasRefWASM.current.getContext('2d');
mousePosition.x = event.clientX - rect.left;