Skip to content

Instantly share code, notes, and snippets.

View scastrec's full-sized avatar

Stephane scastrec

View GitHub Profile
/** Create the entities by scanning all */
/**
* Waiting input:
* @param : json filename
* @param : json key for entities
*/
var fs = require('fs');
var rp = require('request-promise-native')
var chai = require('chai');
@scastrec
scastrec / alexa_encoder.sh
Created February 1, 2019 12:14
alexa_encoder enables to transform your mp3 files to be read in <audio> tag for Alexa
#!/bin/bash
mkdir mp3_ffmpeg
for i in *.mp3; do ffmpeg -i ${i} -ac 2 -codec:a libmp3lame -b:a 48k -ar 16000 "mp3_ffmpeg/${i%.*}.mp3"; done
@scastrec
scastrec / actions-on-google conversation mock
Last active November 12, 2018 14:57
This simple class helps testing Actions conversation
class Conv {
constructor() {
this.messages = [];
this.surface = {
capabilities : new Map()
};
this.closed = false;
}
@scastrec
scastrec / entities.creator.js
Last active May 25, 2019 22:16
A simple script to create simple entities for Dialogflow from json source
/**
* Waiting input:
* @param : json filename
* @param : json key for entities
*/
var fs = require('fs');
//var file = fs.readFileSync('data/' + argv.file, 'utf8');
const file = process.argv[2];
const key = process.argv[3];
@scastrec
scastrec / Dockerfile
Last active October 26, 2015 09:00
Dockerfile for NodeJS + generating PDF with phantom-html2pdf
FROM centos:centos7
# Enable EPEL for Node.js
RUN rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# Install Node.js and npm
RUN yum install -y npm
# Install bzip2
RUN yum install -y bzip2
# Install lib for phantom
RUN yum install -y freetype
@scastrec
scastrec / gist:56fe2af41a4ecb2edb52
Last active August 29, 2015 14:13
Thrift to Json with Field filter
//Solution to convert thrift to pojo to send back to client
// only some fields
public List<JsonObject> mapping(List<TBase> listThrift){
TSerializer serializer = new TSerializer(new TSimpleJSONProtocol.Factory());
ObjectMapper mapper = new ObjectMapper();
for(TBase f : listThrift) {
myJsonList.add(mapper.readValue(serializer.toString(f), MyJsonJson.class));
}
return myJsonList;
}