Skip to content

Instantly share code, notes, and snippets.

View vasigorc's full-sized avatar
🇨🇦
Working from home

Vasile Gorcinschi vasigorc

🇨🇦
Working from home
View GitHub Profile
@vasigorc
vasigorc / EitherTFutureTest.scala
Created December 1, 2022 19:44
Confirm that an exception is not lost with EitherT over Future when doing flatMapF and valueOrF
package ca.vgorcinschi.cats
import cats.data.EitherT
import cats.implicits._
import java.io.IOException
import scala.concurrent.Future
import scala.util.{Failure, Success}
object EitherTFutureTest extends App {
@vasigorc
vasigorc / FindLIS.scala
Created June 16, 2022 16:00
Interview exercise. Find the longest subsequence in an array
object FindLIS {
def findLIS(initialArray: Array[Int]): Int = {
if (initialArray.length < 2) return initialArray.length
val allSubSequences = initialArray.zipWithIndex.foldLeft(List.empty[Array[Int]]) {
case (currentSubSequences, (nextValue, index)) =>
currentSubSequences ::: getSubsequenceFromArray(Array(nextValue), initialArray.drop(index))
}
@vasigorc
vasigorc / CatsUtil.scala
Last active November 15, 2021 22:00
How an Array Monad could look like (naÏve approach)
import cats.Monad
import scala.annotation.tailrec
import scala.collection.mutable.ArrayBuffer
object CatsUtil {
implicit val arrayMonad: Monad[Array] = new Monad[Array] {
override def flatMap[A, B](fa: Array[A])(f: A => Array[B]): Array[B] = {
if (fa.isEmpty) return Array.empty
@vasigorc
vasigorc / .bashrc
Created April 12, 2019 02:04 — forked from tijptjik/.bashrc
mTypeHK .bashrc with Fedora // Git aliases . Put it in your home directory
#!/bin/bash
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
PS1='\[\e[1;34m\]\u\[\e[m\] \[\e[0;32m\]\w\[\e[m\] $(parse_git_branch) \[\e[1;34m\]\$ \[\e[m\]\[\e[0;37m\]'
#PS1='\[\e[1;34m\]\u\[\e[m\] \[\e[0;32m\]\w\[\e[m\] \[\e[1;34m\]\$ \[\e[m\]\[\e[0;37m\]'
# If not running interactively, don't do anything
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />