Skip to content

Instantly share code, notes, and snippets.

@camel113
camel113 / authentication.js
Created January 12, 2019 10:33
Authenticating Google Cloud Platform with environment variables (.dotenv)
const storage = new Storage({
projectId: projectId,
credentials: {
client_email: process.env.CLIENT_EMAIL,
private_key: process.env.PRIVATE_KEY.replace(/\\n/g, '\n')
}
});
@camel113
camel113 / sendVideo.js
Created January 4, 2019 06:59
Upload a video/file to GCP storage bucket and get its public URL
const getPublicUrl = (filename) => {
return `https://storage.googleapis.com/${bucket.name}/${filename}`;
}
const sendUploadToGCS = (req, res, next) => {
if (!req.file) {
return next();
}
console.log("Start to upload"+constants.processedVideosPath + req.file.filename)
const gcsname = Date.now() + req.file.originalname;
@camel113
camel113 / compressvideo.js
Created January 4, 2019 02:40
Compress Video with FFmpeg
const compressVideo = (req,res,next) => {
var cmd = 'ffmpeg';
var args = [
'-i', constants.rawVideosPath + req.file.filename,
'-c', 'copy',
'-vcodec', 'libx264',
'-crf', '24',
'-an', constants.processedVideosPath + req.file.filename
];
@camel113
camel113 / get_video_file_with_multer.js
Created January 2, 2019 10:43
Simply get a single uploaded file from form with Multer
app.post('/social_upload', upload.single('media'), function (req, res, next) {
// req.file is the `media` (video) file
// req.body will hold the text fields, if there were any
})
@camel113
camel113 / form.pug
Created January 2, 2019 10:29
Simple form with file input built with pug
html
head
title Social feed form
body
h1 Hello World
form(action="/socials/social_upload" method="post" enctype="multipart/form-data")
p
| social media:
input(type='file', name='media', value='')
input(type='submit', value='Submit')

Cas pratiques Query DSL et Filter DSL

####Rechercher les films avec les acteurs « Clint Eastwood » et « Lee Van Cleef »

GET ratings/movie/_search
{
  "query":{
    "bool": {
 "must": [

Cas pratiques Query String

Rechercher tous les films.

GET /ratings/_search

Rechercher les films avec « James » comme acteur ou « Michael » comme réalisateur.

<html>
<head>
<title>ol3 - Ex6C</title>
<link rel="stylesheet" href="http://openlayers.org/en/v3.1.1/css/ol.css" type="text/css">
<link rel="stylesheet" href="lib/layerswitcher/ol3-layerswitcher.css" type="text/css">
<script src="lib/ol3.1.1/build/ol.js" type="text/javascript"></script>
<script src="lib/jquery-2.1.3.min.js" type="text/javascript"></script>
<script type="text/javascript">
var map;
$(document).ready(function(){
@camel113
camel113 / newBulk.bat
Last active August 29, 2015 14:01
es movies
POST /_bulk
{ "create": { "_index": "ratings", "_type": "movie", "_id": "1" }}
{"title":"Django Unchained","date":"2013-01-16","directors":["Quentin Tarantino"],"actors":["Jamie Foxx","Christoph Waltz"],"types":["Western"],"presse_rating":4.5,"public_rating":4.6,"description":"Le parcours d'un chasseur de prime allemand et d'un homme noir pour retrouver la femme de ce dernier retenue en esclavage par le propriétaire d'une plantation..."}
{ "create": { "_index": "ratings", "_type": "movie", "_id": "2" }}
{"title":"Forrest Gump","date":"1994-10-05","directors":["Robert Zemeckis"],"actors":["Tom Hanks","Gary Sinise"],"types":["Comédie dramatique","Romance"],"presse_rating":2.6,"public_rating":4.5,"description":"Quelques décennies d'histoire américaine, des années 1940 à la fin du XXème siècle, à travers le regard et l'étrange odyssée d'un homme simple et pur, Forrest Gump."}
{ "create": { "_index": "ratings", "_type": "movie", "_id": "3" }}
{"title":"La Ligne verte","date":"2000-03-01","directors":["Frank Dar
POST /_bulk
{ "create": { "_index": "ratings", "_type": "movie", "_id": "1" }}
{"title":"Django Unchained","date":"2013-01-16","directors":["Quentin Tarantino"],"actors":["Jamie Foxx","Christoph Waltz"],"genres":["Western"],"presse_rating":4.5,"public_rating":4.6,"description":"Le parcours d'un chasseur de prime allemand et d'un homme noir pour retrouver la femme de ce dernier retenue en esclavage par le propriétaire d'une plantation..."}
{ "create": { "_index": "ratings", "_type": "movie", "_id": "2" }}
{"title":"Forrest Gump","date":"1994-10-05","directors":["Robert Zemeckis"],"actors":["Tom Hanks","Gary Sinise"],"genres":["Comédie dramatique","Romance"],"presse_rating":2.6,"public_rating":4.5,"description":"Quelques décennies d'histoire américaine, des années 1940 à la fin du XXème siècle, à travers le regard et l'étrange odyssée d'un homme simple et pur, Forrest Gump."}
{ "create": { "_index": "ratings", "_type": "movie", "_id": "3" }}
{"title":"La Ligne verte","date":"2000-03-01","directors":["Frank D