Skip to content

Instantly share code, notes, and snippets.

@gesslar
gesslar / isOrderGuide.js
Created January 21, 2019 15:55
Determining if the current item is part of an Order Guide in ServiceNow Client Script
function onLoad() {
var isOrderGuide = g_service_catalog.isOrderGuide();
if(isOrderGuide) {
g_form.addInfoMessage("We're part of an order guide!");
} else {
g_form.addInfoMessage("We are not a part of an order guide.");
}
}
@gesslar
gesslar / DailyBirthdayReminders.js
Last active February 11, 2020 04:19
Google Apps Script Daily Birthday Notifications
function run() {
const names = [];
const today = new Date();
const calendars = CalendarApp.getAllCalendars();
const pat = /^(.*)\'s birthday$/;
const subject = `Birthday Notifications for ${today.toString()}`;
const body = "The following birthdays occur today:";
const myEmail = Session.getActiveUser().getEmail();
calendars.forEach( calendar => {
@gesslar
gesslar / Email Summary Bot.gs
Last active April 13, 2021 20:38
Daily Email Summary posts to Google Chat webhook - Number of emails, labels used, unique senders;
const dateBoundaryFactory = (today = new Date()) => {
const yesterday = new Date(today)
const yesternight = new Date(today)
// set yesterday to 00:00:00
yesterday.setDate(today.getDate() - 1)
yesterday.setHours(0)
yesterday.setMinutes(0)
yesterday.setSeconds(0)
@gesslar
gesslar / Gmail Notifications to Chat.gs
Last active April 13, 2021 20:41
Gmail Notifications to Chat - Notify on Google Chat when new messages/threads specified labels appear
/**
* Email Notifications to Chat
*
* Attach this script to a Sheet with two columns
* Column A - Label
* Column B - Webhook
*
* NOTE: This script will skip the first row and only use the first two columns.
*
* In column A (Label), list all of the labels for which you would like to receive notifications in Chat.
@gesslar
gesslar / PasswordGenerator-ES5.js
Last active August 21, 2020 05:18
Password generator using ES5 JavaScript and the Fisher-Yates Algorithm
var config = {
numberToInclude: {
lowers : 3,
uppers : 2,
digits : 2,
symbols: 2
},
digits: "23456789",
symbols: "@#$%&*()[]~=",
lowers: "abcdefghjkmnpqrstuvwxyz",
@gesslar
gesslar / PasswordGenerator-ES6.js
Last active August 21, 2020 05:27
Password generator using ES6 JavaScript and the Fisher-Yates Algorithm
const config = {
numberToInclude: {
lowers : 3,
uppers : 2,
digits : 2,
symbols: 2
},
digits: "23456789",
symbols: "@#$%&*()[]~=",
lowers: "abcdefghjkmnpqrstuvwxyz",
/**
* @param {string} s
* @return {number}
*/
const lengthOfLongestSubstring = s => {
let begin = 0
let end = 1
let final = ""
const length = s.length + 1
@gesslar
gesslar / efun_environment_override.c
Last active April 1, 2021 01:52
An override for efun::environment with arguments to travel up the inventory of a given object to find all environments in order upwards
/* Returns the environment of an object, or all the environments above an
* object, or a single environment at a given position.
*
* Example:
* backpack
* -> pouch
* -> bean
*
* environment( bean ) ; // returns pouch
* environment( bean, 0 ) ; // returns pouch
@gesslar
gesslar / log_file.c
Created April 3, 2021 20:49
log file sefun with log file rotation
void log_file( string file, string text )
{
string pathfile ;
if( !stringp( file ) || !stringp( text ) ) return ; // syntax error
if( strsrch( file, ".." ) != -1 ) return ; // security error
if( text[ <1 .. ] != "\n") text += "\n" ;
if (previous_object())
// /std/events.c
// Event emitter inheritible
//
// Created: 2021/04/09: Gesslar
// Last Change: 2021/04/09: Gesslar
//
// 2021/04/09: Gesslar - Created
private static mapping event_listeners = ([ ]) ;