Skip to content

Instantly share code, notes, and snippets.

View connor4312's full-sized avatar

Connor Peet connor4312

View GitHub Profile
@connor4312
connor4312 / gist:ec15140e972dc27ae465
Last active August 29, 2015 14:06
Find an angular element by in a scope.
/**
* Simple jquery extension to find all elements in a certain Angular scope.
* Usage:
*
* var myElement = $.inScope('.item', $scope);
*
* @param {string} selector
* @param {Angular.Scope} $scope
* @returns {jQuery}
*/
@connor4312
connor4312 / gist:af385d566f016a634a54
Last active August 29, 2015 14:03
A Tiny jQuery Plugin
#########################################################################
# Tiny jQuery plugin that lets us do actions on hidden elements, so we
# can grab heights and such!
##########################################################################
$.fn.whileHidden = (action, args...) ->
r = @show()[action](args...)
@hide()
return r
@connor4312
connor4312 / gist:7f541daf82d7b6b12314
Last active August 29, 2015 14:01
Javascript Semi-Signficant Figures
/**
Handy function to get (kind of) significant figures from Javascript numbers.
Unlike built-in Javascript methods, this works for all numbers, not just decimals.
Example: sigFigs(12345, 2) -> 12000
sigFigs(0.022, 1) -> 0.02
**/
function sigFigs(num, figures) {