Skip to content

Instantly share code, notes, and snippets.

View eurica's full-sized avatar

David Hayes eurica

View GitHub Profile
eurica / spark2pd.js
Created July 7, 2016 21:13
A custom event transformer to create incidents from Cisco Spark
View spark2pd.js
function transform(PD) {
var webhook = PD.inputRequest.body
var message = webhook.text || "Error: Not a Spark chat message";
var room_link = ciscospark2web(b64decode(webhook.roomId)); // clean up the link
var normalized_event = {
incident_key: room_link, //So that all messages from a room de_dupee into the same incident
event_type: PD.Trigger,
description: message,
details: {
eurica / manual_pd.js
Last active August 29, 2015 14:15
Manually Trigger an incident in PagerDuty
View manual_pd.js
/* This is the button I'm using to trigger the incident:
<input type="button" onclick="PDTrigger(prompt('Incident Description'))" value="Trigger Incident">
// Set up the library
PDJS = new PDJSobj()
function PDTrigger(description) {
// Trigger via the rest API
View all_users_by_ep.js
// As always configure PDJS with your subdomain and api-key
PDJS = new PDJSobj({
subdomain: "webdemo",
token: "CkNpsqH9i6yTGus8VDzA",
// Here's the minimum possible UI:
printf = function (str) {
#This function will alert PagerDuty that our script failed
alertonfail() {
if [ "$1" -ne "0" ]; then
echo "Error $1 on $me"
curl -H "Content-type: application/json" -X POST \
-d '{
eurica / dashboard.pseudocode.js
Last active August 29, 2015 14:09
Pseudocode for dashboard example
View dashboard.pseudocode.js
// Initiate PDJS:
PDJS = new PDJSobj({
subdomain: config["subdomain"],
token: config["token"],
loadIncidents = function () {
//Hit the incidents API:
res: "incidents",
View survey.html
<meta name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<script src=""></script>
// Step 1. Put the URL from <form action="URL"> here:
var form_url = ""
eurica / Send-PagerDutyEvent.ps1
Created July 2, 2014 20:47
Trigger PagerDuty event
View Send-PagerDutyEvent.ps1
Param (
[String]$AlertDesc = "No Description provided",
[String]$WebLink = "",
[String]$AlertName = "No Name provided",
[String]$AlertSourceName = "No Source provided"
View PDupdate.js
PDupdate = function(e) {
url: 'http://'+subdomain+''+
type: 'json',
headers: {
Authorization: 'Token token='+token,
contentType: 'application/json; charset=utf-8'
View pagerduty_ruby_httparty.rb
require 'pp'
require 'httparty'
class PagerDuty
include HTTParty
format :json
def initialize(subdomain, api_token)
@options = {
:headers => {
"Authorization" => "Token token=#{api_token}",
eurica / twilio-numbers.rb
Created December 20, 2013 20:55
Ruby script to check numbers against the Twilio Price list.
View twilio-numbers.rb
require 'csv'
#Parse the CSV that Twilio provides
numbers = []
CSV.foreach('international-rates.csv', :headers => true) do |row|
starts = row[2].split(",")
starts.each do |p|
numbers.push([p.strip, p.strip.length, row[1], row[0]])