Skip to content

Instantly share code, notes, and snippets.

@adamd
adamd / graphql-vs-rest.md
Created September 10, 2024 00:15
GraphQL vs REST APIs: A Generic Outline

Title: GraphQL vs REST: A Comprehensive Comparison

Introduction

  • Briefly introduce both GraphQL and REST.
  • Mention the relevance and importance of understanding the differences between them.
  • State the purpose of the post (to help readers choose the right API architecture for their needs).

What is REST?

  • Explain the basics of REST (Representational State Transfer).
  • Discuss the fundamental principles of REST APIs.
@adamd
adamd / check-links.py
Created February 18, 2016 16:48
Check status code of a list of URLs
$.ajax({
"method" : "GET",
"url" : "https://api.keen.io/3.0/projects/" + KeenClient.projectId + "/queries/extraction",
"data" : {
"api_key" : KeenClient.readKey,
"event_collection" : "Sendgrid Email Events",
"filters" : [{
"operator" : "eq",
"property_value" : yourEmailId
"property_name" : yourEmailIdIdentifier // This is a unique_id set when sending the email through SendGrid e.g. my-unique-id
$.ajax({
"method" : "GET",
"url" : "https://api.keen.io/3.0/projects/" + KeenClient.projectId + "/queries/extraction",
"data" : {
"api_key" : KeenClient.readKey,
"event_collection" : "Sendgrid Email Events",
"filters" : [{
"operator" : "eq",
"property_value" : "nick@sendgrid.com"
"property_name" : "email"
Keen.onChartsReady(function () {
var avgProcessedTimeMetric = new Keen.Metric("Sendgrid Email Events", {
"analysisType": "average",
"targetProperty": "timestamp",
"filters": [
{
"property_name" : "event",
"operator" : "eq",
"property_value" : "processed"
}
Keen.onChartsReady(function () {
var openMetric = new Keen.Metric("Sendgrid Email Events", {
analysisType: "count",
targetProperty: "event",
// Note: This assumes you've given each email a SendGrid unique_arg, e.g. "my-unique-id" with a unique identifier in each.
groupBy: unique_arg,
filter: [
{
// Here we use "in" to select any of all posible actions that indicate an email has been read
// http://sendgrid.com/docs/API_Reference/Webhooks/event.html#-Event-Types
@adamd
adamd / Keen Funnel
Last active December 23, 2015 04:39
Keen.onChartsReady(function () {
// To make a funnel we must initiate each step a visitor must take
var processedStep = new Keen.Step(
"Sendgrid Email Events",
{
"name": "Processed",
"filters": [
{
"property_name" : "event",
"operator" : "eq",