Skip to content

Instantly share code, notes, and snippets.

View sawyerh's full-sized avatar

Sawyer Hollenshead sawyerh

View GitHub Profile
{% if current.type == 'page' %}
{% for post in posts %}
{{ post.body }}
{% endfor %}
{% elsif current.type == 'post' %}
{{ body }}
@sawyerh
sawyerh / gist:2847661
Created June 1, 2012 00:48
Black and White Images With SVG
<svg width="640" height="360" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg">
<filter id="grayscale">
<feColorMatrix type="saturate" values="0"/>
</filter>
<image class="bw" filter="url(#grayscale)" width="100%" height="100%" xlink:href="image.jpg" />
<image class="color" width="100%" height="100%" xlink:href="image.jpg" />
</svg>
@sawyerh
sawyerh / email-template.html
Created July 2, 2012 20:52
Template for BrowserID emails
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
#outlook a{
padding:0;
}
body{
background: url("https://static.dev.anosrep.org/v/fb16875e7d/common/i/grain.png") #76868f;
@sawyerh
sawyerh / gist:4127017
Created November 21, 2012 19:17
bookmarklet
javascript:void((function()%7Bvar%20e=document.createElement('script');e.setAttribute('type','text/javascript');e.setAttribute('charset','UTF-8');e.setAttribute('id', 'wander-bookmarklet-script');e.setAttribute('src','http://lvh.me:3000/bookmarklet/bookmarklet-local.js?v=1&url='+encodeURIComponent(window.location.href));document.body.appendChild(e)%7D)());
<? preg_match('#(?:https?://(?:www\.){0,1}amazon\.(com|ca|co\.uk)(?:/.*){0,1}(?:/dp/|/gp/product/))(.*?)(?:/.*|$)#',$item->content,$matches); ?>
var attrs = imageNode.attrs;
attrs.src = 'http://example.com/image.jpg';
var replacement = imageNode.type.create(attrs);
editor.tr.replaceWith(pos.from, pos.to, replacement).apply();
{
"presets": [
"react",
"es2015"
]
}

Keybase proof

I hereby claim:

  • I am sawyerh on github.
  • I am sawyer (https://keybase.io/sawyer) on keybase.
  • I have a public key ASBLD4Q7cshgms5cr00G-CA7Qc_pCD1HrlpgQ_Ufr_ZWvgo

To claim this, I am signing this object:

AWS: Long-term, infrequent backups

All infrequently accessed files are stored on AWS S3. All files are encrypted server-side using AES-256 with the AWS S3 Master Key. When uploading files to this bucket, you must set this encryption option, otherwise uploads will be prevented by the bucket's policy. Unfortunately, this also means using an app like Transmit won't work since they don't offer this encryption option (as of April 10, 2016).

The intention of these backups are "last resort" backups, so hopefully they'll never actually need retrieved. With that in mind, Lifecycle policies are used to archive files to AWS Glacier after a short period of days.

Using AWS because it's dirt cheap, however since the user experience isn't the greatest and Glacier retrieval prices can be a slippery slope, it's only used for infrequently accessed files and backups are uploaded only a few times a year. Most directories will consist of subdirectories named by year (e.g. finances/2014, photos/2014, etc)

Lifecycle policies

@sawyerh
sawyerh / blogs_controller.rb
Created June 24, 2016 14:08
Siteleaf on S3 + Rails
class BlogsController < ApplicationController
def index
@slug = params[:slug]
@file = AWS::S3.new.buckets['YOUR-SITELEAF-BUCKET-HERE']
.objects[File.join('blog', @slug.to_s, 'index.html')]
unless @file.exists?
puts @file.key
raise ActionController::RoutingError.new('Not Found')
end