Skip to content

Instantly share code, notes, and snippets.

View julianeon's full-sized avatar

Julian Martinez julianeon

View GitHub Profile
@julianeon
julianeon / pd-incident-note.rb
Last active August 29, 2015 13:55
To append notes to incidents.
# Copyright (c) 2014, PagerDuty, Inc. <info@pagerduty.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
@julianeon
julianeon / pd-create-incident.rb
Last active August 29, 2015 13:55
A script to create in incident in a given service.
require 'json'
subdomain="change_this"
api_key="change_this"
endpoint="https://events.pagerduty.com/generic/2010-04-15/create_event.json"
service_access_key="change_this"
incident_key="change_this"
subject="change_this"
client="change_this"
@julianeon
julianeon / phantom-nytimes.js
Last active August 29, 2015 13:55
Scraped example using NYTimes.
// Find summary of articles in NYTimes.
var page = require('webpage').create(),
url = 'http://www.nytimes.com/most-popular-blogged';
page.open(url, function (status) {
if (status !== 'success') {
console.log('Unable to access network');
} else {
var results = page.evaluate(function() {
@julianeon
julianeon / phantom-dealbook.js
Created February 2, 2014 02:27
To find NYTimes Dealbook summaries.
// Find summary of articles in NYTimes.
var page = require('webpage').create(),
url = 'http://dealbook.nytimes.com/category/main-topics/legal/';
page.open(url, function (status) {
if (status !== 'success') {
console.log('Unable to access network');
} else {
var results = page.evaluate(function() {
@julianeon
julianeon / phantom-nytimes-links.js
Created February 2, 2014 02:53
Gets all the links from NYTimes' Dealbreaker links.
@julianeon
julianeon / package.json
Last active August 29, 2015 13:56
For use with node.js event state listener.
{
"name": "webhooks-listener",
"version": "0.0.1",
"dependencies": {
"express": "3.1.x",
"nodemailer": "0.5.3",
"jquery": "1.8.3"
},
"engines": {
"node": "0.10.x",
@julianeon
julianeon / gmail_save_incident_number.rb
Last active August 29, 2015 13:57
To save the incident number from a gmail email, in partial pseudocode form.
require 'gmail'
require 'base64'
require 'nokogiri'
require 'date'
require 'redis'
redis=Redis.new
#credentials to login
login="change_this"
@julianeon
julianeon / pd-resolve-incident.rb
Created March 18, 2014 23:10
A script to resolve incidents.
require 'json'
subdomain="change_this"
api_key="change_this"
incident_id="change_this"
requester_id="change_this"
endpoint="https://#{subdomain}.pagerduty.com/api/v1/incidents/#{incident_id}/resolve"
@julianeon
julianeon / pd-integration-gmail-resolve.rb
Last active August 29, 2015 13:57
This service checks an gmail address that you specify for all emails from your monitoring service. If it find ones, it then locates its ID, then hits the PagerDuty API to resolve that incident.
require 'rubygems'
require 'gmail'
require 'curb'
require 'json'
# Gmail Credentials
username="CHANGE_THIS"
password="CHANGE_THIS"
puts ("Connecting to Gmail")
@julianeon
julianeon / pd-single-maintenance-window.rb
Last active August 29, 2015 13:57
To create a maintenance window in a service.
subdomain="CHANGE_THIS"
api_key="CHANGE_THIS"
start="CHANGE_TO_TIME_LIKE_2014-04-08T13:00:00-04:00Z"
stop="CHANGE_TO_TIME_LIKE_2014-04-09T13:00:00-04:00Z"
about="This is the maintenance window for this service."
service="CHANGE_TO_ID_LIKE_P5QRAN5"
requester="CHANGE_TO_ID_LIKE_PVYWSCX"
endpoint="https://#{subdomain}.pagerduty.com/api/v1/maintenance_windows"