Skip to content

Instantly share code, notes, and snippets.

View thinkingserious's full-sized avatar
🦉

Elmer Thomas thinkingserious

🦉
View GitHub Profile
@thinkingserious
thinkingserious / python_global_stats_get.py
Created November 18, 2015 04:00
Python Global Stats GET
import sendgrid
import os
if os.path.exists('.env'):
for line in open('.env'):
var = line.strip().split('=')
if len(var) == 2:
os.environ[var[0]] = var[1]
client = sendgrid.SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
start_date = '2015-10-01'
@thinkingserious
thinkingserious / example-template.rb
Created January 21, 2016 19:58
Sending an email using an template using the sendgrid-ruby library
require 'sendgrid-ruby'
require 'dotenv'
Dotenv.load
sendgrid_apikey = ENV['SENDGRID_APIKEY']
client = SendGrid::Client.new do |c|
c.api_key = sendgrid_apikey
end
@thinkingserious
thinkingserious / sendgrid_html_text_body.py
Created January 28, 2016 17:03
Improve deliverability by including both a text and HTML email body
import sendgrid
from bs4 import BeautifulSoup
def send_email(self, to_email, from_email, subject, body):
message = sendgrid.Mail()
message.add_to(to_email)
message.set_subject(subject)
soup = BeautifulSoup(body, "html.parser")
message.set_text(soup.get_text())
message.set_html(body)
@thinkingserious
thinkingserious / sample-csharp-bcc-unique-args.cs
Created February 4, 2016 21:51
Testing BCC and unique args
using System;
using System.Collections.Generic;
using System.Net.Mail;
using System.Linq;
using SendGrid;
namespace Example
{
internal class Program
{
@thinkingserious
thinkingserious / fluent.py
Created March 5, 2016 02:44
Fluent Interface in Python Using Method Chaining and Reflection
class Fluent:
def __init__(self, cache=None):
self._cache = cache or []
# Build the cache, and handle special cases
def _(self, name):
# Enables method chaining
return Fluent(self._cache+[name])
# Final method call
@thinkingserious
thinkingserious / fluent.php
Created May 9, 2016 16:43
Fluent Interface in PHP Using Method Chaining and Reflection
<?php
class Fluent {
function __construct($cache) {
$this->cache = ($cache ? $cache : []);
}
// Build the cache, and handle special cases
public function _($name) {
array_push($this->cache, $name);
@thinkingserious
thinkingserious / Fluent.cs
Last active May 10, 2016 16:26
Fluent Interface in C# Using Method Chaining and Reflection
using System;
using System.Dynamic;
namespace Fluent
{
class Client : DynamicObject
{
public string UrlPath;
public Client(string urlPath = null)
@thinkingserious
thinkingserious / file1.py
Created May 11, 2016 22:29
Multi File Gist
print "Hello World"
@thinkingserious
thinkingserious / fluent.rb
Created May 24, 2016 02:28
Fluent Interface in Ruby Using Method Chaining and Reflection
class Fluent
def initialize(cache: nil)
@cache = cache ? cache : []
end
# Reflection
def method_missing(name, *args, &block)
_(name.to_s)
end
@thinkingserious
thinkingserious / sample_sendgrid_oai.json
Created October 18, 2016 19:30
Snippit of the SendGrid OAI (Swagger) Definition - /user/webhooks/parse/settings [GET]
"/user/webhooks/parse/settings": {
"get": {
"consumes": [
"application/json"
],
"description": "**This endpoint allows you to retrieve all of your current inbound parse settings.**\n\nThe inbound parse webhook allows you to have incoming emails parsed, extracting some or all of the contnet, and then have that content POSTed by SendGrid to a URL of your choosing. For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Webhooks/parse.html).",
"operationId": "GET_user-webhooks-parse-settings",
"produces": [
"application/json"
],