This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.mongodb.scala.{Observable, Observer} | |
import zio.stream._ | |
import zio.{IO, ZIO} | |
object ZioMongoSupport { | |
implicit class ObsConverter[T](observable: Observable[T]) { | |
def toStream: Stream[Throwable, T] = toStream(identity) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.Math._ | |
object LongExtensions { | |
implicit class BytesLengthConverter(val bytes: Long) extends AnyVal { | |
def humanReadableByteCount(si: Boolean = false): String = { | |
val unit = if (si) 1000 else 1024 | |
if (bytes < unit) bytes + "B" | |
else { | |
val exp = (log(bytes) / log(unit)).toInt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Trie(char: Char, | |
children: Seq[Trie] = Nil, | |
indices: Seq[Int] = Nil) { | |
def add(word: String, | |
index: Int): Trie = { | |
val updatedChildren = word.toSeq match { | |
case Seq(head) => | |
update(head) { | |
Trie(head, indices = Seq(index)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package fr.gstraymond.search | |
data class Trie(private val char: Char, | |
private val indices: MutableList<Int> = mutableListOf(), | |
private val children: MutableList<Trie> = mutableListOf()) { | |
fun add(word: String, | |
index: Int) { | |
val first = word.first() | |
val trie = findOrCreate(first) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ai.snips.bsonmacros.DatabaseContext | |
import models.{SampleData, SampleDataDAO} | |
import org.mongodb.scala.bson.BsonObjectId | |
import play.api.Logger | |
import play.api.mvc._ | |
import scala.concurrent.ExecutionContext | |
class HomeController @Inject()(sampleDataDAO: SampleDataDAO, | |
dbContext: DatabaseContext) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.inject.{Inject, Singleton} | |
import ai.snips.bsonmacros.{BaseDAO, CodecGen, DatabaseContext} | |
import scala.concurrent.ExecutionContext | |
@Singleton | |
class SampleDataDAO @Inject()(val dbContext: DatabaseContext) | |
(implicit ec: ExecutionContext) extends BaseDAO[SampleData] { | |
// generating once a codec for you case class and putting in the registry | |
CodecGen[SampleData](dbContext.codecRegistry) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.mongodb.scala.bson.BsonObjectId | |
case class SampleData(_id: BsonObjectId, | |
string: String, | |
boolean: Boolean, | |
int: Int) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resolvers ++= Seq( | |
… | |
"Sonatype OSS" at "https://oss.sonatype.org/content/groups/public" | |
) | |
libraryDependencies ++= Seq( | |
… | |
"ai.snips" %% "play-mongo-bson" % "0.2", | |
"org.mongodb.scala" %% "mongo-scala-driver" % "1.1.1" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Jenkins | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://jenkins2.snips.ai/view/Monitor/ | |
// @grant none | |
// ==/UserScript== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
i#!/usr/bin/env zsh | |
# in fino veritas | |
# Borrowing shamelessly from these oh-my-zsh themes: | |
# fino-time | |
# pure | |
# https://gist.github.com/smileart/3750104 | |
# Set required options |
NewerOlder