Skip to content

Instantly share code, notes, and snippets.

Avatar
😋

Max Makhrov Max-Makhrov

😋
View GitHub Profile
@Max-Makhrov
Max-Makhrov / telegrambot.gs
Last active Aug 12, 2021
Telegram Bot for Lazy
View telegrambot.gs
// __
// /_ |
// | |
// | |
// | |
// |_|
// Set Bot, copy token:
// https://t.me/botfather
// set your token ↓
var token = "1815465433:AAGpRcd--KsZycuSYmBOCDcVvws5lSvkuqw";
@Max-Makhrov
Max-Makhrov / googleFormOnSubmit.gs
Created Jun 10, 2021
Google Forms Script. Sample script on form submit. Get responses.
View googleFormOnSubmit.gs
// gentleman script for google forms
//
// gets submitted valus:
// 1. question label
// 2. question id
// 3. response value
//
// ⚠️ This is Form trigger.
// Open script editor from form interface
// Install it wia Triggers
@Max-Makhrov
Max-Makhrov / combine.gs
Last active Jun 9, 2021
Combine data from multiple sheets to 1
View combine.gs
// combine data from all sheets in current file
function combineData() {
// CHANGE SHEET NAME ↓ /////////////////////////////
var sheetTo = 'combined';
////////////////////////////////////////////////////
var file = SpreadsheetApp.getActiveSpreadsheet();
var sheets = file.getSheets(); // get all the sheets
// set where we want to write the results
var outSheet = file.getSheetByName(sheetTo);
var outdata = [], sheet, sName, data = [];
@Max-Makhrov
Max-Makhrov / Dependent DropDowns 2D Wide. v0.gs
Last active May 27, 2021
2D Dependent Dropdowns for Google Sheets. ~70 lines of code. Classy sample
View Dependent DropDowns 2D Wide. v0.gs
// Copy sample file here:
// https://docs.google.com/spreadsheets/d/1hUOuDZcfXxaLvJbEA-SxzF4oGGU3lW3iJyS4wAV8YWA/copy
function onEdit(e) {
dvl0_(e);
}
function dvl0_sets_() {
return [
{
@Max-Makhrov
Max-Makhrov / Code.gs
Created May 19, 2021
Google Script. HTML-form to select image from computer and save it to Google Drive and to Sheet cell as image.
View Code.gs
// sample file:
// https://docs.google.com/spreadsheets/d/1_rk4xFsMrxiuXqo5-HQWfvOjBU6nGDw1rlJFU0sci9U/copy
function onOpen() {
var ui = SpreadsheetApp.getUi();
// Or DocumentApp or FormApp.
ui.createMenu('🙂 Click me')
.addItem('Image 🖼️ to Drive', 'showFormImages')
.addToUi();
}
View parsUrls.gs
function test_parse() {
var file = SpreadsheetApp.getActive();
var sheet = file.getSheetByName('Sheet1'); // change
var sets = {
rangeParse: sheet.getRange('L2:L16429'), // change
rangeResult: sheet.getRange("M2"), // change
func_parse: parseOkkoFilmToGetHorizontalPoster_ // change / create your function
};
parseUrls_(sets);
}
@Max-Makhrov
Max-Makhrov / Timer.gs
Created Apr 23, 2021
Timer is a code for monitoring onMinute triggers
View Timer.gs
function readTimer() {
// [ 1 ]. Get report
var tags = ['onMinute_admin', 'onMinute_worker', 'onMinute_importer', 'onMinute_sizif1', 'onMinute_sizif2'];
var report = getTimerReps_(tags);
console.log(report);
// => gives 2D Array with a report about executions.
// So U can write it on Spreadsheet.
// [ 2 ]. Gat all data from logs
View History-gs.gs
// TODO
// 1. test
// 2. error handler
// 3. instructions on trigger installation
// AKfycbz7GZDZb3Yt1usqUkIu_lNOp4tW0xUKuFR9K_fIksIGuep2TeJ5RU0J
// the script assumes this structure of historic table:
// ______________________________________
@Max-Makhrov
Max-Makhrov / email_to_me.gs
Created Dec 3, 2020
Write emails to myself from Google Script functions
View email_to_me.gs
function someImportantFunction() {
// [ 1 ]. do some stuff
//
//
//
Logger.log('Success!');
// [ 2 ]. Report the execution
var recipient = 'makhrov.max@gmail.com'; // change!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//
View preventConflicts.gs
// The function may be used to prevent conflicting launches
function test_PreventConflict() {
// Lock(1). Use Script memory
var key = 'any-key-you-want';
var mem = PropertiesService.getScriptProperties();
// Lock(2). Check if other instance of the code is running
var from = mem.getProperty(key);
if (from) {