This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getAllFiles(folderId) { | |
const accumulated = []; | |
const folder = DriveApp.getFolderById(folderId); | |
// Function to copy a file to GCS, handling file or folder path as argument | |
function traverseOrReturnItem(item, currentPath) { | |
const itemName = item.getName(); // Handles file or folder names | |
const thisPath = `${currentPath}${currentPath ? "/" : ""}${itemName}`; // Construct GCS object key | |
// if (typeof item === 'object' && item.getMimeType() ? false : true && DriveApp.getFolderById(item.getId()) ? true : false) { // If it's a folder, process contents recursively |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>URL Parameter Stripper</title> | |
</head> | |
<body> | |
<h1>URL Parameter Stripper</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# See: https://medium.com/@lakshmanok/how-to-load-geojson-files-into-bigquery-gis-9dc009802fb4 | |
import json | |
import sys | |
def convert_geojson(input_file_path): | |
with open(input_file_path, 'r') as ifp: | |
with open('to_load.json', 'w') as ofp: | |
features = json.load(ifp)['features'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://medium.com/google-cloud/how-to-load-geojson-files-into-bigquery-gis-9dc009802fb4 | |
// Javascript (NodeJS) vs Python | |
function convertGeoJsonBq() { | |
const fs = require('fs'); | |
fs.readFile(process.argv[1], 'utf8', (err, data) => { | |
if (err) throw err; | |
const geojson = JSON.parse(data); | |
const features = geojson.features; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const options = { | |
'muteHttpExceptions': true, | |
'followRedirects': false | |
}; | |
function getStatusCode(url) { | |
const url_trimmed = url.trim(); | |
let cache = CacheService.getScriptCache(); | |
let result = cache.get(url_trimmed); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create external table from CSV or Google Sheet, autodetect schema | |
function bqCreateCsvTable(csvDriveFileId) { | |
const CONFIG = setConfig(); | |
let csvFile = DriveApp.getFileById(csvDriveFileId); | |
let tableId = csvFile.getName(); | |
let bqConfig = { | |
"tableReference": { | |
"projectId": CONFIG.projectId, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function doGet(e) { | |
// Look up the function for the specified endpoint | |
var handler = getEndpointHandlers[e.parameter.action]; | |
if (handler) { | |
// Call the appropriate function for the endpoint | |
return handler(e); | |
} else { | |
// Return an error if the endpoint is not recognized | |
return ContentService.createTextOutput("Error: Invalid GET endpoint.").setMimeType(ContentService.MimeType.TEXT); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://www.labnol.org/code/19721-add-tags-google-drive-files | |
/* | |
setDescriptionToFolderNames | |
Workaround to fake Tags in Google Drive. | |
Writes all the folder names of a file into the file description, so that the file can be found by searching the folder names. | |
*/ | |
function setDescriptionToFolderNames() { | |
var file; | |
var filename; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get the canvas and its context | |
var canvas = document.querySelector('#paint'); | |
var ctx = canvas.getContext('2d'); | |
// Get the parent element of the canvas and its computed style | |
var sketch = document.querySelector('.sketch'); | |
var sketch_style = getComputedStyle(sketch); | |
// Set the canvas dimensions to match the parent element | |
canvas.width = parseInt(sketch_style.getPropertyValue('width')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(window){ | |
// Define the Pen object, which handles drawing on the canvas | |
var Pen = function(context){ | |
// Whether the user is currently drawing | |
var drawing; | |
// Reset the pen's drawing style | |
this.reset = function(){ | |
context.beginPath(); | |
context.lineCap = 'round'; |
NewerOlder