Skip to content

Instantly share code, notes, and snippets.

@juancavallotti
juancavallotti / bert_tokenizer.js
Created October 26, 2022 15:31
Correct implementation of BertWordpieceTokenizer
/*
* Copyright (c) AXA Group Operations Spain S.A.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
@juancavallotti
juancavallotti / mule-config.xml
Created October 8, 2012 04:19
Sample mule CE Application
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:jms="http://www.mulesoft.org/schema/mule/jms" xmlns:jdbc="http://www.mulesoft.org/schema/mule/jdbc" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="CE-3.3.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd
http://www.mulesoft.org/schema/mule/jdbc http://www.mulesoft.org/schema/mule/jdbc/current/mule-jdbc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd ">
<!-- activemq con
@juancavallotti
juancavallotti / TestConcurrencyStability.java
Created July 16, 2012 00:17
A simple test to use the ConcurrencyRule
public class TestConcurrencyStability {
private static final Logger logger = LoggerFactory.getLogger(TestConcurrencyStability.class);
private static DTOBinder binder;
@BeforeClass
public static void globalInit() {
binder = DTOBinderFactory.buildBinder();
}
@juancavallotti
juancavallotti / ConcurrencyRule.java
Created July 16, 2012 00:07
Concurrency test Rule
public class ConcurrencyRule implements TestRule {
private static final Logger logger = LoggerFactory.getLogger(ConcurrencyRule.class);
private final int threadsSpawn;
/**
* Builds a concurrency test with the given number of worker threads.
* @param threadsSpawn
*/
@juancavallotti
juancavallotti / websocketsConnection.js
Created June 19, 2012 21:23
Web Sockets Client Side Sample Code
var ws = new WebSocket("ws://"+document.location.host+document.location.pathname+"/testWebsocket");
ws.onopen = function() {
console.log("Websocket Ready!!");
}
ws.onmessage= function(data) {
console.log(data.data);
}
function sendMessage() {
ws.send("Test");
@juancavallotti
juancavallotti / TestWebsocket.java
Last active October 6, 2015 07:17
Test Websocket Servlet on java.
@WebServlet(urlPatterns="/testWebsocket")
public class TestWebsocket extends WebSocketServlet {
private static final long serialVersionUID = 1L;
@Override
protected StreamInbound createWebSocketInbound(String string, HttpServletRequest hsr) {
return new MessageInbound() {
@Override
protected void onBinaryMessage(ByteBuffer bb) throws IOException {