Sunday, December 27, 2015

NullPointer Exception while testing with Scala Futures...

So I was trying to unit testing Scala Futures, and I was getting NullPointerException out of nowhere. I was frustrated since the stacktrace didn't much more information, not a minimal clue of what was missing. It was until I payed attention to some other examples when I realized that I was missing something important:
import ExecutionContext.Implicits.global
I do not know why it wasn't detected at compile time, or why the exception was only coming as NullPointerException without any other hint. My test is something like this:

"Some test" should {
    "execute this" in {   
      val client = mock[AClass]
      val host = new BClass(client) 
      doReturn(Future {x}).when(client).aMethod(any[String], any[String]) // This was throwing a NPE
      val response = host.anyMethod(cI, mA, bL)
      Await.result(response, Duration(30, SECONDS)) 
      there was one(client). aMethod(any[String], any[String])
    }
  }


Thursday, October 8, 2015

starting with method newCanBuildFrom in object SortedSet

I was trying to loop over Scala Enumeration values like this:
  • aEnumeration.values.map(<something>)
And I got all sort of errors that seem to be unrelated to this. So I had to comment line by line to finally found this was causing the problem.

So, to remove this exception you just have to convert Enumeration values into a Scala List:
  • aEnumeration.values.toList.map(<something>)

Exception gone!

Tuesday, October 6, 2015

MAC getting rid of Nielsen NetSight malware

One of my friends got this thing on his Mac; Chrome and other browsers were crashing and eventually his computer restarted by itself.

I was disappointed on Mac response for help, basically they ask you to backup your data and reinstall OS (or upgrade to the next OS version).

Because we were in hurry, we did not want to do backup and reinstall, so we did the following:

  1. Look for a process named "Nielsen" in the Activity monitor, don't try to kill it, it will restart by itself. It seems, at least in my case, it goes under NetSight directories. 
  2. Double click over that process, and then click over "Open Files and Ports"
    • I found something like this " /Library/NetSight/KeyboardMouse.app"
  3. So you can do one of two things, either move it or delete it (if you are not admin then you have to prepend "sudo" without quotes to any of the following instructions):
    • Open a terminal and paste anyone of the following:
      • mv /Library/NetSight/KeyboardMouse.app ~/malware
      • rm -fr /Library/NetSight/KeyboardMouse.app 
  4. Finally remove anything related to that trash (once we did this the little icon on the top disappear after restarting):
    • sudo find / -name NetSight -exec rm -rf {} \;

 In our case we did not lose any data, and Mac is acting normal now; no more Chrome crashing or Mac restarting. Anyways do this under your own risk.

Tuesday, March 3, 2015

Friday, January 2, 2015

Amazon -- Deliver docs to PC or MAC

I still do not understand why the option of sending personal docs to PC (or Mac) kindle is disabled, there a couple of workarounds:

Option 1)
PC, right click on the document and open it with Kindle.
Mac, open with Kindle.

Option 2)
Find "My Kindle Content" folder and drop your document there.
Linux command [find / -name 'My Kindle Content']

...