Skip to content

Instantly share code, notes, and snippets.

View jeremy-wagner's full-sized avatar

Jeremy Wagner jeremy-wagner

View GitHub Profile
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": [
"edgelambda.amazonaws.com",
"lambda.amazonaws.com"
]
@jeremy-wagner
jeremy-wagner / aws_lambda_cache_control.js
Last active January 27, 2021 19:10
AWS Lambda handler to add cache-control handler.
'use strict';
// Lambda function to set cache control public header in case of missing cache control header
exports.handler = (event, context, callback) => {
const { response } = event.Records[0].cf;
const { headers } = response;
const headerCacheControl = 'Cache-Control';
const defaultTimeToLive = 60 * 60 * 24 * 14; // 14 days
<%= image_tag cdn_for(model.attribute) %>
<%# e.g. for a user cover photo %>
<%= image_tag cdn_for(user.cover_photo) %>
<%= image_tag url_for(model.attribute) %>
<%# e.g. for a user cover photo %>
<%= image_tag url_for(user.cover_photo) %>
def cdn_for(file)
"#{ENV['CDN_URL']}/#{file.key}"
end
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Unit Test</Title>
<Author>Jeremy Wagner</Author>
<Description>C# Unit Test Code Snippet with 3 Parts and Assert Inconclusive</Description>
<HelpUrl>https://msdn.microsoft.com/en-us/library/ms165394.aspx</HelpUrl>
<SnippetTypes />
<Keywords />