Skip to content

Instantly share code, notes, and snippets.

View Strusovsky's full-sized avatar

Andrew Strusovsky Strusovsky

View GitHub Profile
// 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) {
@Strusovsky
Strusovsky / Timer.gs
Created December 11, 2021 16:49 — forked from Max-Makhrov/Timer.gs
Timer is a code for monitoring onMinute triggers
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
/* global UrlFetchApp:false */
// eslint-disable-next-line no-unused-vars
function myTime(par) {
"use strict";
var objectName = "myTime";
var mainSpreadSheetId = par.mainSpreadsheetId;
var mainSpreadsheet;
var hourSheet;
var codesSheet;
var dataRange;
/**
* The time manager manages the time in your script. The timemanager keeps track of
* the time spend and can tell you how much time is left.
*
* This manager is usefull in background scripts that will be killed by apps script
* after some time. Every time before starting an operation you can see if you can
* acquire time to perform the operation. If there is not enough time left you can
* exit the program gracefully.
*
* @param {object} spec - specification for the construction of the object
@Strusovsky
Strusovsky / submit.md
Created June 19, 2021 04:31 — forked from tanaikech/submit.md
Uploading Files of multipart/form-data to Google Drive using Drive API with Node.js

Uploading Files of multipart/form-data to Google Drive using Drive API with Node.js

These are the sample scripts for uploading files of multipart/form-data to Google Drive using Drive API with Node.js. In this case, googleapis for Node.js is not used.

In these sample script, the maximum file size is 5 MB. Please be careful this. When you want to upload the files more than 5 MB, please check this report.

Sample script 1

This sample script uploads a file using the modules of fs and request. Before you use this script, please prepare your access token for uploading the file.

@Strusovsky
Strusovsky / submit.md
Created June 19, 2021 04:28 — forked from tanaikech/submit.md
Using Values Submitted from HTML Form using Google Apps Script

Using Values Submitted from HTML Form using Google Apps Script

This is a sample script for using the values submitted from the HTML form using Google Apps Script and Javascript. In this case, the values include the files.

Issue

<form>
  Text: <input type="text" name="sampleText1" /><br />
 Single file: 
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
@Strusovsky
Strusovsky / main.js
Created January 30, 2021 18:40 — forked from webag/main.js
UTM to forms
/**************************************************
UTM to forms
***************************************************/
$(document).ready(function(){
if ('localStorage' in window) {
if (urlParams('utm_source') != null ||
urlParams('utm_medium') != null ||
urlParams('utm_content') != null ||
urlParams('utm_campaign') != null ||
@Strusovsky
Strusovsky / send.php
Created January 30, 2021 18:38 — forked from webag/send.php
PHP Добавление контакта и сделки в amocrm с полями из формы сайта.
<?
//amo
//ПРЕДОПРЕДЕЛЯЕМЫЕ ПЕРЕМЕННЫЕ
$responsible_user_id = 7292136; //id ответственного по сделке, контакту, компании
$lead_name = 'Заявка с сайта'; //Название добавляемой сделки
$lead_status_id = '11331793'; //id этапа продаж, куда помещать сделку
$contact_name = $cname; //Название добавляемого контакта
$contact_phone = $cphone; //Телефон контакта
@Strusovsky
Strusovsky / submit.md
Created August 23, 2020 14:40 — forked from tanaikech/submit.md
Switching Buttons for Google Spreadsheet using Google Apps Script

Switching Buttons for Google Spreadsheet using Google Apps Script

These are the sample scripts for achieving the switching buttons for Google Spreadsheet using Google Apps Script. The management of images using Spreadsheet service is growing now. But, in the current stage, in order to achieve the switching buttons, it needs a little ingenuity. In this report, I would like to introduce 4 kinds of the switching buttons.

Pattern 1

In this pattern, the drawing is used as the button.