Skip to content

Instantly share code, notes, and snippets.


James Musgrave jamesmusgrave

View GitHub Profile
View countryHash
countryHash: {
unicodeCountry: {
AF: "Afghanistan",
AX: "Aland Islands",
AL: "Albania",
DZ: "Algeria",
AS: "American Samoa",
AD: "Andorra",
AO: "Angola",
AI: "Anguilla",
jamesmusgrave / cachedjson.js
Last active Dec 27, 2015 — forked from kpuputti/gist:1040118
Cached JSON via jQuery
View cachedjson.js
var getCachedJSON = function (url) {
var deferred = new $.Deferred();
var cachedData = window.localStorage[url];
if (cachedData) {
log('Data already cached, returning from cache:', url);
} else {
$.getJSON(url, function(data) {
log('Fetched data, saving to cache:', url);
window.localStorage[url] = JSON.stringify(data);
jamesmusgrave / pre-commit.sample
Last active Jan 3, 2016
Grunt on pre-commit
View pre-commit.sample
# Pre-commit file needs to be executable so first
# chmod +x .git/hooks/pre-commit
# Fix your grunt path
# Runs grunt default
echo "Running Grunt..."
View FloydSteinberg.html
<title>Dithering Test</title>
var canvas = document.getElementsByTagName("canvas")[0];
jamesmusgrave / _smart-underline.scss
Last active Sep 24, 2019
Smart Underline Sass Mixin
View _smart-underline.scss
@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%;
jamesmusgrave / widowFix.js
Created Nov 12, 2014
Angular Widow Fix Filter
View widowFix.js
(function() {
'use strict';
.filter('widowFix', function() {
return function(input) {
if (input !== undefined) {
var wrapper= document.createElement('div');
View iOS-iFrame fix
#doc {
height: 100%; // Passes through the height of the parent iframe element
#doc {
// Magic to prevent iOS growing the iFrame to fit the content.
// This container will mimic the behavior of the iframe on a desktop browser
overflow-y: scroll;
#Fix a folder made as root
sudo chown -R $(whoami) .
#List files in single column
ls -R -1 .
View datewithtimezone.js
Date.prototype.stdTimezoneOffset = function() {
var jan = new Date(this.getFullYear(), 0, 1);
var jul = new Date(this.getFullYear(), 6, 1);
return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset());
Date.prototype.dst = function() {
return this.getTimezoneOffset() < this.stdTimezoneOffset();