Skip to content

Instantly share code, notes, and snippets.

@gspncr
gspncr / new-relic-terraform.md
Last active November 29, 2023 07:27
New Relic Terraform step by step

New Relic Terraform Provider step by step

# Configure terraform
terraform {
  required_version = "~> 0.14.0"
  required_providers {
    newrelic = {
      source  = "newrelic/newrelic"
      version = "~> 2.9.0"
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)
@gspncr
gspncr / _webinar-links.md
Last active December 28, 2022 16:02
new relic x k6 test
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 / k6-new-relic-demo.md
Last active December 14, 2021 18:07
k6 and New Relic demo stack

Assumptions: a New Relic account and Ubuntu 18. Works on a t2.micro

k6 installation instructions from their docs

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61
echo "deb https://dl.bintray.com/loadimpact/deb stable main" | sudo tee -a /etc/apt/sources.list
sudo apt-get update
sudo apt-get install k6
@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).