Category Archives: Uncategorized
Monitor Enery with Shelly 3em, Raspberry Pi, Node Red, PostgreSQL, MQTT(Mosquito), …
Trying to write down some of the things I did to get this working What Shelly 3em publishes You can see all the topics of the mqtt broker by doing like this :mosquitto_sub -d -v -t ‘#’The ‘#’ means ALL … Continue reading
Useful docker commands
Download Docker image docker pull python Start up Docker image with just a bash shell as entrypoint docker run -it –rm –name python python /bin/bash now you should see something like this : Attach to a running docker container docker … Continue reading
Java & JSON : How to serialize NULL
So how do you serialize NULL ? NULL would typically mean that the attribute is omitted from the json, but what if you WANT the NULL to be there, to symbolize an attribute that should be REMOVED.
Mockito and JUnit 5
The purpose of this post is simply to give a hint on how to use Mockito, Spy, and JUnit 5.
SQL Scratch
These are just scratches/notes for my work with Prestashop Create copy of table / duplicate table (select into kind of)
Functions as Arguments Java vs Scala, Game Set Match Scala Wins!
This is how you would create a function that takes a function as argument in Java The Function<A,B> myFunc = num -> “Value = ” + num;Here :A = the type of the first argument, in this example an intergerB … Continue reading
Apache Zeppelin, with Spark and Cassandra, the perfect tool
Zeppelin has become one of my favourite tools in my toolbox. I am heavily designing stuff for Cassandra and in Scala, and even though I love Cassandra there are times when things just gets so complicated with the CQL command … Continue reading
SQL LIKE operation in Cassandra, is possible in v3.4+
For a long time it has not been possible to do a SELECT * FROM table WHERE firstname like ‘t%’; in Cassandra like you could in eg.. MySQL or any other Relation Database for that matter. In Cassandra v3.4 this … Continue reading
Apache SPARK and Cassandra and SQL
This is a short intro to start using Apache SPARK with Cassandra, running SQL on the Cassandra tables. Note that I am not running a SPARK cluster, I am running “local”, to me this is really convenient, not having to … Continue reading
Create an MBean (JMX) in Scala
Create the MBean like this
1 2 3 4 5 6 7 8 9 10 11 12 13 |
trait OrderTrackerMBean { def getOrderId : Int def setOrderId(orderId:Int) } class OrderTracker extends OrderTrackerMBean { var orderId = 0 override def getOrderId: Int = orderId override def setOrderId(_orderId: Int)= { orderId = _orderId } } |
NOTE, that the interface/trait must end with MBean in the name And this is how you register your MBean
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
package com.tsoft.playingWithLogback import java.lang.management.ManagementFactory import javax.management.{ObjectName, MBeanServer} import org.slf4j.{MarkerFactory, Marker, LoggerFactory} import org.slf4j.MDC import scala.concurrent.{Await, Future} import scala.concurrent.duration._ import scala.concurrent.ExecutionContext.Implicits.global object LotsOfLogOutput { val logger = LoggerFactory.getLogger(this.getClass) val orderTrackerBean = new OrderTracker val mbs:MBeanServer = ManagementFactory.getPlatformMBeanServer(); val mBeanName:ObjectName = new ObjectName("com.tsoft.playingWithLogback:type=Tracking"); mbs.registerMBean( orderTrackerBean, mBeanName); ... |
And the simply launch Java Mission Control (imc), attach to the JVM, and modify … Continue reading