Skip to content

Instantly share code, notes, and snippets.

@brandonmwest
brandonmwest / gist:6262934
Last active December 22, 2020 09:02
Custom liquid block for Jekyll example
#Generates a named anchor and wrapping tag from a string.
module Jekyll
class AnchorBlock < Liquid::Block
def initialize(tag_name, markup, tokens)
@tag = markup
super
end
def render(context)
@brandonmwest
brandonmwest / gist:6262952
Last active December 21, 2015 06:18
Example Jekyll layout
<html>
<head>
<title>{{ page.title }}</title>
</head>
<body>
{% include header.html %}
<div class="container">
<article id="content">
{{ content }}
</article>
@brandonmwest
brandonmwest / gist:6262961
Created August 18, 2013 17:49
Example Jekyll page
---
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:6262972
Created August 18, 2013 17:51
Example Jekyll plugin (generator)
module Jekyll
require 'haml'
class HamlConverter < Converter
safe true
priority :low
def matches(ext)
ext =~ /haml/i
end
@brandonmwest
brandonmwest / gist:6263278
Last active December 21, 2015 06:19
Typical jekyll scaffolding (source: http://jekyllrb.com/docs/structure/)
.
├── _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:6335429
Last active December 21, 2015 16:39
ruby script for pretty printing JSON and XML inside of octopress {% codeblock %} tags
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
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:6937700
Created October 11, 2013 16:20
Send an email with categories using sendgrid-csharp
// 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);
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 / example.cs
Last active January 16, 2024 15:52
Generating base64-encoded Authorization headers in a variety of languages
httpClient.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue(
"Basic",
Convert.ToBase64String(
System.Text.ASCIIEncoding.ASCII.GetBytes(
string.Format("{0}:{1}", username, password))));