Skip to content

Instantly share code, notes, and snippets.

@brandonmwest
brandonmwest / create template
Last active Aug 29, 2015
SendGrid web api v3 curl example
View create template
curl -X POST -d '{"name":"example_name"}' -H "Content-Type: application/json" -u sendgrid_username https://api.sendgrid.com/v3/templates
@brandonmwest
brandonmwest / example.cs
Last active Sep 20, 2022
Generating base64-encoded Authorization headers in a variety of languages
View example.cs
httpClient.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue(
"Basic",
Convert.ToBase64String(
System.Text.ASCIIEncoding.ASCII.GetBytes(
string.Format("{0}:{1}", username, password))));
View gist:7605571
module Jekyll
class ApiExample < Liquid::Block
def initialize(tag_name, markup, tokens)
attributes = markup.split
@identifier = attributes[0]
@http_method = attributes[1]
@url = attributes[2]
@data = attributes[3]
super
@brandonmwest
brandonmwest / gist:6937700
Created Oct 11, 2013
Send an email with categories using sendgrid-csharp
View gist:6937700
// Create the email object first, then add the properties.
SendGrid myMessage = SendGrid.GetInstance();
myMessage.AddTo("anna@example.com");
myMessage.From = new MailAddress("john@example.com", "John Smith");
myMessage.Subject = "Testing the SendGrid Library";
myMessage.Text = "Hello World!";
string[] categories = new string[3] {"category1", "category2", "category3"};
myMessage.SetCategories(categories);
View gist:6489339
INVALID JSON in source/API_Reference/Customer_Subuser_API/apps.html:
"settings":null
--------------------------
INVALID JSON in source/API_Reference/Customer_Subuser_API/whitelabel.html:
--------------------------
INVALID JSON in source/API_Reference/Marketing_Emails_API/variations.html:
@brandonmwest
brandonmwest / gist:6335429
Last active Dec 21, 2015
ruby script for pretty printing JSON and XML inside of octopress {% codeblock %} tags
View gist:6335429
require 'rubygems'
require 'json'
require 'nokogiri'
require 'nokogiri-pretty'
markdown_files = File.join("/docs/source", "**", "*.md")
Dir.glob markdown_files do |markdown_file|
next if markdown_file == '.' or markdown_file == '..'
path = markdown_file
@brandonmwest
brandonmwest / gist:6263278
Last active Dec 21, 2015
Typical jekyll scaffolding (source: http://jekyllrb.com/docs/structure/)
View gist:6263278
.
├── _config.yml
├── _drafts
| ├── begin-with-the-crazy-ideas.textile
| └── on-simplicity-in-technology.markdown
├── _includes
| ├── footer.html
| └── header.html
├── _layouts
| ├── default.html
@brandonmwest
brandonmwest / gist:6262972
Created Aug 18, 2013
Example Jekyll plugin (generator)
View gist:6262972
module Jekyll
require 'haml'
class HamlConverter < Converter
safe true
priority :low
def matches(ext)
ext =~ /haml/i
end
@brandonmwest
brandonmwest / gist:6262961
Created Aug 18, 2013
Example Jekyll page
View gist:6262961
---
layout: page
weight: 0
title: Python
navigation:
show: true
---
We'll start with a simple example using the built-in Python SMTP libraries to send a message.
After that example, you can find more complete instructions that use the SendGrid Python library.
@brandonmwest
brandonmwest / gist:6262952
Last active Dec 21, 2015
Example Jekyll layout
View gist:6262952
<html>
<head>
<title>{{ page.title }}</title>
</head>
<body>
{% include header.html %}
<div class="container">
<article id="content">
{{ content }}
</article>