Saturday, 20 October 2018

join clips in imovie in macos


In the latest version of imovie, clips can be joined clicking the "share as File..." at the right top corner.



In order to mute the volume of particular video, click on it at the bottom bar and lower the percentage to 0 at the setting on top right corner.


Saturday, 13 October 2018

tcp connection 101



client     ----------------------------------------> server
                TCP handshake (conn timeout) 
                      eg. 5 secs
                
           ----------------------------------------->
                reading data (read timeout)
                       eg. 60 secs

example - https://github.com/AsyncHttpClient/async-http-client/blob/master/client/src/main/resources/org/asynchttpclient/config/ahc-default.properties#L4

https://stackoverflow.com/a/3069450/432903

Saturday, 5 May 2018

basic performance measurement of JVM process/application

JDK comes with couple of tools for perf measurement
1) jconsole
2) jvisualvm
3) jmc

JMC stands for java mission control.

1) To get started type in command jmc in terminal.

$ jmc
2018-05-05 20:32:04.418 jmc[1556:12405] IMKInputSession presentFunctionRowItemTextInputViewWithEndpoint:completionHandler: : [self textInputContext]=0x0 *NO* NSRemoteViewController to client, NSError=Error Domain=NSCocoaErrorDomain Code=4099 "The connection from pid 0 was invalidated from this process." UserInfo={NSDebugDescription=The connection from pid 0 was invalidated from this process.}, com.apple.inputmethod.EmojiFunctionRowItem


2) First thing I see in UI is the CPU usage, 




3) The 5th tab shows the memory usage,



4) And the 6th tab shows the Threads




Saturday, 7 April 2018

scala populate data class from tuple values



scala> case class Order(id: String, items: Seq[String]) 
// defined case class Order

scala> ("DW-001" -> Seq("item1", "item2")) 
val res0: (String, Seq[String]) = (DW-001,List(item1, item2))

scala> (Order.apply _) tupled res0 
val res1: Order = Order(DW-001,List(item1, item2))


Obviously the tuple needs to have data as in a data class members. Out of sequence tuple won't be applied to data class.

scala> (Seq("item1", "item2"), "some-id") 
val res2: (Seq[String], String) = (List(item1, item2),some-id)
scala> (Order.apply _) tupled res2 
1 |(Order.apply _) tupled res2
  |                       ^^^^
  |                       found:    (Seq[String], String)(res2)
  |                       required: (String, Seq[String])
  |    

Tuesday, 21 November 2017

using java lambdas as groovy closure



using java lambdas from groovy

I have a scala method that takes java.util.function.Supplier as parameter.
class TestKit(system: ActorSystem) {
   def awaitCond(p: Supplier[Boolean]): Unit = tp.awaitCond(p.get)
}
syntactic sugar for Supplier functor would be () -> ... in java, but is not compiled in groovy.
def actorSystem = ActorSystem.create("actor-system")
def verifier = new TestKit(actorSystem)
verifier.awaitCond { -> return verifier.msgAvailable()}

Thursday, 16 November 2017

debugging scala web artifact deployed on docker + tomcat, from intellij



STEP 1 - enable "Java Platform Debugger Architecture" port in docker
FROM tomcat:8.0.46-jre8                                                                                
                                                                                                       
ENV JAVA_OPTS="-Denvironment=local"                                                                    
#ENV CATALINA_OPTS="$CATALINA_OPTS -agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n"
                                                                                                       
ENV JPDA_ADDRESS 8000                                                                                  
COPY nlu-processor-service/target/*.war /usr/local/tomcat/webapps/nlu-processor-1.0.war
                                                                                                       
EXPOSE 8080                                                                                                                                            
CMD ["catalina.sh", "jpda", "run"]

If it's simply tomcat(without docker), create bin/setenv.sh and add jpda port address.

JPDA_OPTS="-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n"


STEP 2 - add remote debugging to intellij

Set the JPDA port as set in setenv.sh or Dockerfile







Wednesday, 15 November 2017

scala pattern matches



collect pattern matches,

scala> val data = Map((1 -> ("prog" -> "Pink floyd")), (2 -> ("metal" -> "Architects")), (3 -> ("prog" -> "Porcupine Tree")))
data: scala.collection.immutable.Map[Int,(String, String)] = Map(1 -> (prog,Pink floyd), 2 -> (metal,Architects), 3 -> (prog,Porcupine Tree))

scala> data.collect {case (k, v) if v._1 == "prog" => v._2}
res9: scala.collection.immutable.Iterable[String] = List(Pink floyd, Porcupine Tree)

scala> data.collect {case (k, (v1, v2)) if v1 == "prog" => v2}

res10: scala.collection.immutable.Iterable[String] = List(Pink floyd, Porcupine Tree)

scala foldLeft pattern matches,

scala> val data = Map((1 -> ("prog" -> "Pink floyd")), (2 -> ("metal" -> "Architects")), (3 -> ("prog" -> "Porcupine Tree")))
data: scala.collection.immutable.Map[Int,(String, String)] = Map(1 -> (prog,Pink floyd), 2 -> (metal,Architects), 3 -> (prog,Porcupine Tree))

scala> data.foldLeft(""){case (text, (id, (genre, artist))) => text + "\n" + artist}
res17: String =
"
Pink floyd
Architects

Porcupine Tree"