Skip to content

Instantly share code, notes, and snippets.

Send an email when a Google Doc's linked files are updated.
Add this script to a Google Apps Script project.
See the JSdoc at `autoDeclineMeetings()` for trigger setup instructions.
@yuhui
yuhui / set-link-titles-from-text-content-or-image-alt-text.js
Created January 5, 2023 03:54
Add titles to links based on the inner text content or image ALT text
@yuhui
yuhui / set-section-names-in-page-content.js
Last active January 20, 2023 15:18
Crawl a page's content DOM tree and set names in each section using a "data-" attribute
/**
* Add a "data-content-section-name" attribute to all page content sections.
*
* Page content sections are determined in this order:
* 1. Wherever there is a DIV with an "id" attribute in the container DIV.
* 2. DIVs that are immediate children of the container DIV.
* ... more methods can be added as required.
*
* In all cases, when the identified content section's DIV has a "data-content-section-name" attribute already,
* then that attribute is left alone.
@yuhui
yuhui / find-root-domain-with-cookie.js
Last active July 8, 2022 06:31
Find the root/apex domain from a web page's hostname by setting a cookie repeatedly starting from the top-level domain.
@yuhui
yuhui / adobe-experience-platform-web-sdk-data-collection-on-before-event-send-callback-code-improve-click-data-collection-for-custom-download-exit-links.js
Last active June 24, 2022 08:51
Adobe Web SDK: improve click data collection by not tracking "other" links automatically, and using the link URL as the link name for "download" and "exit" links.
@yuhui
yuhui / ruby-upgrade.sh
Created April 5, 2022 08:28
Update Ruby's RVM, ruby, and gems
#!/bin/bash
# Load RVM into a shell session *as a function*
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
# First try to load from a user install
source "$HOME/.rvm/scripts/rvm"
elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
@yuhui
yuhui / adobe-analytics-activity-map-rewrite-functions
Last active August 9, 2022 12:07
Adobe Analytics: Specify new functions that Adobe Analytics' Analytics Map should use for tracking links and regions
// update Activity Map to determine how to get its region and link
s.ActivityMap.originalRegion = s.ActivityMap.region;
s.ActivityMap.region = function(element) {
if (element) {
// set the region based on the element's (or ancestor's) "data-section-id" attribute
var currentElement = element;
var sectionId = currentElement.getAttribute('data-section-id');
while (!sectionId && (currentElement = currentElement.parentElement)) {
sectionId = currentElement.getAttribute('data-section-id');
}
@yuhui
yuhui / 0 Adobe Launch property scaffold using Adobe Web SDK to send events to Adobe Analytics.md
Last active March 19, 2024 02:45
Adobe Launch / Adobe Web SDK extension: scaffold for using Web SDK to send events for Analytics to consume, with Adobe Client Data Layer (ACDL) as the data layer.
@yuhui
yuhui / adobe-launch-experience-cloud-id-service-rule-action-append-visitor-ids-to-cross-domain-links.js
Last active May 18, 2022 02:14
Adobe Launch / Adobe Experience Cloud ID Service (ECID) extension: Append Experience Cloud IDs (visitor IDs) to cross-domain links using appendVisitorIDsTo().