I was thinking to rewrite my summarizer app for a while. But couldn’t decide what to use, should I move to play mvc or sth else.. There was a Scala meeting in Helsinki this year, so I joined to meeting and first time I heard about Finatra. Finatra is an HTTP API framework built on top of Finagle. Twitter, Tumblr vs. some big companies use it and develop same time. The project is very active! The documentation is well written. You can easily start to write a sample app. So after some tryings I decided to use Finatra for my service. And about database, basically I store text documents and summaries, so it was easy decision to use Mongodb.
Scala does not read file from resources folder after compiling
While running my app with Intellij Idea , I had no problems with resource folder. It was reading files and passing tests. It was implemented like this:
val resourcesPath = getClass.getResource("/lexical/stopWords.csv").getPath
val source = fromFile(resourcesPath)
val text = try source.mkString finally source.close()
Scalastyle HeaderMatchesChecker problem
Problem is that idea shows warning if you dont have a blank line following the header in a file. My environment is:
scalaVersion: "2.12.4"
sbt.version: "1.1.5"
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")
How to mock a call by name function using ScalaMock?
I was trying to mock my call-by-name function with ScalaMock, so it can run the passed function inside my mock. My workmates helped me to find the solution.
Error: scala.concurrent.impl.Promise$DefaultPromise@69b28a51 cannot be cast to Either
The problem is related with my mock for myFunction(). I pass a call-by-name function to myFunction()(f: => T) which returns T, after evaluating it, myFunction() returns Either[ErrorCode, T]. So the mock should be like that:
Scala forward reference extends over definition of value x
Problem is that can not find the function we call. Try put the function top of it. Or still not work then define as lazy value. If it is referenced somewhere and scalac is confused with the sequence, making it lazy could do the trick Example: ```scala def functionA() { functionB() }
how to run sbt projects with intellij idea
- From the Run menu, select Edit configurations
- Click the + button and select SBT Task.
- Name it Run the program.
- In the Tasks field, type ~run. The ~ causes SBT to rebuild and rerun the project when you save changes to a file in the project.
- Click OK.
- On the Run menu. Click Run ‘Run the program’.
How to move from tumblr to jekyll - part 1
Almost 4 years I have been using tumblr for blogging. I was not happy with tumblr because of google analytics and crawling problems. And I want to try something different. First I tried wordpress but it didn’t work well with my home server, I have an orange pi, so it was very slow to open any page with wordpress. I decided to use static blog, after some research, It was best to use Jekyll for blogging. Good idea but a bit hard to move everything, because there is not any tool which can move to all tumblr posts to your jekyll blog. After trying some tools I finally found a way to move all posts!
Intellij Idea shortcuts
- refactoring : shift + F6
Github tricks when merge has conflicts
For example; we have branch task-12 multiple people commit to branch and they fix conflicts you want to git pull and then commit your changes but when you git pull it has conflict with your local copy of this branch then follow this steps to get latest version of branch without confilicts
Functional Programming for Mortals
I started to read a new book about Scala. You can read it online or you can buy it.