Skip to content

Instantly share code, notes, and snippets.

View alexflav23's full-sized avatar

Flavian Alexandru alexflav23

View GitHub Profile
@alexflav23
alexflav23 / exercise.md
Last active February 20, 2018 00:03
Property Partner - Coding exercise 2018

Config Challenge

Using Scala and a parser combinator library of your choice, please spend 3 hours on:

Every large software project has its share of configuration files to control settings, execution, etc. Let’s contemplate a config file format that looks a lot like standard PHP .ini files, but with a few tweaks.

A config file will appear as follows:

[common] 
@alexflav23
alexflav23 / rating.md
Last active June 19, 2018 14:02
Interview rating

Interview score card

Part 1. Basic knowledge

  1. (2 points) Easy: What is the difference beteen var, val and def? [x] 2
  2. (3 points) Easy: How does pattern matching work in Scala? [x] 3
  3. (3 points) Easy: What are right associative methods in Scala? [x] 0
  4. (3 points) Easy: What is the difference between a trait and an abstract class in Scala? [x] 3
  5. (2 points) Medium: What is scala.util.control.NonFatal? [x] 2
  6. (3 points) Medium: How does Scala solve the diamond resolution problem with traits? [x] 3
@alexflav23
alexflav23 / error.md
Last active August 29, 2015 14:11
Barclays Online Website error

Here's some free debugging as we all really need the service back up and running properly. Cookies and cache where completely wipped before attempting the exercise, several times. The error is consistent across operating systems, devices, browsers and even machines.

At line 356 of LoginLink.action you are passing empty constructor arguments to a JavaScript class instantiation potentially due to a server side error failing to output the relevant arguments where they should be.

The code ends up being:

var timeout = new LoginTimeout( , );
@alexflav23
alexflav23 / ThriftDeps.scala
Created April 28, 2014 09:54
Defining Thrift dependencies in Finagle services.
lazy val service2Thrift = Project(
id = "service2-thrift",
base = file("service2-thrift"),
settings = Project.defaultSettings ++
VersionManagement.newSettings ++
sharedSettings ++
ScroogeSBT.newSettings ++
publishSettings
).settings(
@alexflav23
alexflav23 / ArticleRecord.scala
Last active December 30, 2015 08:39
Using Lift MongoDB record and Foursquare Rogue.
package com.example.record
/**
* In here you will learn how to define a basic MongoDB record class.
* It's type safe and far more powerful than anything our there.
* First, a few basic imports
*/
import org.bson.types.ObjectId
import org.joda.time.DateTime
@alexflav23
alexflav23 / AsyncRest.scala
Last active December 30, 2015 07:19
Example of asynchronous REST route.
import net.liftweb.http.rest.{ RestContinuation, RestHelper }
import net.liftweb.http.{ NotAcceptableResponse, OkResponse, S, UnauthorizedResponse }
import net.liftweb.json.{ DefaultFormats, JsonAST, JsonParser }
import net.liftweb.json.JsonAst.JValue;
/**
* This is a trivial implementation of a Scala case class.
* In our code, they are companions to more complex database models.
*/
package whatever;
import java.util.{ List => JList, Map => JMap }
import com.foursquare.rogue.LiftRogue._
import com.foursquare.rogue.{
AbstractQueryField,
AbstractModifyField,
EqClause,
ModifyClause,
ModOps,
@alexflav23
alexflav23 / Guard.scala
Last active April 23, 2016 16:06
RestHelper 401 response
package code.lib;
import net.liftweb.http.rest.RestHelper
import net.liftweb.http.{ LiftRules, LiftResponse, Req, UnauthorizedResponse }
import net.liftweb.common.{ Box, Full, Empty, Failure, ParamFailure }
trait TypesHelper {
implicit def pfAuthorize[A, B](in: PartialFunction[A, B]): OAuthPartialFunctionWrapper[A, B] =
new OAuthPartialFunctionWrapper[A, B](in)
}
@alexflav23
alexflav23 / LongestCollatzSequence
Created July 15, 2013 13:41
ProjectEuler#14 - Longest Collatz Sequence
package org.projecteuler.exercises
import scala.annotation.tailrec;
import scala.collection.mutable.HashMap;
object LargestCollatzSeq {
val map: HashMap[BigInt, BigInt] = new HashMap
val limit = 1000000
@alexflav23
alexflav23 / Pairing and unicity
Last active December 17, 2015 11:29
StackOverflow Fun
public class Pair {
private String left;
private String right;
public Pair(String v1, String v2) {
left = v1;
right = v2;
};
public String getLeft() {