Skip to content

Instantly share code, notes, and snippets.

View marcguyer's full-sized avatar

Marc Guyer marcguyer

View GitHub Profile
@marcguyer
marcguyer / SupervisordMemory.py
Last active August 29, 2015 13:58
Supervisord memory check plugin for serverdensity.io
#!/usr/bin/env python
"""
Server Density Supervisord plugin.
Track the number of processes in each state.
For possible states see the docs at
http://supervisord.org/subprocess.html#process-states
"""
@marcguyer
marcguyer / cheddargetter-webhook.cs
Last active December 18, 2015 23:09
A c# example for verifying a CheddarGetter webhook
/// Grab The Authorization Header
var authorizationHeader = request.Headers["X-CG-SIGNATURE"];
if (string.IsNullOrEmpty(authorizationHeader))
{
throw new Domain.Exceptions.Exception();
}
request.InputStream.Seek(0, SeekOrigin.Begin);
@marcguyer
marcguyer / cheddargetter-webhooks.rb
Last active December 11, 2015 07:19
A Ruby example for validating a CheddarGetter webhook.
require 'openssl'
require 'digest'
product_key = 'YOUR_PRODUCT_KEY'
if !defined?(request) || request.nil? || request.env.nil? # not rails
# signature = {value of X-CG-SIGNATURE here}
# request_body = {value of raw request body here}
else # assume it's a ROR ActionController::AbstractRequest object
signature = request.env['X-CG-SIGNATURE']
@marcguyer
marcguyer / cheddargetter-webhook-raw.php
Last active December 11, 2015 07:19
Raw PHP example for validating CheddarGetter webhook.
<?php
if (empty($_SERVER['HTTP_X_CG_SIGNATURE'])) {
//invalid
}
$rawBody = file_get_contents('php://input');
$token = md5($rawBody);
// check signature
@marcguyer
marcguyer / zf1-webhook-controller.php
Last active December 11, 2015 07:19
Basic ZF1 controller for handling CheddarGetter webhooks
<?php
class HookController extends Zend_Controller_Action {
public function preDispatch() {
$this->_helper->viewRenderer->setNoRender(true);
if (!$this->_request->isPost()) {
throw new Exception('POST required');
}
@marcguyer
marcguyer / customers.xml
Created November 2, 2010 18:36
Example CheddarGetter API responses
<?xml version="1.0" encoding="UTF-8"?>
<customers>
<customer id="89fdd0e4-c775-11de-8728-40407c9117fd" code="test_customer">
<firstName>Joe</firstName>
<lastName>Schmoe</lastName>
<company/>
<email>joe.schmoe@example.com</email>
<notes/>
<gatewayToken>SIMULATED</gatewayToken>
<isVatExempt>0</isVatExempt>