Skip to content

Instantly share code, notes, and snippets.

View jesgundy's full-sized avatar

Jesse Gundy jesgundy

View GitHub Profile
@jesgundy
jesgundy / window-model.js
Created April 1, 2014 19:19
A require module that leverages backbone jquery and underscore to debounce and keep a running log of the window width for all components to listen to.
define([
'backbone',
'jquery',
'underscore'
], function(Backbone, $, _) {
// x-browser window width test
function winWidth() {
var w = 0;
@jesgundy
jesgundy / evts.js
Created March 31, 2014 16:08
Bind to transition end JS event.
evts = 'transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd';
$menu.bind( evts, function() {
$menu.css('visibility', 'hidden');
$menu.unbind( evts );
});
@jesgundy
jesgundy / fonts.scss
Created March 27, 2014 14:47
Font-Icons Cheat Sheet. (Based on http://filamentgroup.com/lab/bulletproof_icon_fonts/) (Assumes Ruby/Rails env w/ Bourbon, Modernizr, Fontello, etc)
// Icon-Font Cheat Sheet
// Based on http://filamentgroup.com/lab/bulletproof_icon_fonts/
// Non-Critical icon
// ---
// <a href="#">
// <span class="icon-x" aria-hidden="true"></span> Menu
// </a>
@jesgundy
jesgundy / ie.js
Created January 24, 2014 19:51
Down and dirty IE detection script. Works on IE11.
function getInternetExplorerVersion() {
var rv = -1;
if (navigator.appName == 'Microsoft Internet Explorer')
{
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat( RegExp.$1 );
}
else if (navigator.appName == 'Netscape')
@jesgundy
jesgundy / ie8fonts.scss
Created January 16, 2014 15:58
Method to trigger IE8's redraw for icon fonts. (Currently untested)
// This triggers a redraw in IE to Fix IE8's :before content rendering.
html:hover [class^="icon-"] {
-ms-zoom: 1;
}
@jesgundy
jesgundy / handy.txt
Created December 12, 2013 18:49
Greg's Handy formulas
Radians of a circle: Math.PI * 2;
Radians to degrees: radians * 180 / Math.PI;
Degrees to radians: degrees * Math.PI / 180;
Midpoint interpolation: minValue + (maxValue - minValue) * percent
Angle (radians) between two points: Math.atan2(end.y-start.y, end.x-start.x)
distance between two points: pythagorean theorem...
function distance(start, end) {
var a = start.x-end.x, b = start.y-end.y;
@jesgundy
jesgundy / archive
Last active December 30, 2015 20:08
Archive repo from Github
# From Desktop
git clone -o github git@github.com:{User}/{Repo}.git {Repo}
# tar (and feather) it
tar -czvf {DESTINATION}.tar.gz {TARGET FOLDER}
@jesgundy
jesgundy / distance.js
Last active December 21, 2015 07:09
Find the distance between two locations with longitude/latitude points using the Haversine formula.
function deg2rad(deg) {
return deg * (Math.PI/180)
};
function getDistance(lat1, lon1, lat2, lon2) {
var R = 3959; // Radius of the earth in miles
var dLat = deg2rad(lat2-lat1); // deg2rad below
var dLon = deg2rad(lon2-lon1);
var a =
Math.sin(dLat/2) * Math.sin(dLat/2) +
@jesgundy
jesgundy / sass-system.md
Created June 27, 2013 18:43
Outlining a system for writing Sass.

Sass 'Alphabetization'

I wanted to outline a potential system for organizing Sass declarations. Since Alphabetization has also been a hot topic (of which I am in favor), it outlines how things such as nesting, @extend, @include, and comments would all fall into the same system. This is by no means a perfect system - but after using Sass for a variety of different things, this is the organization I've found that can deal most easily with edge cases.

Please feel free to critique / edit / etc.

Order of Items

  1. Module label - Succinct top-level label for the section of code (if applicable)
  2. Selector
@jesgundy
jesgundy / detection.js
Created May 24, 2013 14:57
Vanilla JS detection module.
// Vanilla JS tests for detecting HTML elements
define('detection', function() {
if (!document.querySelectorAll) {
var d=document, s=d.createStyleSheet();
d.querySelectorAll = function(r, c, i, j, a) {
a=d.all, c=[], r = r.replace(/\[for\b/gi, '[htmlFor').split(',');
for (i=r.length; i--;) {
s.addRule(r[i], 'k:v');
for (j=a.length; j--;) a[j].currentStyle.k && c.push(a[j]);
s.removeRule(0);