Skip to content

Instantly share code, notes, and snippets.

DCL VAR(&RESPONSE) TYPE(*CHAR) LEN(2000)
DCL VAR(&ERROR) TYPE(*CHAR) LEN(2000)
CALL PGM(SYSTOOLS/HTTPPOST)
PARM('https://api.twilio.com/2010-04-01/Accounts/YOUR_ACCOUNT_SID/Messages.json'
'From=+1234567890&To=+0987654321&Body=Hello+from+AS400'
'Authorization: Basic BASE64ENCODED_AUTH_TOKEN' &RESPONSE &ERROR)
exports.handler = async (context, event, callback) => {
// Providing a string will result in a 200 OK
var location = event.location.toLowerCase();
console.log('hello');
const TWILIO_SYNC_SERVICE_SID = 'ISxxx'
const TWILIO_MAP_SID = 'MPxxx'
const syncClient = Runtime.getSync({ serviceName: TWILIO_SYNC_SERVICE_SID});
var enteredLocation = await syncClient
@gspncr
gspncr / .env
Last active May 10, 2022 15:47
Print to the console voice/message activity and your numbers. Take this information to look at the numbers you own without logged calls/messages.
TWILIO_ACCOUNT_SID=ACxxxxxxxxxx
TWILIO_AUTH_TOKEN=xxxxxxxxx
@gspncr
gspncr / calc-years-delta.js
Created November 29, 2021 08:58
Twilio Functions
// calculate the delta between the date you provide as an arg and the year of the current day.
// Provide it 01/01/2000 and you run this on 12/12/2020, this will return 20
exports.handler = function(context, event, callback) {
function formatDate(date){
var d = new Date(date), month = '' + (d.getMonth() + 1), day = '' + d.getDate(), year = d.getFullYear();
if (month.length < 2) month = '0' + month;
if (day.length < 2) day = '0' + day;
console.log(year)
@gspncr
gspncr / years-difference.liquid
Created November 21, 2021 13:53
liquid collection
{% assign bday = "1993-09-05" %}
{{ bday | date: "%Y" }}
{{'now' | date: '%Y' }}
{% assign today = 'now' | date: '%Y' %}
{% assign birthYear = bday | date: '%Y' %}
{{today}}
{{birthYear}}
{{today | minus: birthYear }}
@gspncr
gspncr / useful-apps.md
Last active October 11, 2021 09:58
Useful things

Useful Apps

Altair Nice GraphQL client

KeyCastr App to display pressed keys, useful for webinars

ngrok Service to create a public URL to a local port

remote write config example

Lines 24-27 are doing the filtering per docs

# my global config
global:
  scrape_interval:     60s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 60s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).
@gspncr
gspncr / nr-count-things.js
Created August 2, 2021 14:27
count NR dashboards, policies, conditions
//add your user API key - ideally set this as a secure credential per: https://docs.newrelic.com/docs/synthetics/synthetic-monitoring/using-monitors/store-secure-credentials-scripted-browsers-api-tests/
var myQueryKey = 'NRAK-<>';
function countDashboards(){
var options = {
uri: 'https://api.newrelic.com/v2/dashboards.json',
headers: {
'Api-Key': myQueryKey,
'Accept': 'application/json'
}
@gspncr
gspncr / newrelic.js
Created July 20, 2021 15:14
Scripted Browser monitor script that will fail if the text “Log In” is present on the New Relic homepage:
// Scripted Browser monitor script that will fail if the text “Log In” is present on the New Relic homepage:
var assert = require('assert');
var URL = 'http://newrelic.com';
var textToFind = 'Log In';
$browser.get(URL).then(function(){
return $browser.findElement($driver.By.tagName('html')).getText();
}).then(function(body){
var textFound = (body.indexOf(textToFind) > -1);
@gspncr
gspncr / nr-slo-dash.json
Created July 19, 2021 09:19
SLO demo dash example
{
"name": "SLO Dashboard (WebPortal)",
"description": "",
"permissions": "PRIVATE",
"pages": [
{
"name": "SLO Dashboard (WebPortal)",
"description": "",
"widgets": [
{