Scala Slick – Omit ID column (Auto_Increment)

Uncategorized
Question: I have learned Scala, Slick, Akka for 2 months and I got a problem when doing a project of Akka... // This case class is to use for parsing data from request // case class UserTransaction(sender: String, recipient: String, amount: Int) //This one is to use for reflecting database case class UserTransactionDB(sender: String, recipient: String, amount: Int, id: Int) class UserTransactionModelDB(tag: Tag) extends Table[UserTransactionDB](tag, "usertransaction") { def id = column[Int]("id", O.PrimaryKey, O.AutoInc) def sender = column[String]("sender") def recipient = column[String]("recipient") def amount = column[Int]("amount") override def * = (sender, recipient, amount, id) (UserTransactionDB.tupled, UserTransactionDB.unapply) } I want to send a POST request (Json) to Akka like this :{"sender" : "S" , "recipient" : "R", "amount" : 100} Now, I want to use just only one case class UserTransaction (without…
Read More

Decimal Degree to Degree script [on hold]

Uncategorized
Question: Hi I am new to python and have some tute problems I am struggling with! I have searched for similar examples and tried using my python book to apply what knowledge I have so far, but I still get stuck! I am looking at trying to convert decimal degree to degree [deg, min, sec] - if someone could help me with the first line, I can try from there, I just need to know where to begin! thanks Answer: Read more
Read More

Visual Studio Code – how to remote debug python code in a Docker Container

Uncategorized
Question: Iam trying to remote dubug python in VSC: It is main.py file:print('Hello, World') debug.py:import ptvsd ptvsd.enable_attach('my_secret', address=('0.0.0.0', 7102)) ptvsd.wait_for_attach() Dockerfile:FROM python:3.6-slim EXPOSE 7102 RUN pip install ptvsd WORKDIR /app COPY . . CMD ["python", "debug.py"] and it is launch.json file:{ "version": "0.2.0", "configurations": [ { "name": "Attach (Remote Debug)", "type": "python", "request": "attach", "localRoot": "${workspaceRoot}", "remoteRoot": "/app", "port": 7102, "secret": "my_secret", "host": "172.17.0.3" } ] } It is a command to build and start container: docker build -t python-for-debug . docker run -it -p 7102:7102 python-for-debug When I run the debugger I get: screen of vs code No any errors at debug console, not output, not problems. No any output for running container. No docker logs VS Code version: 1.15.0 Docker version 17.06.0-ce, build 02c1d87 Answer: The behavior you…
Read More

How can I convert RSA PlblicKey XML to PEM format

Uncategorized
Question: I receive a RSA Key from C# server through httprequest, But so many Encrypt lib need PEM format. I find a solution at this XML to PEM in Node.js But I can't use it in my Javscript H5 Project, Have any other solution? Answer: Your XML seems a propietary format 1znidPBIcMcO7K/53tkTSyKqxlG5Mcws8kVtijS4tyEU4W/FEVWYpOtv+Stnb4Vt AQAB You will need a cryptographic library like forge to build a RSA public key from modulus and exponent. Based on this thread , you can use a code similar to this // parse XML var rsaKeyValue = ... var BigInteger = forge.jsbn.BigInteger; function parseBigInteger(b64) { return new BigInteger(forge.util.createBuffer(forge.util.decode64(b64)).toHex(), 16); } //Create a Forge public key from modulus and exponent var publicKey = forge.pki.setRsaPublicKey( parseBigInteger(rsaKeyValue.Modulus), // n parseBigInteger(rsaKeyValue.Exponent)); // e // convert a Forge public key to PEM-format…
Read More

Trigger guard to re-render component when change url manually via browser

Uncategorized
Question: I setup routing like this { path: ':parent', component: ParentComponent, resolve: { data: ParentResolve }, children: [ { path: ':child', component: ChildComponent, resolve: { data: ChildResolve } } } Everything works normally but when I change my url from /:parent/:child to /:parent. I want to redirect to child route with param get from ParentResolve. My problem: Angular does not call Resolve guard when I change url by hand so I can't redirect to child route. Please ask me if you're not clear, thank you. Answer: The 'resolve' part in router config is handling all of the route fetching before it's been activated. That's mean that it will be called when you are entering this route form any other route and not from it's own children (Because the route is…
Read More