Skip to content

Instantly share code, notes, and snippets.

View danielcranney's full-sized avatar

Daniel Cranney danielcranney

View GitHub Profile
@danielcranney
danielcranney / WelcomeModal.tsx
Created March 17, 2025 19:09
Supabooking Welcome Modal
<div className="flex flex-col gap-y-1.5 bg-white sm:max-w-[780px]">
<div className="flex justify-between items-start">
<h2 className="font-bold text-xl">Welcome to Supabooking 👋</h2>
{/* <Button variant="ghost" className="p-0 h-auto" onClick={onClose}>
<X className="w-4 h-4" />
</Button> */}
</div>
<p className="font-bold text-base">
Your account is now active and ready to use!
@danielcranney
danielcranney / 09 - logUnsubscribes() complete code.js
Created November 1, 2024 10:21
newsletter unsubscription tracker / 09 - logUnsubscribes() complete code.js
// Logs emails from threads labeled "unsubscribed" to a Google Sheet
function logUnsubscribes() {
var label = GmailApp.getUserLabelByName('unsubscribed');
var threads = label.getThreads();
var sheet = SpreadsheetApp.open(DriveApp.getFileById('1v77gBSUzF7evN5Rlnvsz27LgoHgowiLivPpAGeTMgBQ'));
threads.forEach(function(thread) {
var messages = thread.getMessages();
messages.forEach(function(message) {
var body = message.getBody();
@danielcranney
danielcranney / 08 - isAlreadyLogged() helper function.js
Created November 1, 2024 10:21
newsletter unsubscription tracker / 08 - isAlreadyLogged() helper function.js
// Helper function to check if an email is already in the sheet
function isAlreadyLogged(email, sheet) {
var data = sheet.getDataRange().getValues(); // Get all values in the sheet
for (var i = 0; i < data.length; i++) {
if (data[i][0] === email) {
return true; // Return true if email is already logged
}
}
return false; // Return false if the email is not in the sheet
}
@danielcranney
danielcranney / 07 - extractEmail() helper function.js
Created November 1, 2024 10:20
newsletter unsubscription tracker / 07 - extractEmail() helper function.js
// Helper function to extract the first email address found in a given text
function extractEmail(body) {
var emailPattern = /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/; // Regex pattern to match an email address
var match = body.match(emailPattern); // Find the first email that matches the pattern
return match ? match[0] : null; // Return the email if found, otherwise return null
}
@danielcranney
danielcranney / 06 - read the contents of the emails.js
Created November 1, 2024 10:20
newsletter unsubscription tracker / 06 - read the contents of the emails.js
// Logs emails from threads labeled "unsubscribed" to a Google Sheet
function logUnsubscribes() {
var label = GmailApp.getUserLabelByName('unsubscribed');
var threads = label.getThreads();
var sheet = SpreadsheetApp.open(DriveApp.getFileById('1v77gBSUzF7evN5Rlnvsz27LgoHgowiLivPpAGeTMgBQ'));
threads.forEach(function(thread) {
var messages = thread.getMessages();
messages.forEach(function(message) {
var body = message.getBody(); // Get the body content of the email
@danielcranney
danielcranney / 05 - get all messages in thread.js
Created November 1, 2024 10:19
newsletter unsubscription tracker / 05 - get all messages in thread.js
// Logs emails from threads labeled "unsubscribed" to a Google Sheet
function logUnsubscribes() {
var label = GmailApp.getUserLabelByName('unsubscribed');
var threads = label.getThreads();
var sheet = SpreadsheetApp.open(DriveApp.getFileById('1v77gBSUzF7evN5Rlnvsz27LgoHgowiLivPpAGeTMgBQ'));
threads.forEach(function(thread) {
var messages = thread.getMessages(); // Get all messages in the thread
});
}
@danielcranney
danielcranney / 04 - connect to Google sheet.js
Created November 1, 2024 10:19
newsletter unsubscription tracker / 04 - connect to Google sheet.js
// Logs emails from threads labeled "unsubscribed" to a Google Sheet
function logUnsubscribes() {
var label = GmailApp.getUserLabelByName('unsubscribed'); // Fetch the "unsubscribed" label from Gmail
var threads = label.getThreads(); // Get all threads with this label
var sheet = SpreadsheetApp.open(DriveApp.getFileById('REPLACE_WITH_GOOGLE_SHEET_ID')); // Open the target Google Sheet
}
@danielcranney
danielcranney / 03 - get threads with the unsubscribed label.js
Created November 1, 2024 10:18
newsletter unsubscription tracker / 03 - get threads with the unsubscribed label.js
// Logs emails from threads labeled "unsubscribed" to a Google Sheet
function logUnsubscribes() {
var label = GmailApp.getUserLabelByName('unsubscribed'); // Fetch the "unsubscribed" label from Gmail
var threads = label.getThreads(); // Get all threads with this label
}
@danielcranney
danielcranney / 02 - fetch unsubscribed label from gmail.js
Created November 1, 2024 10:18
newsletter unsubscription tracker / 02 - fetch unsubscribed label from gmail.js
// Logs emails from threads labeled "unsubscribed" to a Google Sheet
function logUnsubscribes() {
var label = GmailApp.getUserLabelByName('unsubscribed'); // Fetch the "unsubscribed" label from Gmail
}
@danielcranney
danielcranney / 01 - create logUnsubscribes().js
Created November 1, 2024 10:18
newsletter unsubscription tracker / 01 - create logUnsubscribes().js
// Logs emails from threads labeled "unsubscribed" to a Google Sheet
function logUnsubscribes() {
// Additional code will go here
}