This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const REDIRECTS_DATA_REGION = 'us-east-1'; | |
const REDIRECTS_DATA_BUCKET = 'pdfs'; | |
const REDIRECTS_DATA_OBJECT = 'docs/pdf-redirects.json'; | |
// https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/s3/command/GetObjectCommand/ | |
import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3"; | |
const client = new S3Client({ | |
region: REDIRECTS_DATA_REGION | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const handler = async (event, context) => { | |
const request = event.request; | |
var newLocation = ""; | |
var statusCode = 301; | |
var statusDescription = "Moved Permanently"; | |
switch(request.uri) { | |
case "/test-pdf-1.pdf": | |
newLocation = "/test-pdf-2.pdf"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function handler(event) { | |
// NOTE: This example function is for a viewer request event trigger. | |
// Choose viewer request for event trigger when you associate this function with a distribution. | |
var newLocation = ""; | |
var statusCode = 301; | |
var statusDescription = "Moved Permanently"; | |
switch(event.request.uri) { | |
case "/test-pdf-1.pdf": |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* save UTM parameters in URL as session cookies | |
* if a link contains the class "appendUTM", | |
* then append the UTM params to the link | |
*/ | |
(function () { | |
"use strict"; | |
// get url query string parameters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This NodeJS script will recursively read files in a folder | |
and execute a series of search and replace commands. | |
It will convert document-relative image paths to root-relative paths, e.g. | |
../assets/images/home_page_banner.png | |
to | |
/public/assets/images/home_page_banner.png | |
Set the name of the folder as the value of the "dir" variable. | |
Run the script as follows: node recursive-replace.js | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const path = require('path'); | |
const walk = dir => { | |
try { | |
let results = []; | |
const list = fs.readdirSync(dir); | |
list.forEach(file => { | |
file = path.join(dir, file); | |
const stat = fs.statSync(file); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$=jQuery.noConflict(); | |
(function () { | |
var backgrounds = [ | |
"http://d3zntdne6n1qh.cloudfront.net/microsoft-rolling-hills.jpg", | |
"http://d3zntdne6n1qh.cloudfront.net/san-francisco-night.jpg", | |
"http://d3zntdne6n1qh.cloudfront.net/snow-mountain.jpg", | |
"http://d3zntdne6n1qh.cloudfront.net/turqoise-lake.jpg", | |
"http://d3zntdne6n1qh.cloudfront.net/desert.jpg", | |
"http://d3zntdne6n1qh.cloudfront.net/beach.jpg" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function mychildtheme_enqueue_styles() { | |
$parent_style = 'parent-style'; | |
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' ); | |
wp_enqueue_style( 'child-style', | |
get_stylesheet_directory_uri() . '/style.css', | |
array( $parent_style ) | |
); | |
} | |
add_action( 'wp_enqueue_scripts', 'mychildtheme_enqueue_styles' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Theme Name: [Your Theme Name] | |
Description: The custom theme [Your Theme Name] using the parent theme Twenty Fifteen. | |
Author: [You] | |
Author URI: [Your URL] | |
Template: twentyfifteen | |
Version: 1 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// first we need an asynchronous function that returns a promise | |
function getBurger () { | |
return new Promise(function (resolve, reject) { | |
// making burger ... | |
if (error) { | |
reject(error); | |
} else { | |
resolve(burger); | |
} | |
}); |
NewerOlder