Skip to content

Instantly share code, notes, and snippets.

chrisdpeters / index.js
Last active May 18, 2019
Setting up all kinds of domain redirects in S3 and CloudFront
View index.js
'use strict';
exports.handler = (event, context, callback) => {
const request = event.Records[0].cf.request;
let uri = request.uri ? request.uri : '/';
if (request.querystring) {
uri += '?' + request.querystring;
chrisdpeters / _call_to_action_view.html.erb
Last active Jul 17, 2017
Alchemy CMS: great for websites integrated with Ruby on Rails
View _call_to_action_view.html.erb
<%- cache(element) do -%>
<%= element_view_for(element) do |el| -%>
<div class="cta">
<h3 class="cta-heading">
<%= el.render :headline %>
<%= el.render :description %>
<div class="cta-actions">
chrisdpeters / Address.cfc
Last active Aug 10, 2017
Progressively enhancing your CFWheels form with nested properties and jQuery
View Address.cfc
component extends="Model" {
function init() {
chrisdpeters / show-output-filtered.html
Last active Aug 10, 2017
Never output anything to a browser without a formatting filter
View show-output-filtered.html
<a href="/posts/fart">&lt;script&gt;>alert('All your base are belong to us!');&lt;/script&gt;</a>
<p class="post-meta">
&lt;script&gt;sendCookieInfoToAnotherServer = function() { /* ... */ }; sendCookieInfoToAnotherServer();&lt;/script&gt;
<h2>Banana Comments</h2>
View InvoiceSearchForm-init.cfc
component extends="Model" {
function init() {
// Set property labels for form fields and related error messages.
property(name="startDate", label="Start");
property(name="endDate", label="End");
chrisdpeters / contact.rb
Last active Mar 2, 2016
Users, Contacts, and Friendships
View contact.rb
class Contact < ActiveRecord::Base
has_many :users
has_many :friendships
chrisdpeters / TablelessModel.cfc
Last active Dec 16, 2015
Hiding complex model relationships behind form objects in CFWheels
View TablelessModel.cfc
<cfcomponent extends="Model">
<cffunction name="init">
<cfset table(false)>
chrisdpeters / Issue.cfc
Last active Aug 25, 2015
CFWheels nestedProperties sortProperty fix
View Issue.cfc
<cfcomponent extends="Model" output="false">
<cffunction name="init" output="false">
hasMany(name="attemptedSolutions", shortcut="solution", dependent="delete");
nestedProperties(association="attemptedSolutions", allowDelete=true, sortProperty="sortOrder");
<cffunction name="$adjustAttemptedSolutionSortOrders" access="private" hint="Adjusts array of attempted solutions before save happens so there aren't any null entries." output="false">
View _google_analytics.cfm
<!--- Instead of a lame check like `<cfif get("environment") eq "production">`,
we can instead do whatever the environment is calling for --->
View _bios.scss
$bio-breakpoint: 500px;
.bio {
@media screen and (min-width: $bio-breakpoint) {
float: left;
width: 50%;
.bio-photo {