show dbs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
| "NodeJS base64 encode unction": { | |
| "scope": "javascript", | |
| "prefix": "base64 encode function", | |
| "body": [ | |
| "function toBase(string) {", | |
| "\treturn Buffer.from(string).toString('base64');", | |
| "}" | |
| ], | |
| "description": "Function to Base64 encode a string in NodeJS" | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const crypto = require('crypto'); | |
| const algorithm = 'aes-256-ctr'; | |
| let key = 'asupersecretpassword'; | |
| key = crypto.createHash('sha256').update(key).digest(); | |
| const encrypt = (buffer) => { | |
| // Create an initialization vector | |
| const iv = crypto.randomBytes(16); | |
| // Create a new cipher using the algorithm, key, and iv | |
| const cipher = crypto.createCipheriv(algorithm, key, iv); |
This is an overhauled approach to an older script that I was running for a while to clean up my Gmail. This script can delete old emails automatically and sort old emails from the inbox to folders (labels).
- Create a new Google Apps Script at https://script.google.com and overwrite the placeholder content with the javascript below.
- Create a google spreadsheet which will be used to store and easily update your configurations.
- In the Spreadsheet create a table with the same headers from the following example.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class BigDater { | |
| constructor() { | |
| this.date = new Date(); | |
| this.weekStart = this.dateGetter(this.date,-(this.date.getDay())); | |
| this.nextWeek = this.dateGetter(this.weekStart,7); | |
| this.nextWeekEnd = this.dateGetter(this.nextWeek,7); | |
| this.lastWeek = this.dateGetter(this.weekStart,-7); | |
| this.weekBeforeLast = this.dateGetter(this.lastWeek,-7); | |
| } | |
| dateGetter(dateObj,adjust) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const START_ADDRESS = '1600 Pennsylvania Avenue NW, Washington, DC 20500' // replace with the starting address you want | |
| /** | |
| * Return the driving distance from a specified start location. | |
| * The argument passed to the function can be an address or a place or array of those things. | |
| * | |
| * @param {string|array} location - Address or name of place. This can also be an array. | |
| * @returns {string|array} distance - The travel distance by car in one direction. | |
| * @customfunction | |
| */ |
Automatically deletes old emails that match the specified label.
- Create a new Google Apps Script at https://script.google.com
- Overwrite the placeholder with the javascript below
- Update the following constants:
LABEL_TO_DELETE: the label that should be have old messages deleted