Skip to content

Instantly share code, notes, and snippets.

View jamesmusgrave's full-sized avatar

James Musgrave jamesmusgrave

View GitHub Profile
@jamesmusgrave
jamesmusgrave / pre-commit.sample
Last active January 3, 2016 14:09
Grunt on pre-commit
#!/bin/sh
# Pre-commit file needs to be executable so first
# chmod +x .git/hooks/pre-commit
# Fix your grunt path
PATH="/usr/local/bin:$PATH"
# Runs grunt default
echo "Running Grunt..."
@jamesmusgrave
jamesmusgrave / cachedjson.js
Last active December 27, 2015 11:59 — forked from kpuputti/gist:1040118
Cached JSON via jQuery
var getCachedJSON = function (url) {
var deferred = new $.Deferred();
var cachedData = window.localStorage[url];
if (cachedData) {
log('Data already cached, returning from cache:', url);
deferred.resolve(JSON.parse(cachedData));
} else {
$.getJSON(url, function(data) {
log('Fetched data, saving to cache:', url);
window.localStorage[url] = JSON.stringify(data);
#Fix a folder made as root
sudo chown -R $(whoami) .
#List files in single column
ls -R -1 .
diff -qr dirA dirB | sort > diffs.txt
@jamesmusgrave
jamesmusgrave / widowFix.js
Created November 12, 2014 12:24
Angular Widow Fix Filter
(function() {
'use strict';
angular.module('webApp.filters')
.filter('widowFix', function() {
return function(input) {
if (input !== undefined) {
var wrapper= document.createElement('div');
<html>
<head>
<title>Dithering Test</title>
</head>
<body>
<canvas></canvas>
<script>
var canvas = document.getElementsByTagName("canvas")[0];