This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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'; |
This file contains hidden or 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
// given a column 'A'...'AB' etc, return a numeric index | |
function columnToIndex(column) { | |
// Initialize the index to 0 | |
var index = 0; | |
// Iterate through the characters in the column string | |
for (var i = 0; i < column.length; i++) { | |
// Get the character at the current index | |
var char = column.charAt(i); |
This file contains hidden or 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
// JSON geocode returned | |
function doNativeGeoCode(address) { | |
var response = Maps.newGeocoder().setBounds(32.85964933715685, -117.32946858722974, 32.70248574032382, -117.0346293702513).geocode(address); | |
return response; | |
} | |
// JSON geocode returned | |
function doApiGeoCode(address) { | |
var options = { | |
muteHttpExceptions: true, |
This file contains hidden or 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
// addresses "Exception: Service invoked too many times for one day: geocode" because the built-in Maps App does not support API keys | |
// you must create an API key in Maps API in the Google Cloud Console for insertion into Script Properties `mapsApiKey` | |
function doGeoCode(address) { | |
var serviceUrl = `https://maps.googleapis.com/maps/api/geocode/json?address=${address}&key=${ScriptProperties.getProperty('mapsApiKey')}`; | |
var response=UrlFetchApp.fetch(serviceUrl, options); | |
if(response.getResponseCode() == 200) { | |
var responseJSON = JSON.parse(response.getContentText()); | |
if (responseJSON !== null) { return responseJSON; } | |
} |
This file contains hidden or 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
#!/bin/sh | |
# v1.0 | |
wd="/tmp/IPCAM" | |
mkdir -p $wd | |
rm -f $wd/* | |
tar -cf $wd/config.tar -C ./ mnt/mtd |
This file contains hidden or 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
#!/bin/sh | |
# FTP_COPY version 0.3 by MP77V www.4pda.ru | |
# ---------------------------- | |
FTP_DEST_DIR="/FTP_directory" | |
FTP_DEST_HOST="FTP_host" | |
FTP_DEST_PORT="21" | |
FTP_DEST_LOGIN="FTP_user" | |
FTP_DEST_PASS="FTP_password" | |
# ---------------------------- |