Skip to content

Instantly share code, notes, and snippets.

@j26design
j26design / .htaccess
Created April 11, 2016 19:57
Force .html extension with .htaccess
# This code must be placed in the .htaccess
# file that is located in the root directory
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^.]+?)/?$ /$1.html [L,R=301]
$('a[href*="//"]:not([href*="'+ location.hostname +'"])').attr('target','_blank');
@j26design
j26design / responsive-youtube.js
Created March 31, 2016 08:46
Responsive YouTube videos
// Find all YouTube videos
var $allVideos = $("iframe[src^='//www.youtube.com']"),
// The element that is fluid width
$fluidEl = $("body");
// Figure out and save aspect ratio for each video
$allVideos.each(function() {
$(this)
@j26design
j26design / cpt-genesis.php
Created March 24, 2016 23:26 — forked from neilgee/a-cpt.php
CPT (Custom Post Type) Genesis Theme - Plugin - WordPress Example
<?php
/*
Plugin Name: Event Custom Post Type
Plugin URI: http://wpbeaches.com/create-custom-post-types-in-genesis-child-theme-in-wordpress/
Description: Custom Post Types for Event
Author: Neil Gee
Version:1
Author URI:http://wpbeaches.com
*/
@j26design
j26design / .htaccess
Last active November 2, 2018 04:11
Redirect subdomain to subfolder
RewriteEngine on
RewriteCond %{HTTP_HOST} ^subdomain\.example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.subdomain\.example\.com$
RewriteRule ^/?$ "http\:\/\/www\.example\.com\/subdomain\/" [R=301,L]
@j26design
j26design / .htaccess
Created February 23, 2016 16:13
Prevent users from accessing directories with .htaccess
# prevent directory browsing
Options All -Indexes
@j26design
j26design / gist:24f03d219e25cbc7c9c0
Created February 11, 2016 13:27
Archive individual folders into separate archives from terminal
for i in */; do zip -r "${i%/}.zip" "$i"; done
@j26design
j26design / .json
Created February 9, 2016 03:30
Amazon Cloudfront S3 bucket policy makes all objects publicly accessible by default.
{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "AllowPublicRead",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
@j26design
j26design / .htaccess
Last active February 1, 2016 20:04
Redirect specific domain to or away from https
# Redirect to https
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} example\.com$ [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
# Redirect to http
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} example\.com$ [NC]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
@j26design
j26design / .htaccess
Last active January 8, 2016 07:07
Leverage browser caching with expire tags in .htaccess
<ifModule mod_expires.c>
ExpiresActive On
# Expiration can be defined by years, months, weeks, days, hours, minutes, and seconds
# CSS
ExpiresByType text/css "access plus 1 week"
# Data
ExpiresByType application/atom+xml "access plus 1 hour"
ExpiresByType application/rdf+xml "access plus 1 hour"