Skip to content

Instantly share code, notes, and snippets.

@johnstew
johnstew / showhidden.bash
Created January 4, 2015 23:58
Mac Show Hidden Files
defaults write com.apple.finder AppleShowAllFiles NO
defaults write com.apple.finder AppleShowAllFiles YES
@johnstew
johnstew / package.json
Last active August 29, 2015 14:12
Package.json v2
{
"name": "Project",
"version": "0.1.0",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-autoprefixer": "^2.0.0",
"grunt-contrib-concat": "^0.5.0",
"grunt-contrib-imagemin": "^0.9.2",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-nodeunit": "~0.4.1",
@johnstew
johnstew / GruntFile.js
Created January 2, 2015 21:49
GruntFile v2
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
build: {
src: 'includes/production/js/production.js',
dest: 'includes/production/js/production.min.js'
}
@johnstew
johnstew / ie8helpers.js
Created January 2, 2015 19:52
IE8 Helper Functions
/*
Helper functions.
*/
//add
function addClass(el, cls){
return (el.className == "") ? el.className += cls : el.className += " "+cls;
}
//remove
@johnstew
johnstew / scrolltop.js
Created December 30, 2014 16:23
JS Scroll Top
button.onclick = function(){
//get current scrollpos and calculate step
var offset = this.getBoundingClientRect(),
scrollStep = -window.pageYOffset / (500/15);
//call our scroll top function
scrollToTop(scrollStep);
};
/*
Scroll to top function.
@johnstew
johnstew / classprototype.js
Created December 23, 2014 20:27
JS Class Prototype
HTMLElement.prototype.addClass = function(cls){
return this.classList.add(cls);
};
HTMLElement.prototype.removeClass = function(cls){
return this.classList.remove(cls);
};
HTMLElement.prototype.hasClass = function(cls){
return this.classList.Contains(cls);
@johnstew
johnstew / ie8svgimage
Created December 22, 2014 21:01
IE 8 SVG Image
<!--[if IE 8]>
<img alt='Chase.com <http://Chase.com> Homepage' src='includes/production/images/logo.png'>
<![endif]-->
<img alt='Chase.com <http://Chase.com> Homepage' class='svgimg' onerror="this.src='includes/production/images/logo.png'; this.onerror=null;" src='includes/production/images/logo.svg'>
@johnstew
johnstew / emailbp.html
Created December 19, 2014 15:11
HTML Email Boilerpplate
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width"/>
<link rel="stylesheet" href="ink.css"> <!-- For testing only -->
<style type="text/css">
@johnstew
johnstew / runoncescroll.js
Created December 2, 2014 21:17
Window Scroll Run Once Hack
var t;
$(window).scroll(function() {
clearTimeout(t);
t = setTimeout(function() {
alert("Scrolled Once!");
}, 250);
});
@johnstew
johnstew / GruntFile.js
Created November 16, 2014 03:56
Basic GruntFile.js
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
dist: {
files: {
'css/main.css' : 'sass/main.scss'
}
}
},