Skip to content

Instantly share code, notes, and snippets.

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

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

import mesosphere.mesos.util.FrameworkInfo
import org.apache.mesos.MesosSchedulerDriver
/**
* @author Tobi Knaup
*/
object Main extends App {
@yujikiriki
yujikiriki / UnaMejorForma?
Last active August 29, 2015 14:04
Hay alguna forma de hacerlo mejor?
case class OrderIncomeReportEntry( month: String, value: Double )
private def sumValues( entries: List[ OrderIncomeReportEntry ] ): List[OrderIncomeReportEntry] = {
val byMonth: Map[ String, List[ OrderIncomeReportEntry ] ] = entries.groupBy( e => e.month )
byMonth.foldLeft( List[OrderIncomeReportEntry]() ) {
( list, value ) =>
val sum = value._2.foldLeft( 0.0 )( ( acc, oire ) => acc + oire.value )
list.+:( OrderIncomeReportEntry( value._1, sum ) )
}
}

Keybase proof

I hereby claim:

  • I am yujikiriki on github.
  • I am yujikiriki (https://keybase.io/yujikiriki) on keybase.
  • I have a public key whose fingerprint is C4E8 CAB6 1837 0D10 29F2 988E D9B1 D1F7 0678 BA42

To claim this, I am signing this object:

@yujikiriki
yujikiriki / YearOrderIncomeReport.scala
Created September 18, 2014 13:32
ReactiveMongo aggregation pipeline example
private def query( ): Future[ List[ JsObject ] ] = {
val group: Group = Group( BSONString( "$order.year" ) )( ("total", SumField( "value" )) )
val pipeline: Seq[ PipelineOperator ] = Seq( group )
val command: Future[ Stream[ BSONDocument ] ] = db.command( Aggregate( "opportunities", pipeline ) )
command map {
c =>
c.toList map {
d =>
toJSON( d ).asInstanceOf[ JsObject ]
}
@yujikiriki
yujikiriki / gist:12a3dc9465aa50cd7fe6
Created September 18, 2014 14:49
ReactiveMongo aggregation pipeline example #2
collection.db.command(Aggregate(collection.name, Seq(
Match(toBSON(jsonQuery)).get.asInstanceOf[BSONDocument]),
Project(convertProjectionJsonForAggregate(projectionJson):_*),
Sort(convertSortJsonForAggregate(versionDescendingSort))
))) map { stream =>
stream.toList map { doc =>
toJSON(doc).asInstanceOf[JsObject]
}
}
@yujikiriki
yujikiriki / sprayio.conf
Last active January 15, 2016 21:16
Spray.io configuration
akka.actor{
creation-timeout = 20s
default-dispatcher {
throughput = 20
executor = "fork-join-executor"
fork-join-executor {
parallelism-min = 16
parallelism-factor = 2.0
parallelism-max = 16
}
@yujikiriki
yujikiriki / blog-review.md
Last active August 29, 2015 14:08
Review blog Felipe

a) Acá encuentro un primer mal entendido.

Dentro de los elementos de este estilo arquitectural a mí entender dos de ellos son fundamentales:

Proceso de negocio: es un conjunto de tareas que se relacionan lógicamente para conseguir un resultado bien definido dentro de un negocio. Por ejemplo uno puede pensar en el proceso de: comprar libro en un ecommerce. Si no estoy mal aquí hay lenguajes como BPMN que permiten describir un proceso de negocio.

Servicio: Esos son los que implementamos los desarrolladores normalmente y corresponden a definiciones de software concretas de los conceptos de negocio.

Los procesos NO hacen parte de SOA. Sí es un estilo arquitectónico, pero le falta apellido: es un estilo arquitectónico para sistemas distribuidos.

@yujikiriki
yujikiriki / gist:65bf00d105613e203184
Created December 22, 2014 19:09
Referencias a tolerancia a fallas
The bizantine generals problem - Lamport
Why Do Computers Stop and What Can Be Done About It? - Jim Gray
Why do Internet services fail, and what can be done about it? - Oppenheimer
Lightweight Recoverable Virtual Memory - M. Satyanarayana
Principles of Antifragile Software - Martin Monperrus
Building on Quicksand - Helland, Campbell
Crash-Only Software - Candea, Fox
Fault Tolerance via Idempotence - Ramalingam, Vaswani
Fundamental Concepts of Dependability - Avizienis, Laprie, Randell
How Complex Systems Fail - Richard I. Cook, MD