Skip to content

Instantly share code, notes, and snippets.

@mbeale
mbeale / gist:6981298
Last active March 27, 2017 08:36
EasyPost Handle Webhook PHP
$inputJSON = file_get_contents('php://input');
$event = \EasyPost\Event::receive($inputJSON);
if($event.description == 'tracker.updated'){
//process event here
}
@mbeale
mbeale / gist:6998412
Last active December 25, 2015 15:29
Flask and Easypost handle webhooks
from flask import Flask, request
import easypost
import json
app = Flask(__name__)
@app.route("/webhooks", methods=['POST'])
def webhook():
e = easypost.Event()
e.receive(json.loads(request.form.keys()[0]))
@mbeale
mbeale / gist:7044836
Created October 18, 2013 17:21
Easypost webhook with sinatra
require 'easypost'
require 'sinatra'
require 'json'
post '/webhook' do
e = EasyPost::Event.new
e.receive(JSON.parse(request.body.string))
e.result.to_s
end
@mbeale
mbeale / shippingexport.py
Last active December 31, 2015 13:09
EasyPost - Python export shipments to csv
#
# This will fetch shipments and ouput them into csv
#
# Dependencies
# python requests lib - pip install requests
# python iso8601 lib - pip install iso8601
#
# Setup
# add your API key to the code
#
@mbeale
mbeale / gist:8569047
Last active January 4, 2016 04:29
Ruby fetch IDs EasyPost
require "easypost"
EasyPost.api_key = 'YOUR API KEY'
shipment_ids = #fetch a list of shipment ids from your end
shipment_ids.each do |id|
shipment = EasyPost::Shipment.retrieve(id)
if shipment.tracker.status == 'pre_transit'
begin
shipment.refund
@mbeale
mbeale / papertrail.go
Last active August 29, 2015 14:23
Papertrail with Go
package main
import (
// "log"
"log/syslog"
)
func main() {
pt, err := syslog.Dial("udp", "<host>.papertrailapp.com:11111", syslog.LOG_ERR, "My_App_Name")
if err != nil {
@mbeale
mbeale / remove_stale_metrics.rb
Last active December 4, 2017 18:31
Removing stale metrics from Librato
#!/usr/bin/env ruby
require 'librato/metrics'
c = Librato::Metrics
email = '[email protected]'
token = 'abcd1234'
c.authenticate email, token
# http://www.graphviz.org/content/cluster
digraph G {
subgraph cluster_level_1 {
style=filled;
color=lightgrey;
node [style=filled,color=white];
integration_0[label="integration"];
custom_space_0[label="custom_space"];
#!/usr/bin/env bash
#
# Python MAC OSX Librato Agent install script
# Version: 0.0.2
# Author: Librato
#
# run:
# curl -s "https://raw.githubusercontent.com/librato/python-librato-agent/master/sh/install.sh?" | bash
#
#!/usr/bin/env bash
#
# Python MAC OSX Librato Agent install script
# Version: 0.0.2
# Author: Librato
#
# run:
# curl -s "https://raw.githubusercontent.com/librato/python-librato-agent/master/sh/install.sh?" | bash
#