Skip to content

Instantly share code, notes, and snippets.

Avatar

Vituchon Vitucho

  • omnia salud
  • buenos aires
View GitHub Profile
View RedisCache.scala
package util
import com.redis._
import java.util.concurrent.Executors
import scala.concurrent.{Future, ExecutionContext}
trait Cache {
def get(key: String): Future[Option[String]]
def set(key: String, value: String, seconds: Long): Future[Boolean]
def ping(): Future[Boolean]
@Vitucho
Vitucho / Jsoning_A_Map_in.scala
Last active May 29, 2020
Todo el quilombo que hay que hacer para transformar a JsValue un Map
View Jsoning_A_Map_in.scala
object CookiesStore {
private var sessionDataBySessionId = Map[Long, CookieUserInfo]()
def asJson(): JsValue = { // taken and adapted from: https://stackoverflow.com/a/27286808/903998
import play.api.libs.json.Json.JsValueWrapper
/*implicit val mapReads: Reads[Map[Long, CookieUserInfo]] = new Reads[Map[Long, CookieUserInfo]] {
def reads(jv: JsValue): JsResult[Map[Long, CookieUserInfo]] =
JsSuccess(jv.as[Map[Long, CookieUserInfo]].map{case (k, v) =>
View trying.js
//Esto no funciona....
// wait ms milliseconds
function wait(ms) {
return new Promise(r => setTimeout(r, ms));
}
function f() {
@Vitucho
Vitucho / main.go
Created Apr 8, 2019
Example usage of Postgres Array within a golang app
View main.go
package main
import (
"database/sql"
"fmt"
"log"
"github.com/lib/pq"
)
@Vitucho
Vitucho / postgres_recipes.sql
Created Apr 5, 2019
Recopilación de sentencias SQL que trabajan con mucha dato-diversidad
View postgres_recipes.sql
-- Consulta sobre el valor un miembro de primer nivel (para el caso, turnos que son sobreturnos)
select *
from appointments
where details ->> 'isOverturn' = 'true';
-- Consulta sobre el valor de un miembro de un nivel aninado (para el caso, los turnos con atención particular)
select *
from appointments
where details -> 'extra' ->> 'attentionBy' = 'particular'
@Vitucho
Vitucho / Consumer.java
Last active May 27, 2020
Fibonacci Procuder, Prime Producer and StdOut Consumer Example
View Consumer.java
import java.util.concurrent.BlockingQueue;
public class Consumer implements Runnable {
private final BlockingQueue<Long> queue;
private volatile boolean finish;
public Consumer(BlockingQueue<Long> queue) {
this.queue = queue;
You can’t perform that action at this time.