Skip to content

Instantly share code, notes, and snippets.

Robert Rawlins SirRawlins

View GitHub Profile
@SirRawlins
SirRawlins / url_matcher.rb
Last active May 7, 2020
RSpec url matcher.
View url_matcher.rb
# Drop this into /spec/support/matchers
# Usage: result.should be_url
# Passes if result is a valid url, returns error "expected result to be url" if not.
# Matcher to see if a string is a URL or not.
RSpec::Matchers.define :be_url do |expected|
# The match method, returns true if valie, false if not.
match do |actual|
# Use the URI library to parse the string, returning false if this fails.
URI.parse(actual) rescue false
@SirRawlins
SirRawlins / Rakefile
Last active Dec 21, 2017
Using Jekyll plugins on GitHub Pages.
View Rakefile
# Rquire jekyll to compile the site.
require "jekyll"
# Github pages publishing.
namespace :blog do
#
# Because we are using 3rd party plugins for jekyll to manage the asset pipeline
# and suchlike we are unable to just branch the code, we have to process the site
# localy before pushing it to the branch to publish.
#
@SirRawlins
SirRawlins / 2013-01-27-example-article.html
Last active Jan 4, 2016
Adding authors to a Jekyll blog
View 2013-01-27-example-article.html
---
# Layout.
layout: post
# Author.
author: robert_rawlins
---
@SirRawlins
SirRawlins / gist:4953756
Last active Dec 13, 2015
Making curl requests to mimic PostmarkApp Inbound Hook.
View gist:4953756
curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{ "From": "myUser@theirDomain.com", "FromFull": { "Email": "myUser@theirDomain.com", "Name": "John Doe" }, "To": "451d9b70cf9364d23ff6f9d51d870251569e+ahoy@inbound.postmarkapp.com", "ToFull": [ { "Email": "451d9b70cf9364d23ff6f9d51d870251569e+ahoy@inbound.postmarkapp.com", "Name": "" } ], "Cc": "\"Full name\" <sample.cc@emailDomain.com>, \"Another Cc\" <another.cc@emailDomain.com>", "CcFull": [ { "Email": "sample.cc@emailDomain.com", "Name": "Full name" }, { "Email": "another.cc@emailDomain.com", "Name": "Another Cc" } ], "ReplyTo": "myUsersReplyAddress@theirDomain.com", "Subject": "This is an inbound message", "MessageID": "22c74902-a0c1-4511-804f2-341342852c90", "Date": "Thu, 5 Apr 2012 16:59:01 +0200", "MailboxHash": "ahoy", "TextBody": "[ASCII]", "HtmlBody": "[HTML(encoded)]", "Tag": "", "Headers": [ { "Name": "X-Spam-Checker-Version", "Value": "SpamAssassin 3.3.1 (2010-03-16) onrs-ord-pm-inbound1.wildbit.com" }, { "Name
@SirRawlins
SirRawlins / gist:4664075
Last active Dec 11, 2015
This is a short process which collectes the directory path of a CFC, and uses it's location to find a related view by convention. For instance, if the CFC path is /mailers/foo/bar.cfc the view location would be /views/email/foo/bar/ This is done simply at the moment by using REGEX to switch the '/mailers/ directory with '/views/email' in the CFC…
View gist:4664075
<!---
No path for the view was set into the payload so we
render a view based on the conventions.
--->
<!--- Get the full directory path of this mailer object. --->
<cfset LOCAL.MailPath = getDirectoryFromPath(getMetaData(this).path) />
<!--- This path MAY be a windows path, with backslashes so I'm going to normalize this into a NIX path. --->
<cfset LOCAL.MailPath = Replace(LOCAL.MailPath, '\', '/', "ALL") />
You can’t perform that action at this time.