Skip to content

Instantly share code, notes, and snippets.

View danderson00's full-sized avatar

Dale Anderson danderson00

View GitHub Profile
@danderson00
danderson00 / pipeline.js
Created February 26, 2019 02:02
Simple middleware execution pipeline
module.exports = (api, middleware, context) => (
middleware.reverse()
.reduce(
(next, current) => executor(current, next, context),
(...args) => Promise.resolve(api.handler.apply(api.hostObject, args))
)
)
const executor = (middleware, next, context) => (
(...args) => (
@danderson00
danderson00 / TimeZoneInfo.json
Created June 20, 2018 05:39
JSON serialized output of the .NET TimeZoneInfo.GetSystemTimeZones method
[
{
"Id": "Dateline Standard Time",
"DisplayName": "(UTC-12:00) International Date Line West",
"StandardName": "Dateline Standard Time",
"DaylightName": "Dateline Daylight Time",
"BaseUtcOffset": "-12:00:00",
"AdjustmentRules": null,
"SupportsDaylightSavingTime": false
},
@danderson00
danderson00 / timezoneConversions.json
Created June 20, 2018 05:17
Convert Windows time zone names to IANA names. Derived from http://unicode.org/repos/cldr/trunk/common/supplemental/windowsZones.xml using the `001` territory for each zone.
{
"Dateline Standard Time": "Etc/GMT+12",
"UTC-11": "Etc/GMT+11",
"Aleutian Standard Time": "America/Adak",
"Hawaiian Standard Time": "Pacific/Honolulu",
"Marquesas Standard Time": "Pacific/Marquesas",
"Alaskan Standard Time": "America/Anchorage",
"UTC-09": "Etc/GMT+9",
"Pacific Standard Time (Mexico)": "America/Tijuana",
"UTC-08": "Etc/GMT+8",
@danderson00
danderson00 / servicenow.js
Last active April 21, 2022 04:37
ServiceNow Authentication
const fetch = require('node-fetch')
const querystring = require('querystring')
var data = querystring.stringify({
"grant_type": "password",
// client_id and client_secret are from the System OAuth -> Application Registrations screen on the ServiceNow portal
"client_id": "",
"client_secret": "",
// username and password are valid user credentials for a user in the ServiceNow instance
"username": "",