Skip to content

Instantly share code, notes, and snippets.

Avatar

Adam Norwood adamnorwood

View GitHub Profile
@adamnorwood
adamnorwood / switchToLocalhost.js
Created Mar 2, 2016
Bookmarklet: switch between .dev domain and localhost (helpful for BrowserSync testing)
View switchToLocalhost.js
javascript:(function(){var d='law.utexas.dev',l='localhost',n=(document.domain==d)?document.location.toString().replace(document.domain,l+':3000'):(document.domain==l)?document.location.toString().replace(document.domain+':3000',d):'';if ( n ) window.location.href = n;})()
@adamnorwood
adamnorwood / vagrant-halt.sh
Created Jan 25, 2016
Simple zsh / bash function and alias for halting all running Vagrant guests
View vagrant-halt.sh
halt_running_vagrant_guests() {
vagrant global-status | awk '/running/{print $1}' | xargs -n 1 -- vagrant halt
}
alias vagrant-halt='halt_running_vagrant_guests'
@adamnorwood
adamnorwood / Gruntfile.js
Last active Aug 29, 2015
Gruntfile for Pattern Lab + Compass + LiveReload
View Gruntfile.js
/*
Gruntfile for Pattern Lab + Compass + LiveReload
This is a sample Gruntfile for integrating Pattern Lab's template
regeneration with Compass and LiveReload.
I've found that using the Chrome LiveReload extension is slow as it
forces a full-page browser reload instead of using CSS injection. This
Gruntfile setup seems to work great, though, if you use the LiveReload
JS snippet instead. Just add this script right before the closing
@adamnorwood
adamnorwood / Gruntfile.js
Last active Oct 3, 2018
Gruntfile for Pattern Lab + Compass + Live Reload via grunt-browser-sync
View Gruntfile.js
/*
Gruntfile for Pattern Lab + Compass + Live Reload via grunt-browser-sync
Set up to use browser-sync because for the life of me I can't get
the grunt-contrib-watch livereload to *inject* the compiled CSS changes
to the browser (as opposed to livereload doing a full page refresh)...
(To be clear, the CSS injection I'm talking about is where changes to
the CSS file are slipped in to the browser very quickly with no
full page reload, and without losing your place if you've scrolled
@adamnorwood
adamnorwood / newsite.sh
Created May 9, 2013
A simple bash script for setting up a local directory and corresponding entry in /etc/hosts, suitable for use with Apache wildcard name-based virtual hosts. For example: 'newsite example.dev' creates a directory called /www/example.dev/ and also adds appropriate 127.0.0.1 / ::1 entries for example.dev to /etc/hosts (the latter step requires sudo).
View newsite.sh
#!/bin/bash
DIRECTORY="/www/$1"
DIR_CREATED=false
HOSTS_EDITED=false
if [ -d "$DIRECTORY" ]; then
echo "* Directory $DIRECTORY already exists, skipping this step."
else
mkdir $DIRECTORY
DIR_CREATED=true
You can’t perform that action at this time.