Skip to content

Instantly share code, notes, and snippets.

@j26design
j26design / activeMenu.js
Last active December 28, 2015 08:38
Add a class to menu items that match the current URL of the page (jQuery)
jQuery(function(){
var page = window.location.pathname,
find = new RegExp(page == '/' ? window.location.origin + '/?jQuery' : page.replace(/\/jQuery/,''));
jQuery('nav a').each(function(){
if(find.test(this.href.replace(/\/jQuery/,''))){
jQuery(this).addClass('active');
}
});
});
@j26design
j26design / continueShoppingRedirect.js
Last active December 20, 2015 21:15 — forked from makfruit/ecwid_redirect_continue_shopping.html
An HTML/Javascript code snippet for Ecwid to redirect continue shopping buttons to a custom page
if (typeof(Ecwid) == 'object') {
Ecwid.OnAPILoaded.add(function() {
// Redirect address. Change it to the URL of page where you want to redirect your customers.
// You can use absolute or relative addresses, e.g. 'index.html', 'http://google.com'
var continueShoppingRedirect = "#!/~/category/id=0";
// Delay (ms), which is necessary for the empty cart page to appear after onCartChange event firing
var empty_cart_page_delay = 500;
// Continue shopping buttons CSS selectors
@j26design
j26design / .htaccess
Last active December 20, 2015 21:01
Redirect from old domain to new domain
## Redirect from olddomain to newdomain
<IfModule mod_rewrite.c>
RewriteEngine On
# Redirect to non-www
RewriteCond %{HTTP_HOST} ^olddomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.olddomain\.com$
RewriteRule (.*)$ http://newdomain.com/$1 [R=301,L]
# Redirect to www
RewriteCond %{HTTP_HOST} ^olddomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.olddomain\.com$
@j26design
j26design / .htaccess
Last active December 20, 2015 21:26
www .htaccess redirects
<IfModule mod_rewrite.c>
RewriteEngine On
# Redirect to non-www
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# Redirect to www
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
</IfModule>
@j26design
j26design / .htaccess
Last active February 2, 2016 05:20
Remove .html file extension
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
@j26design
j26design / .htaccess
Last active January 8, 2016 06:48
Enable compression with deflate in .htaccess
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rdf+xml application/rss+xml application/schema+json application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-javascript application/x-web-app-manifest+json application/xhtml+xml application/xml font/eot font/opentype image/bmp image/svg+xml image/vnd.microsoft.icon image/x-icon text/cache-manifest text/css text/html text/javascript text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy text/xml
</ifmodule>
@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"
@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 / .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 / 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