Skip to content

Instantly share code, notes, and snippets.

View alexismp's full-sized avatar

Alexis MP alexismp

View GitHub Profile
@alexismp
alexismp / index.js
Last active November 8, 2022 21:58
Node.js 8 Cloud Function to write to a Google Sheets document
// Copyright 2018 Google LLC.
// SPDX-License-Identifier: Apache-2.0
const { google } = require("googleapis");
const { Storage } = require("@google-cloud/storage");
exports.csv2sheet = async (data, context) => {
var fileName = data.name;
// basic check that this is a *.csv file, etc...
if (!fileName.endsWith(".csv")) {
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Lecteur Ecard</title>
<link rel="stylesheet" href="https://www.cartesvirtuelles.fr/inc/css/reset.css">
<!-- <link rel="stylesheet" href="inc/css/styles.css?v--><!--">-->
@alexismp
alexismp / index.js
Last active May 8, 2020 14:45
csv2sheet populateAndStyle
function populateAndStyle(sheetsAPI, theData, sheetId) {
return new Promise((resolve, reject) => {
// Using 'batchUpdate' allows for multiple 'requests' to be sent in a single batch.
// Populate the sheet referenced by its ID with the data received (a CSV string)
// Style: set first row font size to 11 and to Bold. Exercise left for the reader: resize columns
const dataAndStyle = {
spreadsheetId: process.env.SPREADSHEET_ID,
resource: {
requests: [
{
@alexismp
alexismp / ffmpeg-combine.sh
Last active April 16, 2020 21:38
ffmpeg combine two videos and audio into one
ffmpeg -i solo.mkv -i accompagnement-trimmed.mkv -filter_complex "[0:v][1:v]hstack=inputs=2[v]; [0:a][1:a]amerge[a]" -map "[v]" -map "[a]" -ac 2 valse-melanco.mkv
@alexismp
alexismp / ffmpeg-trim.sh
Created April 16, 2020 21:38
trim beginning by 3 seconds
ffmpeg -i accompagnement.mkv -ss 3 -c copy accompagnement-trimmed.mkv
@alexismp
alexismp / index.js
Last active December 27, 2019 03:17
csv2sheet block and call functions
const sheetId = await addEmptySheet(sheetsAPI, sheetName);
const theData = await readCSVContent(sheetsAPI, data, sheetName);
await populateAndStyle(sheetsAPI, theData, sheetId);
@alexismp
alexismp / index.js
Last active July 15, 2019 19:52
csv2sheet readCSVContent (assumes CSV content, no parsing)
function readCSVContent(sheetsAPI, file, sheetName) {
return new Promise((resolve, reject) => {
const storage = new Storage();
let fileContents = new Buffer('');
let rows = [];
storage
.bucket(file.bucket)
.file(file.name)
.createReadStream()
.on("error", function(err) {
@alexismp
alexismp / package.json
Last active June 11, 2019 13:49
csv2sheet dependencies
{
"name": "csv2sheet",
"version": "0.0.42",
"dependencies": {
"googleapis": "^40.0.0",
"@google-cloud/storage": "^2.5.0"
}
}
@alexismp
alexismp / index.js
Last active June 11, 2019 13:49
Cloud Function csv2sheet - Part 1
const {google} = require("googleapis");
const {Storage} = require("@google-cloud/storage")
exports.csv2sheet = async (data, context) => {
var fileName = data.name;
// basic check that this is a *.csv file, etc...
if (!fileName.endsWith(".csv")) {
console.log("Not a .csv file, ignoring.");
return;
}
@alexismp
alexismp / index.js
Last active June 11, 2019 13:48
csv2sheet auth
const auth = await google.auth.getClient({
scopes: [
"https://www.googleapis.com/auth/spreadsheets",
"https://www.googleapis.com/auth/devstorage.read_only"
]
});