Skip to content

Instantly share code, notes, and snippets.

Avatar

Mike Garde MikeGarde

View GitHub Profile
View S3Redirect.xml
<RoutingRules>
<RoutingRule>
<Condition>
<KeyPrefixEquals/>
<HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals>
</Condition>
<Redirect>
<Protocol>https</Protocol>
<HostName>newDomain.com</HostName>
<ReplaceKeyPrefixWith>oldStuff/?page=</ReplaceKeyPrefixWith>
View s3PublicPolicy.json
{
"Version": "2012-10-17",
"Id": "1",
"Statement": [
{
"Sid": "1",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
View simpleXmlLambdaResponse.js
var parseString = require('xml2js').parseString;
exports.handler = function (event, context, callback) {
parseString(event.body, function (err, result) {
event.body = result;
let respondToGateway = {
statusCode: '200',
body : JSON.stringify({
event: event,
View simpleLambdaResponse.js
exports.handler = function (event, context, callback) {
let respondToGateway = {
statusCode: '200',
body : JSON.stringify({
event: event,
context: context
}),
headers : {
'Content-Type': 'application/json'
}
View apiGatewayPassthroughMapping.js
#set($propertyRegex = '\\n')
#set($allParams = $input.params())
{
"body-xml" : $input.json('$').replaceAll($propertyRegex, ''),
"params" : {
#foreach($type in $allParams.keySet())
#set($params = $allParams.get($type))
"$type" : {
#foreach($paramName in $params.keySet())
"$paramName" : "$util.escapeJavaScript($params.get($paramName))"
@MikeGarde
MikeGarde / infustionsoftWebForm.js
Last active Jul 10, 2018
jQuery version of populating Infusionsoft fields
View infustionsoftWebForm.js
function getParameterByName(name, url) {
if (!url) {
url = window.location.href;
}
name = name.replace(/[\[\]]/g, "\\$&");
let regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) {
return null;
}