Posts

Showing posts from March, 2023

Useful NPM Tips and Tricks for Developers to Boost Productivity

Image
NPM, short for Node Package Manager, is a widely-used tool for managing JavaScript packages in a project. It allows developers to install and update packages, as well as manage dependencies and scripts. NPM comes bundled with Node.js, so if you have Node installed on your machine, you automatically have access to NPM as well. npm Commands You Should Know This is not a tutorial for learning npm, the official docs are a good place to get started, but a collection of tips and tricks that will help you do more with the npm utility. Whether you’re a seasoned developer or just starting out, these tips can help you be more efficient and productive in your work with npm. Instantly run packages without installing The NPM registry is a treasure trove for finding packages that do useful stuff and they aren’t just for programmers . For instance, the speed-test package shows the speed of your internet connection. The emoj package helps you search for emojis from the terminal. And the...

Automating the Creation of Multiple Folders in Google Drive

Image
A teacher may want to create folders in Google Drive for each of their students and share those folders with the students. This can be a tedious task if you have a large number of students but there’s a way to automate the process - you may either use an add-on or write an Apps Script to generate the folder structure. Prepare the Students’ Data in Google Sheets We’ve prepared a Google Sheet with the names of students, their corresponding classes and email addresses. The first row of the sheet displays the column titles, while the student data starts from row two onwards. The folder structure in Google Drive would be as follows - the parent folder would have sub-folders for each class and each class folder would have sub-folders for each student. The student folders would be shared with the student’s email addresses where students can upload their work. Bulk Create Folders in Google Drive Install the Document Studio add-on for Google Sheets. Open the spreadsheet with the s...

Lite YouTube Embeds - A Better Method for Embedding YouTube Videos on your Website

Image
It is easy to embed a YouTube video but you’ll be surprised to know how much extra weight a single YouTube video embed can add to your web pages. The browser has to download ~900 kB of data (see screenshot) for rendering the YouTube video player alone. And these files are downloaded even before the visitor has clicked the play button. The embedded YouTube video not only increases the byte size of your web pages but the browser has to make multiple HTTP requests to render the video player. This increases the overall loading time of your page thus affecting the page speed and the core vitals score of your website. The other drawback of the default YouTube embed code is that it renders a video player of fixed dimensions and isn’t responsive . If people view your website on a mobile phone, or a tablet, the video player may not resize properly on the small screen. Embed YouTube Videos without Increasing Page Size Google+, which is now retired, made use of a very clever technique f...

How to Efficiently Read Email Messages with the Gmail API and Apps Script

The Email Address Extractor add-on for Gmail helps you extract email addresses of your customers from your Gmail messages and writes them to a Google Sheet. It internally uses the Gmail API to fetch the messages and the Google Sheets API to write the email addresses to a Google Sheet. There are two ways to pull email addresses from Gmail messages. The simpler, and more popular, method is that you pull a list of messages from which you wish to extract the email and loop over them to extract the email addresses. // Pull details of emails from PayPal, Stripe or Shopify function getEmailAddress ( ) { const threads = GmailApp . search ( 'from:paypal OR from:stripe OR from:shopify newer_than:2d' , 0 , 10 ) ; threads . forEach ( ( thread ) => { const messages = thread . getMessages ( ) ; messages . forEach ( ( message ) => { Logger . log ( 'Subject: ' + message . getSubject ( ) ) ; Logger . log ( 'To: ' + message...