Skip to content

Instantly share code, notes, and snippets.

View jlittlejohn's full-sized avatar

Josh Littlejohn jlittlejohn

View GitHub Profile
@jlittlejohn
jlittlejohn / gist:5266916
Created March 28, 2013 21:21
JS: Conditional Event Handling
// Conditional Event Handling
$('#target').click(function(e) {
if ( $(e.target).is('a') ) {
// code
// e.preventDefault();
}
});
@jlittlejohn
jlittlejohn / gist:5266757
Created March 28, 2013 21:01
JS: Add Class on Hover
// Add Class on Hover
$('#target').bind('mouseenter mouseleave', function(e){
$(this).toggleClass('active', e.type === 'mouseenter');
}))
@jlittlejohn
jlittlejohn / gist:5090968
Created March 5, 2013 15:12
SCSS: @font-face Declaration
// Font Name
@font-face {
font-family: 'Font Name';
src: url('/assets/fonts/Font-Name.eot');
src: url('/assets/fonts/Font-Name.eot?#iefix') format('embedded-opentype'),
url('/assets/fonts/Font-Name.woff') format('woff'),
url('/assets/fonts/Font-Name.ttf') format('truetype'),
url('/assets/fonts/Font-Name.svg#fontname') format('svg');
font-weight: normal;
font-style: normal;
@jlittlejohn
jlittlejohn / gist:5044990
Created February 27, 2013 04:10
JS: Browser Back & Forward (Vanilla)
function moveBack() { // Simulate Back Button
history.back();
}
function moveForward() { // Simulate Forward Button
history.forward();
}
@jlittlejohn
jlittlejohn / gist:5034822
Created February 26, 2013 00:54
JS: Add Event (Vanilla)
var addEvent = (function() {
return function(elem, type, fn) {
if (document.addEventListener) {
if (elem && !elem.length) {
elem.addEventListener(type, fn, false);
}
else if ( elem && elem.length) {
var len = elem.length;
for (var i = 0; i < len; i++) {
addEvent(elem[i], type, fn);
@jlittlejohn
jlittlejohn / gist:5006716
Created February 21, 2013 17:59
SCSS: Media-Queries Template
/*********************************************
MEDIA QUERIES
*********************************************/
/* MOBILE PORTRAIT */
@media only screen and (min-width: 320px) {
body {
}
}
@jlittlejohn
jlittlejohn / gist:4986708
Created February 19, 2013 15:11
HTACCESS: 5G Blacklist 2013
# 5G BLACKLIST/FIREWALL (2013)
# @ http://perishablepress.com/5g-blacklist-2013/
# 5G:[QUERY STRINGS]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} (\"|%22).*(<|>|%3) [NC,OR]
RewriteCond %{QUERY_STRING} (javascript:).*(\;) [NC,OR]
RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3) [NC,OR]
@jlittlejohn
jlittlejohn / gist:4773456
Created February 12, 2013 21:15
JS: Embed Google Maps
<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
//<![CDATA[
// Create an array of styles.
var styles = [
{
stylers: [
{ saturation: -85 }
]
},{
@jlittlejohn
jlittlejohn / gist:4756814
Created February 11, 2013 19:16
WP: Basic Loop
<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
// code
<?php endwhile; endif; ?>
@jlittlejohn
jlittlejohn / JS: Password Strength Indication
Created January 31, 2013 15:03
JS: Password Strength Indication
function passwordStrength(password) {
var $ = jqnc();
var desc = new Array();
desc[0] = "Very Weak";
desc[1] = "Weak";
desc[2] = "Better";
desc[3] = "Medium";
desc[4] = "Strong";
desc[5] = "Strongest";