Skip to content

Instantly share code, notes, and snippets.

@taf2
taf2 / action.js
Last active August 24, 2020 15:13
Salesforce - Query for custom field picker in CallTrackingmetrics.
/*
Usage:
Configure in Variables the objects and their properties you want to search.
The properties must include an Id and Name. Optionally you can include an Email property.
You can use https://app.calltrackingmetrics.com/salesforce/object_attributes.json?object=<insert your object type here>
to discover the internal names for your Object's properties.
@taf2
taf2 / action.js
Created August 6, 2020 15:56
Update Zendesk Ticket with Chat Transcription
exports.handler = function(event, context, callback) {
const ticket = event.activity.custom_fields.zd_ticket.match(/\d+/)[0]
const data = {call_id: event.activity.id, ticket_id: ticket, ticket_data: {"ticket": {"status": "open", "comment": { "body": event.activity.chat_transcription }}}}
var authHeaders = {'Authorization': process.env.ZDAuth};
context.http_post('https://app.calltrackingmetrics.com/api/v1/accounts/25/zendesk/update_ticket',
JSON.stringify(data),
authHeaders).then(function(request) {
@taf2
taf2 / action.js
Last active September 30, 2022 13:33
Query Salesforce Used in a picker to select an object in salesforce by user input e.g. phone number or name
const jsforce = require('jsforce');
function phoneQuery(number, objects) {
let digits = number.replace(/\D/g,'').split("");
if (digits.length > 10) {
let country_code = digits.shift();
}
let npa = [];
npa.push(digits.shift());
npa.push(digits.shift());
openssl s_client -connect yum.datadoghq.com:443
CONNECTED(00000003)
140536412514128:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:s23_clnt.c:794:
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 7 bytes and written 289 bytes
---
@taf2
taf2 / oauth2-client.rb
Created April 28, 2020 14:17
Example oauth2 client for CallTrackingMetrics.com
#
# Example OAuth2 Application for CallTrackingMetrics.com
# Users are redirected to your application and prompted to allow access to their CallTrackingMetrics account with the given permissions
# After accepting they are redirected back to your applicaiton's /authorize URL via GET request.
# In this request you will receive a 'code' that you must send via a POST request back to CTM to get an access token and refresh token.
# Later when the access token expires you can renew it via the refresh request.
#
require 'sinatra'
require 'curb'
require 'uri'
@taf2
taf2 / sofar.sh
Created March 31, 2020 04:04
here's the output so far
pt-slave-restart --master-uuid 393fa485-fd5d-11e7-8c56-0e15b1b77760 --host localhost -u root
*******************************************************************
Using the default of SSL_verify_mode of SSL_VERIFY_NONE for client
is deprecated! Please set SSL_verify_mode to SSL_VERIFY_PEER
together with SSL_ca_file|SSL_ca_path for verification.
If you really don't want to verify the certificate and keep the
connection open to Man-In-The-Middle attacks please set
SSL_verify_mode explicitly to SSL_VERIFY_NONE in your application.
*******************************************************************
at /usr/bin/pt-slave-restart line 3842.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>Lazy load specific scopped run</title>
<script>
function goNow() {
__ctm.main.start(document.querySelector(".callus"));
}
window.winReady = false;
/**
* Simple Menu Template
*
* This Function builds a simple IVR menu. Learn more about <Gather> at:
* https://www.twilio.com/docs/api/twiml/gather
*/
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.VoiceResponse();
if (event.Digits && event.Digits.length && event.Digits != 'timeout' && event.Digits != '*') {
let digits = event.Digits.split("").join(", ");
class ObjectThing
extend PropertyAttributeHelper
property :my_options, :my__value # adding an extra underscore to indicate private
def my_value
my__value.nil? ? true : my__value
end
def my_value=(v)
my__value = v
@taf2
taf2 / example.html
Created November 4, 2019 21:46
Tracking visitor_sid with Shopify orders
<input type="hidden" name="attributes[visitor_sid]" id="ctm_visitor_sid" value=""/>
<script>
function getCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0, len = ca.length;i < len;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) {
return c.substring(nameEQ.length,c.length);