Snippets Collections
function shareActive() {
  var ss = SpreadsheetApp.getActive();
  var sheet = ss.getActiveSheet();

  var newSheet = SpreadsheetApp.create("New Sheet");
  var id = newSheet.getId();
  var open = SpreadsheetApp.openById(id);
  
  var copy = sheet.copyTo(open);

  var ui = SpreadsheetApp.getUi();
  var user = ui.prompt('Enter user email address', ui.ButtonSet.OK_CANCEL);

  if (
    user.getSelectedButton() == ui.Button.OK
  ) {
  var email = user.getResponseText()
  }

  DriveApp.getFileById(id).addEditor(email);
}

function onOpen(e) {
  SpreadsheetApp.getUi()
      .createMenu("Share Sheet")
      .addItem('Active Sheet', 'shareActive')
      .addToUi();
}
function sendMail(){
 var sh = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("SEPARATE REPORT");
 var data = sh.getRange("Q2:T3").getValues();
  //var htmltable =[];
  var emailAddress = "ashwani.kumar1@meenakshipolymers.com";
  var subject = "GURGAON PRODUCTIVITY REPORT";
  

  var tableFormat = 'cellspacing="50" cellpadding="6" dir="ltr" border="30" style="width:100%;table-layout:fixed;font-size:12pt;font-family:arial,sans,sans-serif;border-collapse:collapse;border:1px solid #ccc;font-weight:normal;color:black;background-color:white;text-align:center;text-decoration:none;font-style:normal;Cell:Merge Cell'
var htmltable = '<table ' + tableFormat +' ">';

for (row = 0; row<data.length; row++){

htmltable += '<tr>';
  


for (col = 0 ;col<data[row].length; col++){
  if (data[row][col] === "" || 0) {htmltable += '<td>' + '' + '</td>';} 
  else
    if (row === 0)  {
      htmltable += '<th>' + data[row][col] + '</th>';
    }

  else {htmltable += '<td>' + data[row][col] + '</td>';}
}

     htmltable += '</tr>';
}

     htmltable += '</table>';
     Logger.log(data);
     Logger.log(htmltable);
  MailApp.sendEmail({
       to: "vijaya.budhiraja@meenakshipolymers.com,sanjeevsoni@meenakshipolymers.com,sakshi.kapoor@meenakshipolymers.com,bijender.singh@meenakshipolymers.com,ashwani.kumar1@meenakshipolymers.com",
         subject:" GURGAON PRODUCTIVITY REPORT" ,
         htmlBody: htmltable
  })
}
function emailDocTestasDocx()
 {
  var id = '10odsSY4XX3TNhRjlmZoLOo2g3yNOP9g3pBebrk25G8g';// an example of Google doc
  var url = 'https://docs.google.com/spreadsheets/d/10odsSY4XX3TNhRjlmZoLOo2g3yNOP9g3pBebrk25G8g/edit#gid=754080197';
  var doc = DriveApp.getFileById(id); //used ID to get the file saved in your Drive using DriveApp.getFileById() method
  var me = Session.getEffectiveUser().getEmail();
  MailApp.sendEmail(me, 'test', 'see attachment', {attachments:[doc]}); //attach the file via email
}
/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.camel.component.google.drive;

import java.util.HashMap;
import java.util.Map;

import com.google.api.services.drive.model.Comment;
import com.google.api.services.drive.model.File;

import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.google.drive.internal.DriveCommentsApiMethod;
import org.apache.camel.component.google.drive.internal.DriveFilesApiMethod;
import org.apache.camel.component.google.drive.internal.GoogleDriveApiCollection;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Test class for com.google.api.services.drive.Drive$Comments APIs.
 */
public class DriveCommentsIntegrationTest extends AbstractGoogleDriveTestSupport {

    private static final Logger LOG = LoggerFactory.getLogger(DriveCommentsIntegrationTest.class);
    private static final String PATH_PREFIX = GoogleDriveApiCollection.getCollection().getApiName(DriveCommentsApiMethod.class).getName();
    
    @Test
    public void testComment() throws Exception {
        // 1. create test file
        File testFile = uploadTestFile();
        String fileId = testFile.getId();
        
        // 2. comment on that file
        Map<String, Object> headers = new HashMap<String, Object>();
        // parameter type is String
        headers.put("CamelGoogleDrive.fileId", fileId);
        // parameter type is com.google.api.services.drive.model.Comment
        com.google.api.services.drive.model.Comment comment = new com.google.api.services.drive.model.Comment();
        comment.setContent("Camel rocks!");
        headers.put("CamelGoogleDrive.content", comment);

        requestBodyAndHeaders("direct://INSERT", null, headers);

        // 3. get a list of comments on the file
        // using String message body for single parameter "fileId"
        com.google.api.services.drive.model.CommentList result1 = requestBody("direct://LIST", fileId);

        assertNotNull(result1.get("items"));
        LOG.debug("list: " + result1);
        
        Comment comment2 = result1.getItems().get(0);
        
        // 4. now try and get that comment 
        headers = new HashMap<String, Object>();
        // parameter type is String
        headers.put("CamelGoogleDrive.fileId", fileId);
        // parameter type is String
        headers.put("CamelGoogleDrive.commentId", comment2.getCommentId());

        final com.google.api.services.drive.model.Comment result3 = requestBodyAndHeaders("direct://GET", null, headers);

        assertNotNull("get result", result3);
        
        // 5. delete the comment
        
        headers = new HashMap<String, Object>();
        // parameter type is String
        headers.put("CamelGoogleDrive.fileId", fileId);
        // parameter type is String
        headers.put("CamelGoogleDrive.commentId", comment2.getCommentId());

        requestBodyAndHeaders("direct://DELETE", null, headers);

        // 6. ensure the comment is gone
        
        headers = new HashMap<String, Object>();
        // parameter type is String
        headers.put("CamelGoogleDrive.fileId", fileId);
        // parameter type is String
        headers.put("CamelGoogleDrive.commentId", comment2.getCommentId());

        try {
            final com.google.api.services.drive.model.Comment result4 = requestBodyAndHeaders("direct://GET", null, headers);
            assertTrue("Should have thrown an exception.", false);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            public void configure() {
                // test route for delete
                from("direct://DELETE")
                    .to("google-drive://" + PATH_PREFIX + "/delete");

                // test route for get
                from("direct://GET")
                    .to("google-drive://" + PATH_PREFIX + "/get");

                // test route for insert
                from("direct://INSERT")
                    .to("google-drive://" + PATH_PREFIX + "/insert");

                // test route for list
                from("direct://LIST")
                    .to("google-drive://" + PATH_PREFIX + "/list?inBody=fileId");

                // test route for patch
                from("direct://PATCH")
                    .to("google-drive://" + PATH_PREFIX + "/patch");

                // test route for update
                from("direct://UPDATE")
                    .to("google-drive://" + PATH_PREFIX + "/update");
                
                // just used to upload file for test
                from("direct://INSERT_1")
                    .to("google-drive://" + GoogleDriveApiCollection.getCollection().getApiName(DriveFilesApiMethod.class).getName() + "/insert");

            }
        };
    }
}




 



 
function myFunction() {
  let sheetData = SpreadsheetApp.getActiveSpreadsheet()
    .getSheetByName("Data")
    .getDataRange()
    .getValues();

  for (let i = 1; i < sheetData.length; i++) {
    Logger.log(sheetData[i][0]);
  }

  SpreadsheetApp.getActiveSpreadsheet()
    .getSheetByName("Data")
    .getDataRange()
    .setValues(sheetData);
}
async function autocomplete(text){
	return JSON.parse(await fetch("https://www.google.com/complete/search?q=testing&client=Firefox").then(res => res.text()))[1];
}
/**
 * Translates text to a certain language.
 * @param {String} text The text to translate (or an options object)
 * @param {String} target The target language to translate to.
 * @param {String} source The source language.
 * @returns {Promise.<object>} Returns a promise resolving into an object with the translated text, raw response JSON, the original text, and the target and source languages.
 * @example
 * var translated = await translate("Hello world", "fr");
 * // ⇒ 
 * // {
 * //   source: "en", 
 * //   original: "Hello world",
 * //   translated: "Bonjour le monde",
 * //   result: "weird google stuff here"
 * // }
 *
 */
async function translate(text, target, source, proxy) {
  if (typeof text == "object") {
    target = text.target;
    source = text.source;
    proxy = text.proxy;
    text = text.text;
  }
  var opts = {
    text: text || "",
    source: source || 'auto',
    target: target || "en",
    proxy: proxy || "",
	}
  var result = await fetch(
    `https://${opts.proxy}translate.googleapis.com/translate_a/single?client=gtx&sl=${opts.source}&tl=${opts.target}&dt=t&q=${encodeURI(opts.text)}`
  ).then(res => res.json());
  return {
    source: opts.source,
    target: opts.target,
    original: text,
    translated: result[0]?.[0]?.[0],
    result,
  };
}
Select a cell from where you want to start displaying the exchange rates. Type the formula: =GOOGLEFINANCE(“CURRENCY:GBPEUR”, “price”, TODAY()-10, TODAY(), “DAILY”)
  <script type="text/javascript" src="https://ssl.gstatic.com/trends_nrtr/2578_RC01/embed_loader.js"></script>
  <script type="text/javascript">
    trends.embed.renderExploreWidget("TIMESERIES", {"comparisonItem":[{"keyword":"Penticton","geo":"CA","time":"today 12-m"},{"keyword":"Kelowna","geo":"CA","time":"today 12-m"},{"keyword":"Osoyoos","geo":"CA","time":"today 12-m"}],"category":0,"property":""}, {"exploreQuery":"geo=CA&q=Penticton,Kelowna,Osoyoos&date=today 12-m,today 12-m,today 12-m","guestPath":"https://trends.google.com:443/trends/embed/"});
  </script>
add_action( 'wp_body_open', 'wpdoc_add_custom_body_open_code' );
 
function wpdoc_add_custom_body_open_code() {
    echo '<!-- Google Tag Manager (noscript) --> ... <!-- End Google Tag Manager (noscript) -->';
}
import numpy as np

def pagerank(M, num_iterations=100, d=0.85):
    N = M.shape[1]
    v = np.random.rand(N, 1)
    v = v / np.linalg.norm(v, 1)
    iteration = 0
    while iteration < num_iterations:
        iteration += 1
        v = d * np.matmul(M, v) + (1 - d) / N
    return v
star

Sat Jan 28 2023 06:42:03 GMT+0000 (UTC)

#google
star

Sat Dec 24 2022 04:29:09 GMT+0000 (UTC)

#google
star

Sat Oct 29 2022 17:10:20 GMT+0000 (UTC) https://www.javatips.net/api/camel-master/components/camel-google-drive/src/test/java/org/apache/camel/component/google/drive/DriveCommentsIntegrationTest.java

#apachecamel google drive #apache #camel #google #drive
star

Thu Jul 07 2022 14:59:25 GMT+0000 (UTC) https://webapps.stackexchange.com/questions/85043/craft-url-to-create-google-doc-in-specific-folder/89069

#google
star

Sat Apr 23 2022 21:56:15 GMT+0000 (UTC) https://www.quora.com/How-do-you-remove-all-text-to-the-left-of-the-last-on-Google-Sheets

#google #sheets
star

Wed Mar 30 2022 23:45:13 GMT+0000 (UTC) https://www.reddit.com/r/GoogleAppsScript/comments/hob5tn/issues_copying_csv_data_to_google_sheets/

#google #app #script
star

Mon Jan 10 2022 17:03:43 GMT+0000 (UTC) https://github.com/explosion-scratch/cool_apis

#javascript #api #js #autocomplete #google
star

Mon Jan 10 2022 17:02:09 GMT+0000 (UTC) https://github.com/explosion-scratch/cool_apis

#javascript #google #translate #api
star

Mon Jun 21 2021 14:12:28 GMT+0000 (UTC) https://trends.google.com/trends/explore?geo=CA&q=Penticton,Kelowna,Osoyoos

#html #stephanestonge #google
star

Fri Apr 02 2021 01:24:18 GMT+0000 (UTC) https://webapps.stackexchange.com/questions/87025/how-to-refer-to-this-cell-in-a-conditional-formatting-formula

#google #sheets
star

Sat Mar 06 2021 03:42:11 GMT+0000 (UTC) https://rckflr.com

#wordpress #google #tag #manager #function

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension