Skip to content

Instantly share code, notes, and snippets.

View fehmicansaglam's full-sized avatar
🚶‍♂️
Wandering

Fehmi Can Sağlam fehmicansaglam

🚶‍♂️
Wandering
View GitHub Profile
@joom
joom / syllablize.hs
Last active August 29, 2015 14:04
Turkish NLP: Split a word to its syllables
import Data.Maybe (isNothing, fromJust)
import Data.Char (isAlpha, toLower)
import Data.List (findIndex)
-- charAt xs i = Just x, where x character at index i
-- Nothing, is i is out of bounds
charAt :: String -> Int -> Maybe Char
charAt xs i = if length xs > i then Just (xs !! i) else Nothing
-- isVowel x = True if x is a vowel,
@dpratt
dpratt / spray-stream-enumerator
Created July 24, 2014 16:52
A Spray chunking marshaller for Play Enumerators
package com.vast.utils
import akka.actor._
import akka.io.Tcp
import play.api.libs.iteratee._
import scala.concurrent.ExecutionContext
import spray.http._
import spray.httpx.marshalling.{MarshallingContext, Marshaller}
import akka.util.{ByteString, Timeout}
import scala.util.control.NonFatal
import scala.concurrent.{ ExecutionContext, Future }
import shapeless._, ops.tuple.{ IsComposite, LeftFolder, Prepend }
object zipAndAdd extends Poly2 {
implicit def only[B, A](implicit p: Prepend[B, Tuple1[A]], executor: ExecutionContext) =
at[Future[B], Future[A]] {
(fb, fa) => fb.zip(fa).map { case (b, a) => p(b, Tuple1(a)) }
}
}
@almeidap
almeidap / BaseDAO.scala
Last active March 25, 2023 12:26
DAO design for ReactiveMongo using JSONCollection and Play2 Scala JSON API (work in progress).
package core.dao
import scala.concurrent.Future
import play.api.Logger
import reactivemongo.core.commands.LastError
import reactivemongo.core.errors.DatabaseException
import core.db.MongoHelper