Skip to content

Instantly share code, notes, and snippets.

View westonwatson's full-sized avatar

Weston Watson westonwatson

View GitHub Profile
@westonwatson
westonwatson / table-column-count.js
Created March 7, 2014 16:26
Count Table Column Values
function tableColumnTotal(tableClassName,columnClassName){
var columnIndexes = [];
var columnTotals = [];
//grab all tables
var tablesToInspect = document.getElementsByClassName(tableClassName);
//if tables found
if (tablesToInspect.length > 0){
//loop thru tables
@westonwatson
westonwatson / html5_input_polyfill.js
Last active January 4, 2016 05:59
Basic HTML5 Input (placeholder and required) Polyfill/Shim Loader using Modernizr.
//defer until Modernizr is loaded.
$(function () {
/* HTML5 Input Placeholder Polyfill. */
Modernizr.load({
test: Modernizr.input.placeholder,
nope: [
'/assets/css/placeholder_polyfill.min.css',
'/assets/js/placeholder_polyfill.jquery.min.combo.js'
]
@westonwatson
westonwatson / password-strength.js
Created December 10, 2013 20:05
regex Patterns for Password Strength
// STRONG PASSWORD
// Must have capital letter, numbers and lowercase letters
var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
// MEDIUM PASSWORD
// Must have either capitals and lowercase letters or lowercase and numbers
var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
// WEAK PASSWORD
// Must be at least 6 characters long
@westonwatson
westonwatson / server-side-js.sh
Created December 1, 2013 15:40
install nodejs phantomjs and casperjs
apt-get update
apt-get -y install rpcbind nfs-common
apt-get -y install libfontconfig
apt-get -y install git
wget http://phantomjs.googlecode.com/files/phantomjs-1.9.1-linux-x86_64.tar.bz2
tar -xvf phantomjs-1.9.1-linux-x86_64.tar.bz2
sudo mv phantomjs-1.9.1-linux-x86_64 /usr/local/src/phantomjs
rm phantomjs-1.9.1-linux-x86_64.tar.bz2
sudo ln -sf /usr/local/src/phantomjs/bin/phantomjs /usr/local/bin/phantomjs
phantomjs --version
@westonwatson
westonwatson / external-links.js
Created November 1, 2013 19:50
Sets the "target" attribute for any links to external domains on your page.
@westonwatson
westonwatson / casper_and_phantom
Created October 24, 2013 13:16
phantomjs and casperjs install on Ubuntu
apt-get update
apt-get -y install libfontconfig
wget http://phantomjs.googlecode.com/files/phantomjs-1.9.1-linux-x86_64.tar.bz2
tar -xvf phantomjs-1.9.1-linux-x86_64.tar.bz2
sudo mv phantomjs-1.9.1-linux-x86_64 /usr/local/src/phantomjs
rm phantomjs-1.9.1-linux-x86_64.tar.bz2
sudo ln -sf /usr/local/src/phantomjs/bin/phantomjs /usr/local/bin/phantomjs
phantomjs --version
cd /usr/local/src/
sudo git clone git://github.com/n1k0/casperjs.git
@westonwatson
westonwatson / urlparse.js
Last active December 24, 2015 19:59
Javascript URL Parser Hack
#first line is the actual parser (DOM Hack)
var parser = document.createElement('a');
#below are example usages
parser.href = "http://example-domain:1337/path/?search=query#anchor";
parser.protocol; // => "http:"
parser.hostname; // => "example-example.com"
parser.port; // => "1337"
parser.pathname; // => "/path/"
parser.search; // => "?search=query"
@westonwatson
westonwatson / mysqldate.php
Last active December 23, 2015 22:39
always forget the php MySQL Date format
$datetime = strtotime("now");
$mysqldate = date("m/d/y g:i A", $datetime);
@westonwatson
westonwatson / gist:6354598
Created August 27, 2013 14:52
install rbenv/ruby/rails/gem/rake/bundler
curl https://raw.github.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash
nano ~/.bashrc
#insert into .bashrc
export RBENV_ROOT="${HOME}/.rbenv"
if [ -d "${RBENV_ROOT}" ]; then
export PATH="${RBENV_ROOT}/bin:${PATH}"
eval "$(rbenv init -)"
fi
@westonwatson
westonwatson / install.nodejs.git.curl.sh
Created August 27, 2013 14:49
install nodejs, git, curl
sudo apt-get update
sudo apt-add-repository -y ppa:chris-lea/node.js
sudo apt-get install python-software-properties
sudo apt-get -y update
sudo apt-get -y install curl git-core nodejs