Scala.js – Referring to non-existent class
By admin | September 9, 2021
Referring to non-existent class MyClass$ called from JSClass$.jsMethod()void called from JSClass$.$js$exported$meth$jsMethod()java.lang.Object exported to JavaScript with @JSExport involving instantiated classes: JSClass$ exported to JavaScript with @JSExport Cannot access module for non-module MyClass$ called from JSClass$.jsMethod()void called from JSClass$.$js$exported$meth$jsMethod()java.lang.Object exported to JavaScript with @JSExport involving instantiated classes: JSClass$ exported to JavaScript with @JSExport
Related issue: https://github.com/scala-js/scala-js/issues/629
If the issue is coming from a shared module being used in both a Scala.js and JVM setting, the issue may be that the shared module is not being compiled for Scala.js. We can fix that as follows by compiling it for both. Mill example below:
object MyObject extends ScalaModule with ScalaJSModule with ScalafmtModule { // ... } // Instead of object MyObject extends ScalaModule with ScalafmtModule { // ... }
Topics: Code | 7 Comments »
Serving VNC via HTML5 using noVNC and x11vnc
By admin | July 22, 2021
# May need to set up x11vnc password beforehand! # -forever and -loop are important to makes sure it keeps working nohup x11vnc -create -forever -loop -usepw & # noVNC git clone https://github.com/novnc/noVNC.git --depth 2 cd noVNC # Set up SSL openssl req -x509 -nodes -newkey rsa:2048 -keyout novnc.pem -out novnc.pem -days 180 nohup ./utils/novnc_proxy --vnc localhost:5900 --cert novnc.pem --ssl-only --listen 443 &
Topics: (X)HTML, HTTP (Internet), Linux | 6 Comments »
Accessing SQL databases from Scala
By admin | July 21, 2021
import scalikejdbc._ import scalikejdbc.scalikejdbcSQLInterpolationImplicitDef // initialize JDBC driver & connection pool Class.forName("org.postgresql.Driver") scalikejdbc.ConnectionPool.singleton("jdbc:postgresql://localhost:5432/", "user", "abcdef888") sql""" create table members ( id serial not null primary key, fav_num integer NOT NULL, name text NOT NULL ) """.execute.apply()(scalikejdbc.AutoSession) sql""" INSERT INTO members (name, fav_num) VALUES ('Foo', 123) """.execute.apply()(scalikejdbc.AutoSession) sql""" INSERT INTO members (name, fav_num) VALUES ('Bar', 456) """.execute.apply()(scalikejdbc.AutoSession) // http://scalikejdbc.org/documentation/operations.html scalikejdbc.DB.readOnly { implicit session => sql"select * from members".foreach { (rs: scalikejdbc.WrappedResultSet) => println(rs.toMap()) } }
You can run the database with Docker (example) as follows:
docker run --name mypsql -e POSTGRES_USER=user -e POSTGRES_PASSWORD=abcdef888 -p 5432:5432 postgres:13.3
Reference instructions for connecting to the docker instance:
psql -h localhost -U user \dt select * from members;
Topics: Code | 1 Comment »
Local build in npm
By admin | May 24, 2021
npm install # Install dependencies
npm run build # Needs a like like "build": "tsc" in package.json. For TypeScript, just run tsc directly if missing
npm install -g # Installed compiled result to global packages
Topics: Code | 3 Comments »
Python classes, metaclasses, and instances at a glance
By admin | February 16, 2021
For more details: http://www.thedigitalcatonline.com/blog/2014/09/01/python-3-oop-part-5-metaclasses/

Topics: Code | 20 Comments »
git-strip-above
By admin | February 15, 2021
git format-patch $1..HEAD -o wip && git reset --hard $1
Topics: Code | 23 Comments »
Getting files from sources in Scala
By admin | February 14, 2021
// Java-based ways getClass.getResource("/html/myfile.html") println(Source.fromInputStream(getClass.getResourceAsStream("/html/myfile.html")).mkString) // Scala-native way // Note: NO LEADING SLASH println(Source.fromResource("html/myfile.html").getLines.toList)
Topics: Code | 243 Comments »
Epson DS-30 on Ubuntu Linux
By admin | February 13, 2021
https://bugs.launchpad.net/ubuntu/+source/sane-backends/+bug/1728012/comments/36
Use the attached ds-30-bundle, download from
http://support.epson.net/linux/en/iscan.php?model=ds-30&version=1.0.1
Install the deb packages with ./install.sh –dry-run
Use simple-scan to run the scan. Insert paper face down above/next to
the little scan marker and press the button
Topics: Linux | 24 Comments »
Running a GUI application in Docker
By admin | January 30, 2021
apt-get update && apt-get install -y openssh-server vim xpra # Allow container to connect to GUI? xhost + docker run --rm -v /tmp/.X11-unix:/tmp/.X11-unix -p 2222:2222 -e DISPLAY --security-opt seccomp:unconfined -it <image> bash sudo mkdir -p /run/user/1000 sudo chown ubuntu:ubuntu /run/user/1000 xpra start ssh:ubuntu@localhost:2222 --exit-with-children --start-child="xfce4-terminal"
Topics: Linux | 27 Comments »
Creating a service to run a systemd-nspawn server
By admin | January 28, 2021
debootstrap –include=systemd-container –components=main,universe focal myContainer
http://nova.clouds.archive.ubuntu.com/ubuntu/
https://bbs.archlinux.org/viewtopic.php?id=232804
Edit /usr/lib/systemd/system/systemd-nspawn@.service
ExecStart= -> remove -U
Add
[Exec]
PrivateUsers=off
https://wiki.debian.org/nspawn#Booting_a_Container
sudo systemctl daemon-reload
sudo systemctl restart systemd-nspawn@myContainer
Topics: Linux | 20 Comments »