Author Archives: tobias
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
UDF/User Defined Functions in Cassandra 3.x
I was just playing around with Cassandra WRITETIME and thought it was somewhat difficult to figure out the date / timestamp of a number like this (microseconds since EPOC) 1470645914253000. So in my example it looked like this
1 2 3 4 5 6 7 8 9 10 11 |
cqlsh:bth> select id, writetime(dateofbirth) from bth.employee; id | writetime(dateofbirth) ----+------------------------ 1 | 1470645914253000 2 | 1470645977177000 7 | 1470948508799001 3 | 1470645977178000 (4 rows) cqlsh:bth> |
So … Continue reading
Cassandra set the writetime explicitly with a PreparedStatement
This is a quick one, I wanted to set the writetime of a row explicitly when I populate the database for testing purposes. We use the writetime of a column to filter them out. It required some looking around to … 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
SBT Good to know…
Dependecy problems I have been having some difficulties figuring out what depends on what. I found the following set plugins which I think can be really helpful; https://github.com/jrudolph/sbt-dependency-graph and https://github.com/gilt/sbt-dependency-graph-sugar Be sure to install GraphWiz first, I used Homebrew on … 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
SBT module not found, why ?
I have an build.sbt file that looks like this
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
name := "TobiasPlayground" version := "1.0" scalaVersion := "2.11.7" scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8") libraryDependencies ++= { val akkaV = "2.3.9" val sprayV = "1.3.3" Seq( "io.spray" %% "spray-client" % sprayV, "io.spray" %% "spray-can" % sprayV, "io.spray" %% "spray-routing" % sprayV, "io.spray" %% "spray-testkit" % sprayV % "test", "com.typesafe.akka" %% "akka-actor" % akkaV, "com.typesafe.akka" %% "akka-testkit" % akkaV % "test", "org.specs2" %% "specs2-core" % "2.3.11" % "test", "org.slf4j" %% "slf4j-api" % "1.7.10" ) } |
But for some reason I can’t get slf4j downloaded from the Maven repository (http://mvnrepository.com) If I search the Maven Repository, I can clearly see that the version I intend to … Continue reading
See who is connected to the same network / WIFI
There are tools out there, such as Angry IP Scanner, iNet or IP Scanner, Â but this can easily be done using a bash script, not as nice looking perhaps but it does the job. The script :
1 2 3 4 5 6 7 8 9 10 |
#!/bin/bash for i in {0..255} do cmd="nslookup 192.168.1." cmd=$cmd$i result=$($cmd|egrep "Address|name") echo "****************" echo $cmd echo $result done |
Which should … Continue reading
Övervakning av min IVT-490 värmepump med Raspberry Pi
I denna artikeln ska jag försöka beskriva mitt lilla projekt med att övervaka min IVT-490 värmepump med en Raspberry P. Jag har hämtat mycket kunskap från dessa två forum-trådar : http://www.varmepumpsforum.com/vpforum/index.php?topic=27306.15Tanken och http://www.byggahus.se/forum/varme-allmant/44487-prata-med-ivt-490-a-5.html Min värmepump har ett interface som ser … Continue reading
Calculate the minimum waste when cutting planks…
I made a web application which will calculate the most optimum layout of your pieces you would like to cut from a plank. This helps in figuring out how many planks of a certain size you would have to buy, … Continue reading