Skip to content

Instantly share code, notes, and snippets.

View vituchon's full-sized avatar

Vituchon vituchon

  • omnia salud
  • buenos aires
View GitHub Profile
#!/bin/sh
# diff is called by git with 7 parameters:
# path old-file old-hex old-mode new-file new-hex new-mode
kdiff3 "$2" "$5" | cat
@vituchon
vituchon / postgres recipes
Last active January 31, 2024 17:23
Recetas caseritas del postgres
-- 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'
function sumTableCells(tableId,cellIndex) {
var table = document.getElementById(tableId);
debugger;
let subTotal = Array.from(table.rows).reduce((total, row) => {
const textContent = row?.cells[cellIndex]?.textContent
return total + textContent ? parseInt(textContent.split(" ")[1].replace(",",".")) : 0
}, 0);
return subTotal
}
sumTableCells("table",5)
This file has been truncated, but you can view the full file.
Nabs Carlos
Alejandro Bologna
ANALIA ANTONIA ABALOS
María Pia Editadaaa Paz
Gonzalo Mauricio Coria
Usuario Sistema
Matias Buscaglia
Alexis Eme
Christian Sánchez
Cecilio Luis Cerisoli
@vituchon
vituchon / deferBuilder.ts
Last active April 21, 2023 13:21
Construyendo deferreds a manopla
function deferBuilder<T>() {
type resolveType = (value: T) => void;
interface resolveInterface { // no funca con interface :S
(value: T): void;
}
type rejectType = (reason?: any) => void
var resolve: resolveType;
var reject: rejectType
const promise = new Promise(function (_resolve: resolveType, _reject: rejectType) {
@vituchon
vituchon / postgres_recipes.sql
Last active July 5, 2022 20:44
Recopilación de sentencias SQL que trabajan con mucha dato-diversidad
-- 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'
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
</style>
<script>
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]
@vituchon
vituchon / Jsoning_A_Map_in.scala
Last active May 29, 2020 15:10
Todo el quilombo que hay que hacer para transformar a JsValue un Map
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) =>
@vituchon
vituchon / Consumer.java
Last active May 27, 2020 16:39
Fibonacci Procuder, Prime Producer and StdOut Consumer Example
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;