Skip to content

Instantly share code, notes, and snippets.

View dbuos's full-sized avatar
:octocat:

Daniel Bustamante Ospina dbuos

:octocat:
View GitHub Profile
@dbuos
dbuos / detect_lang.py
Created December 27, 2023 21:27
Detect Language Text Dataset
from datasets import load_dataset
from transformers import pipeline
import torch
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
pipe = pipeline("text-classification", model="papluca/xlm-roberta-base-language-detection", device=device)
def classify_lang(elem):
results = pipe(elem['text'], truncation=True)
return {'lang': [r['label'] for r in results]}
var flow_example = [0, ":block", [[ //Start of block 0
//Action
[1, ":send_command", ["cmd_name", {age: "ctx.human.age"}, "service0"]],
//Action
[2, ":query_pet", ["query_pet", {id: "ctx.human.petId"}, "target0"]],
// Action "Rule"
[3, ":delay", [{time: 7000}]],
// High level action
[4, ":send_email", [{template: "contact", name: "#ctx.human.name"}]],
// High level Action
@dbuos
dbuos / Docker Java
Last active September 17, 2020 18:11
FROM anapsix/alpine-java:8
WORKDIR /app
EXPOSE 8080
CMD java -XX:MaxRAMFraction=1 -XX:MaxRAM=$(( $(cat /sys/fs/cgroup/memory/memory.limit_in_bytes) * 67 / 100 )) -jar /app/app.jar
//In mongo Shell
//To list databases
show dbs
show databases
// Para usar una db (o crear una si no existe al realizar una operación de escritura)
use nombreDB
//Insertar documentos
#Almacenar el id (name) del proyecto en una variable (Muy importante para interoperabilidad)
export GCP_PROJECT=`gcloud config list core/project --format='value(core.project)'
Use MongoOperations
https://kamranzafar.org/2016/10/25/atomic-updates-on-mongodb-with-spring-data/
Use ReactiveMongoOperations
https://dzone.com/articles/spring-data-mongodb-with-reactive-mongodb
@dbuos
dbuos / PublisherToMessageChannelResultAdapter.java
Last active March 13, 2018 16:54
Reactive StreamListener does not propagate headers
/*
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@dbuos
dbuos / start_rabbitmq_docker.sh
Last active March 8, 2018 16:57
Start RabbitMQ in Docker
# To run a rabbitMQ instance with management interface enabled in port 15672
docker run -d --hostname my-rabbit --name some-rabbit -p 5672:5672 -p 15672:15672 -e RABBITMQ_DEFAULT_VHOST=my_vhost -e RABBITMQ_DEFAULT_USER=user -e RABBITMQ_DEFAULT_PASS=password rabbitmq:3-management
@dbuos
dbuos / SimpleSpringIntegrationExample.java
Created March 5, 2018 19:27
Simple spring integration example to listen to a directory
package com.example.demo;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.integration.dsl.IntegrationFlow;
import org.springframework.integration.dsl.IntegrationFlows;
import org.springframework.integration.file.dsl.Files;
import java.io.File;
@dbuos
dbuos / Docker connect to remote server.md
Created February 20, 2018 23:34 — forked from kekru/Docker connect to remote server.md
Connect to another host with your docker client, without modifying your local Docker installation

Run commands on remote Docker host

This is how to connect to another host with your docker client, without modifying your local Docker installation or when you don't have a local Docker installation.

Enable Docker Remote API

First be sure to enable the Docker Remote API on the remote host.

This can easily be done with a container.
For HTTP connection use jarkt/docker-remote-api.
For HTTPS connection use whiledo/docker-remote-api-tls.