Skip to content

Instantly share code, notes, and snippets.

View javichur's full-sized avatar
🏠
Working from home

Javier Campos javichur

🏠
Working from home
View GitHub Profile
Receta (desde Windows, con WSL2):
# git clone https://github.com/aws-deepracer-community/deepracer-for-cloud # clonar repo (solo la 1ª vez).
# sudo apt-get install jq awscli python3-boto3 docker-compose # instalar dependencias (solo la 1ª vez).
# docker swarm leave --force
bin/init.sh -a cpu -c local
# aws configure --profile minio # Configurar un perfil para S3 local (solo la 1ª vez).
@javichur
javichur / modeling_bart_custom_fragment.py
Created April 22, 2021 15:56
modeling_bart_for_custom_generation_custom_loss
# Original version: https://github.com/huggingface/transformers/blob/master/src/transformers/models/bart/modeling_bart.py
# Attempt for NLP Spain AI challenge (http://www.spain-ai.com/hackathon2020_reto_NLP.php)
# Loss_v2 = num_productos_no_acertados + porcentaje_tokens_no_acertados + 0,001 * default_loss
lm_logits = self.lm_head(outputs[0]) + self.final_logits_bias
masked_lm_loss = None
if labels is not None:
BATCH_SIZE = 8
cuda0 = torch.device('cuda:0')
const Sentry = require("@sentry/serverless");
Sentry.AWSLambda.init({
dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0', // cambiar por el DSN que te proporciona Sentry.
tracesSampleRate: 1.0,
});
exports.handler = Sentry.AWSLambda.wrapHandler(async (event, context) => {
// Your handler code
// TODO
/* eslint-disable no-console */
/* eslint-disable global-require */
// More info about Alexa Location Services:
// https://developer.amazon.com/es-ES/docs/alexa/custom-skills/location-services-for-alexa-skills.html
const auto = {
getFrescuraSegundos(handlerInput) {
var geoObject = handlerInput.requestEnvelope.context.Geolocation;
return (new Date(handlerInput.requestEnvelope.request.timestamp) - new Date(geoObject.timestamp)) / 1000; // freshness in seconds
@javichur
javichur / index.js
Created April 11, 2020 20:38
Alexa account linking Facebook
const HelloWorldIntentHandler = {
canHandle(handlerInput) {
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'HelloWorldIntent';
},
handle(handlerInput) {
var accessToken = handlerInput.requestEnvelope.context.System.user.accessToken; // obtener el Access Token (si lo hay)
var speechText = '';
if (accessToken == undefined){
const https = require('https');
const mode = 'prod'; // dev or 'prod'
const clientID = 'xxx'; // obtenido de consola web de Alexa developers.
const clientSecret = 'xxx'; // obtenido de consola web de Alexa developers.
let tokenGlobal = null; // se usa para enviar notificaciones. Dura 1h. Se rellena en notify().
// Ejemplo de envío de una notificación
const who = 'cake';
@javichur
javichur / skill.json
Created January 25, 2020 16:38
Añadiendo soporte para notificaciones en una skill Alexa
{
"manifest": {
"apis": {
// ...
},
"manifestVersion": "1.0",
"privacyAndCompliance": {
// ...
},
"publishingInformation": {
...
"types": [
{
"name": "LIST_OF_PRODUCT_NAMES",
"values": [
{
"id": "nameproductpurchase", /* id de producto comprable (isp)*/
"name": {
"value": "suscripción premium",
"synonyms": [
/* Ejemplo de intent handler que sugiere la compra del in-skill purchase si no se
* ha comprado ya antes y además el usuario puede comprarlo (purchasable)
*/
const HelloWorldIntentHandler = {
canHandle(handlerInput) {
return handlerInput.requestEnvelope.request.type === 'IntentRequest'
&& handlerInput.requestEnvelope.request.intent.name === 'HelloWorldIntent';
},
handle(handlerInput) {
SessionState.setCurrentState(handlerInput, SessionState.STATES.HELLO_WORLD);
const skillBuilder = Alexa.SkillBuilders.custom();
exports.handler = skillBuilder
.addRequestHandlers(
...
PurchaseHandlers.WhatCanIBuyIntentHandler, // purchase handlers
PurchaseHandlers.TellMeMoreAboutProductIntentHandler,
PurchaseHandlers.BuyIntentHandler,
PurchaseHandlers.BuyResponseHandler,
PurchaseHandlers.PurchaseHistoryIntentHandler,
PurchaseHandlers.RefundProductIntentHandler,