Skip to content

Instantly share code, notes, and snippets.

@steveosoule
steveosoule / htaccess-force-www.htaccess
Created November 30, 2012 00:33
Force WWW on Non-Secure URLS and Keep Request URI
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule ^ http://www.domain.com%{REQUEST_URI} [L,R=301]
(!window.console||!console.log)&&function(){for(var c=function(){},a="assert clear count debug dir dirxml error exception group groupCollapsed groupEnd info log markTimeline profile profileEnd markTimeline table time timeEnd timeStamp trace warn".split(" "),b=a.length,d=window.console={};b--;)d[a[b]]=c}();
<?
// Snippet from: http://net.tutsplus.com/tutorials/php/understanding-hash-functions-and-keeping-passwords-safe/
/* ---- Defining the Class ---- */
class PassHash {
// blowfish
private static $algo = '$2a';
// cost parameter
private static $cost = '$10';
@steveosoule
steveosoule / force-www-on-all-pages.htaccess
Created January 4, 2013 01:13
Force WWW On All Pages
# FORCE WWW ON ALL PAGES
RewriteCond %{HTTP_HOST} !^www\.(.+)
RewriteCond %{HTTPS}s ^(on(s)|offs)
RewriteRule ^ http%2://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
@steveosoule
steveosoule / simple-scroll-to-element.js
Last active May 13, 2024 09:34
Simple Scroll To Anchor
// Found at: http://jsfiddle.net/BjpWB/4
function scrollToAnchor(aid){
var aTag = $("a[name='"+ aid +"']");
$('html,body').animate({scrollTop: aTag.offset().top},'slow');
}
scrollToAnchor('id3');
function scrollTo($element){
$('html,body').animate({scrollTop: $element.offset().top},'slow');
}
@steveosoule
steveosoule / regex-string-whitelist.js
Last active October 15, 2022 18:59
JavaScript Regular Expression Whitelist for String
// in the regex, the carrot(^) negates the match, so if the stringToReplace contains something that is not a-z or 0-9 it will be replaced
// In this case the desired string will only be alpha numeric characters, stripping out spaces and symbols
// Help from: http://stackoverflow.com/questions/4374822/javascript-regexp-remove-all-special-characters
var desired = stringToReplace.replace(/[^a-zA-Z0-9]/gi, '')
@steveosoule
steveosoule / common-settings.htaccess
Last active December 10, 2015 21:50
Common .htaccess Settings
### SOURCE: http://stackoverflow.com/questions/6847649/htaccess-help-need-to-force-www-https-and-remove-index-php
### Force WWW:
RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L] # include 's' here to force ssl in addition to www
### Force SSL:
RewriteCond %{SERVER_PORT} 80
@steveosoule
steveosoule / miva_clear-file-cache.html
Last active December 10, 2015 23:59
Miva clear file cache
<link rel="stylesheet" href="css/styles.css?v=<mvt:eval expr="stime('/mm5/css/styles.css')"/>">
@steveosoule
steveosoule / blocking-users.htaccess
Last active January 26, 2016 23:41
htaccess block users
# From: http://www.unitedforums.co.uk/vb/website-development-scripting/10926-how-block-wget.html
# Turn on mod_rewrite
RewriteEngine On
# Block undesirable requests in general
RewriteCond %{THE_REQUEST} ^GET\ http [NC,OR]
# Block undesirable requests specifically
RewriteCond %{REQUEST_URI} cs\.txt?$ [OR]