Skip to content

Instantly share code, notes, and snippets.

View jamesmusgrave's full-sized avatar

James Musgrave jamesmusgrave

View GitHub Profile
@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');
@jamesmusgrave
jamesmusgrave / _smart-underline.scss
Last active September 24, 2019 17:57
Smart Underline Sass Mixin
@mixin smart-underline($background: #fff, $text: #000, $selection: #ffc, $position: 86%){
a {
color: inherit;
text-decoration: none;
background: -webkit-linear-gradient($background, $background), -webkit-linear-gradient($background, $background), -webkit-linear-gradient($text, $text);
background-size: .05em 1px, .05em 1px, 1px 1px;
background-repeat: no-repeat, no-repeat, repeat-x;
text-shadow: 0.03em 0 $background, -0.03em 0 $background, 0 0.03em $background, 0 -0.03em $background, 0.06em 0 $background, -0.06em 0 $background, 0.09em 0 $background, -0.09em 0 $background, 0.12em 0 $background, -0.12em 0 $background, 0.15em 0 $background, -0.15em 0 $background;
background-position-y: $position,$position, $position;
background-position-x: 0%, 100%, 0%;
<html>
<head>
<title>Dithering Test</title>
</head>
<body>
<canvas></canvas>
<script>
var canvas = document.getElementsByTagName("canvas")[0];
@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);
countryHash: {
unicodeCountry: {
AF: "Afghanistan",
AX: "Aland Islands",
AL: "Albania",
DZ: "Algeria",
AS: "American Samoa",
AD: "Andorra",
AO: "Angola",
AI: "Anguilla",