Skip to content

Instantly share code, notes, and snippets.

@duynhm
duynhm / google sheet functions
Created November 28, 2023 05:37
tổng hợp các hàm Google Sheet thường sử dụng
//unpivot
=ArrayFormula(SPLIT(FLATTEN(B1:E1&"🦊"&A2:A4&"🦊"&B2:E4),"🦊"))
@duynhm
duynhm / CalendarFuncs.gs
Created November 28, 2023 05:09
Create bot for L&D include Trip bot and Send notify to email for attendees
//https://docs.google.com/spreadsheets/d/1VHaSalwgxWg7gCgQPr-lIGVsH9QebU4RO4of9d-ubTs/edit#gid=1626974869 link backend
//cần 1 hàm để tạo ra nhiều events tương ứng với từng sheet events
function createListEvent(){
//bước 1: đã có: menu danh sách các lớp - danh sách từng lớp theo từng sheet
//đọc menu lấy ra danh sách các lớp học
var sheetConf = getSheet("conf");
var countClass = getValueNotationBySheet(sheetConf,"B2");
var countReminder = getValueNotationBySheet(sheetConf,"B2");
@duynhm
duynhm / TripBot.gs
Created November 28, 2023 05:01
Create bot for Teambuilding Trip with features: 1. Inform, 2. Mini Game, 3. Checkin, 4.Share Photo. Make by Telegram bot and Google App Script
//@s_trip_bot
//group BTC:
var photoGroup = "-1002472";
var errorGroup = "-28682";
var token = "390126410:AAFPVtM4gK4";
var telegramUrl = "https://api.telegram.org/bot" + token;
var ssBotDb = "1xwp75RqDceKgTz4-tUfOk";
//var ssLog = SpreadsheetApp.openById(ssBotDb).getSheetByName("BotLog");
var ssCategory = SpreadsheetApp.openById(ssBotDb).getSheetByName("Menu");
var webhookURL = "https://script.google.com/macros/s/AKfycbwETnxP9bzRvK7XWpA7L/exec";
@duynhm
duynhm / InternalCommunityBot.gs
Created November 28, 2023 04:48
Create channel notify to employee with telegram bot and app script
var token = "567814838:AAG4Idptbdgvmnke";
var telegramUrl = "https://api.telegram.org/bot" + token;
var webhookURL = "https://script.google.com/macros/s/AKfycbzNwAMpdXYxEeCsIaftD7/exec";
var scriptProperty = PropertiesService.getScriptProperties();
var MENU = JSON.parse(scriptProperty.getProperty("Menu"));
function onOpen() {
var ui = SpreadsheetApp.getUi();
// Or DocumentApp or FormApp.
@duynhm
duynhm / checkInProcess.gs
Created November 28, 2023 04:39
Create checkin qrcode with bot telegram and submit web
function checkin(lat,lng) {
var addressHCM = {lat:10.8093425, lng:106.6756985};
//var addressHN = {lat:10.8093425, lng:106.6756985};
Logger.log(calculateDistanceTwoLocation(addressHCM.lat, lat, addressHCM.lng, lng));
}
//start checkin-YEP2017
function qrCode(){
if (/^\/start ([\w-]+)$/.test(text)) {
@duynhm
duynhm / Convert Sign to unsign character.gs
Created November 28, 2023 04:06
Convert sign character to unsign character, such as: Nguyễn to nguyen
function convert(str){
str = str.replace(/[^A-Za-z0-9\-_]/g, function(ch) {
// Character that look a bit like 'a'
if ("áàãạảâấầẩẫậăắằẳặẵ".indexOf(ch) >= 0) { // There are a lot more than this
return 'a';
}
if ("ÁÀÃẠẢÂẤẦẨẪẬĂẮẰẲẶẴ".indexOf(ch) >= 0) { // There are a lot more than this
return 'a';
}
if ("đ".indexOf(ch) >= 0) { // There are a lot more than this
@duynhm
duynhm / DrawOrgchartByGoogleChart.gs
Last active November 28, 2023 04:01
Draw Orgchart using google charts and custom data store in google sheet
function onOpen() {
SpreadsheetApp.getUi() // Or DocumentApp or SlidesApp or FormApp.
.createMenu('OrgChart')
// .addItem('Dialog', 'openDialog')
.addItem('Dialog', 'openDialog2')
.addItem('Slidebar', 'openSlideBar')
.addItem('OrgChart by JobTitle', 'openDialog3')
.addToUi();
}
@duynhm
duynhm / ConnectAirTable.gs
Created November 28, 2023 03:55
Connect AirTable for Talent Pool to Google Sheet with App Script
var API_KEY = "";
function onOpen() {
var ui = SpreadsheetApp.getUi();
// Or DocumentApp or FormApp.
ui.createMenu('Integrate')
.addItem('Get Requests', 'getRequest')//x
.addItem('Get Position', 'getPosition')//
.addItem('Get Progress', 'getProgress')//x
.addItem('Get Department', 'getDept')//x
@duynhm
duynhm / Report generation.yaml
Created September 10, 2018 07:20
Writes data to the workbook, reads and applies basic formatting, and adds a chart bound to that data. - Shared with Script Lab
name: Report generation
description: 'Writes data to the workbook, reads and applies basic formatting, and adds a chart bound to that data.'
author: duynhm
host: EXCEL
api_set: {}
script:
content: |
$("#create-report").click(() => tryCatch(createReport));
/** Load sample data into a new worksheet and create a chart */
@duynhm
duynhm / GET and POST Requests in Google Apps Script
Created March 29, 2018 02:38
GET and POST Requests in Google Apps Script
function doGet(e) {
if(typeof e !== 'undefined')
return ContentService.createTextOutput(JSON.stringify(e.parameter));
}
function doPost(e) {
if(typeof e !== 'undefined')