Skip to content

Instantly share code, notes, and snippets.

module Jekyll
class PostPublisher < Generator
safe false
def replace(filepath, regexp, *args, &block)
content = File.read(filepath).gsub(regexp, *args, &block)
File.open(filepath, 'wb') { |file| file.write(content) }
end
def generate(site)
@delputnam
delputnam / collections_filter.rb
Last active August 29, 2015 14:03
This is a liquid filter for Jekyll that will filter out individual collection items based on arbitrary yaml front matter variables.
# collections_filter.rb
#
# Filter individual Jekyll collections items based on arbitrary yam front matter variables.
#
# input - the collection array
# property - key to filter by
# value - desired value
#
# Returns the filtered array of objects
#
@delputnam
delputnam / gist:347482e02e5edd6adb7b
Last active August 29, 2015 14:12
Get load time statistics using curl
Create a file named 'curl-format.txt':
time_namelookup: %{time_namelookup} s\n
time_connect: %{time_connect} s\n
time_appconnect: %{time_appconnect} s\n
time_pretransfer: %{time_pretransfer} s\n
time_redirect: %{time_redirect} s\n
time_starttransfer: %{time_starttransfer} s\n
----------\n
time_total: %{time_total} s\n
@delputnam
delputnam / gist:a0361b939999c8ecf909
Created January 5, 2015 13:58
HTML5 Video Example
<video width="1100" height="619" preload="metadata" poster="/wp-content/uploads/2014/10/here-they-come-16x9.jpg" controls>
<source src="/wp-content/uploads/2014/10/Sample-16x9-HD.mp4" type="video/mp4">
<source src="/wp-content/uploads/2014/10/Sample-16x9-HD.webm" type="video/webm">
<source src="/wp-content/uploads/2014/10/Sample-16x9-HD.ogv" type="video/ogg">
</video>
@delputnam
delputnam / gist:8aa157d1d0a5a3e5fd48
Created January 5, 2015 13:59
Background images for HTML Emails
<!-- from http://backgrounds.cm/ -->
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td background="http://i.imgur.com/YJOX1PC.png" bgcolor="#7bceeb" valign="top">
<!--[if gte mso 9]>
<v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="mso-width-percent:1000;">
<v:fill type="tile" src="http://i.imgur.com/YJOX1PC.png" color="#7bceeb" />
<v:textbox style="mso-fit-shape-to-text:true" inset="0,0,0,0">
<![endif]-->
<div>
@delputnam
delputnam / gist:b44118c7974cd0b6643d
Created January 5, 2015 13:59
Send an HTML email from the command line
You can do this relatively simple from the command line. Save your HTML, but also include the necessary SMTP headers at the top in the source. For this example I'll save the source as example.html in my home directory.
~/example.html:
From: sender@example.com
To: recipient@example.com
Subject: Test email
Mime-Version: 1.0
Content-Type: text/html
@delputnam
delputnam / gist:68484d0c3f59a6670bb6
Created January 5, 2015 14:00
Embed video in HTML email
<!doctype html>
<!-- For more info: http://www.emailonacid.com/blog/details/C13/a_how_to_guide_to_embedding_html5_video_in_email -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Video in Email Test</title>
<style type="text/css">
@media screen and (max-width:800px) {
@delputnam
delputnam / gist:3ef2dbede54491b2bbf8
Created March 8, 2015 01:26
Set up ssh without password
ssh-keygen -t rsa
ssh username@remotehost mkdir -p .ssh
cat ~/.ssh/id_rsa.pub | ssh username@remothost 'cat >> .ssh/authorized_keys'
@delputnam
delputnam / gist:71b11fb750310f3e57b3
Last active August 29, 2015 14:16
Set up postfix (on Mac OS X 10.10 Yosemite) with Google Apps smtp
$ sudo vim /etc/postfix/main.cf
Add the following to the 'relayhost' section:
relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_use_tls = yes
smtp_sasl_mechanism_filter = plain
@delputnam
delputnam / gist:63dc8234df5841bad924
Created November 17, 2015 23:02 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>