Skip to content

Instantly share code, notes, and snippets.

View pmioduszewski's full-sized avatar
🔵

Pawel Mioduszewski pmioduszewski

🔵
View GitHub Profile
@Spencer-Easton
Spencer-Easton / XMLtoJSON
Created April 8, 2015 17:30
Script to convert XML to JSON using XmlService - Originaly published in a +Google Apps Script community thread by Eric Koleda
/**
* Converts an XML string to a JSON object, using logic similar to the
* sunset method Xml.parse().
* @param {string} xml The XML to parse.
* @returns {Object} The parsed XML.
*/
function xmlToJson(xml) {
var doc = XmlService.parse(xml);
var result = {};
var root = doc.getRootElement();
@fevangelou
fevangelou / default.vcl_PREFACE.md
Last active April 9, 2024 04:30
The perfect Varnish configuration for WordPress, Joomla, Drupal & other (common) CMS based websites

The perfect Varnish configuration for WordPress, Joomla, Drupal & other (common) CMS based websites

Updated on December 15th, 2021

IMPORTANT: Read this before implementing one of the configuration files below (for either Varnish 3.x or 4.x+).

USE: Replace the contents of the main Varnish configuration file located in /etc/varnish/default.vcl (root server access required - obviously) with the contents of the configuration you'll use (depending on your Varnish version) from the 2 examples provided below.

IMPORTANT: The following setup assumes a 180 sec (3 minute) cache time for cacheable content that does not have the correct cache-control HTTP headers. You can safely increase this to 300 sec (or more) for less busier sites or drop it to 60 sec or even 30 sec for high traffic sites. It obviously depends on your use case.

Oh my zsh.

Install with curl

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Enabling Plugins (zsh-autosuggestions & zsh-syntax-highlighting)

  • Download zsh-autosuggestions by
@neveldo
neveldo / Logger.gs
Last active November 5, 2020 18:25
Google Apps Script : send server logs to the browser console
/**
* Set of function that allow log messages to be retrieved from the view in order to be displayed
* into the regular JS console
*/
/**
* Push one or several objects into the log stack
* @param obj1 ... objN A list of JavaScript objects to log.
*/
function log() {
@tanaikech
tanaikech / submit.md
Last active June 5, 2024 05:54
Downloading Shared Files on Google Drive Using Curl

Downloading Shared Files on Google Drive Using Curl

When the shared files on Google Drive is downloaded, it is necessary to change the download method by the file size. The boundary of file size when the method is changed is about 40MB.

File size < 40MB

CURL

filename="### filename ###"
fileid="### file ID ###"
curl -L -o ${filename} "https://drive.google.com/uc?export=download&amp;id=${fileid}"
@tanaikech
tanaikech / submit.md
Last active December 27, 2022 09:26
Enhanced onEdit(e) using Google Apps Script

Enhanced onEdit(e) using Google Apps Script

onEdit(e) which is used for the Edit event on Spreadsheet has the old value as e.oldValue. The specifications for this are as follows.

  1. When an user edited a single "A1" cell, e of onEdit(e) shows hoge for e.oldValue and fuga for e.value.
  2. When an user edited the "A1:A2" multiple cells, e.oldValue and e.value of onEdit(e) are not shown anything.
  3. When an user copied and pasted from other cell, e.oldValue and e.value of onEdit(e) are not shown anything.

This sample script was created to retrieve both the edited values and the old values for the range of edited cells. This is the modified e.oldValue.

@NikitaAvvakumov
NikitaAvvakumov / code.js
Last active September 30, 2020 06:23
Google Apps Script - send spreadsheet changes to an external API
// provided `onEdit` trigger cannot use `UrlFetchApp.fetch`.
// create a custom-named function, then add it as a new trigger in "Edit" > "Current Project Triggers"
// with events "From spreadsheet" > "On edit"
function customOnEdit(e) {
const range = e.range;
const row = range.getRow();
const sheet = e.source.getActiveSheet();
const data = {
vendor: sheet.getRange(row, 1).getValue(),
@unnikked
unnikked / README.md
Last active February 19, 2024 02:58
How to host your Telegram bot on Google App Script

Telegram Bot on Google App Script

This is the source code of one of my blog post. To read the full blog post please click here.

@tanaikech
tanaikech / submit.md
Last active January 24, 2023 12:01
Open Site with New Window using Google Apps Script

Open Site with New Window using Google Apps Script

This is a sample script for opening a site with new window using Google Apps Script. It is possible to open the site inside the opened dialog box using iframe. But in my situation, I had to open the site as new window. So I created this. As a sample application, it can think of like this. When the special keyword was inputted, open sites and files in Google Drive as a help window. In this case, the trigger installed onEdit() is required to be used. I think that there are some other applications.

Demo :

Sample script :

function myFunction() {
 var js = " \
@bennettscience
bennettscience / onEdit.gs
Last active May 9, 2023 07:22
Dynamic data validation in Apps Script
function onEdit(e) {
var row = e.range.getRow();
var col = e.range.getColumn();
// If the edited column was 2 or 3, do the next part. Ignore other changes
if(col == 2 || col == 3) {
var value = sheet.getRange(row, col).getValue();
updateList(row,col, value);
}
}