Skip to content

Instantly share code, notes, and snippets.

Jim Montgomery jimmont

Block or report user

Report or block jimmont

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
jimmont / transitionEnd.js
Created May 3, 2014
transitionEnd attribute directive
View transitionEnd.js
element{transition:height 500ms ease-out;height:10px;}
<element transition-end="endTransition($event)"></element>
$scope.endTransition = function(e){ }
.directive('transitionEnd', function($parse){
return {
restrict: 'A'
,link: function(scope,elem,attr){
jimmont / detectTextFile.js
Created May 23, 2014
check if a file is text based on its content
View detectTextFile.js
// detect if a text file, like Perl's stat(file); if(-T) ...,'r',function(err, fd){
if(err) return;
var len = 100;
var buf = new Buffer(len);
var re = /[.a-z0-9(){}\[\]? "':;<>?\s\n\r\t "':;#@~$%*<>.,_=+-]/ig;,buf,0,len,0,function(err,num,buf){
if(err || num < 1) return;
var str = buf.toString('utf-8',0,num);
// do we have enough of the types of characters typical of a text file?
jimmont / anagramDetector
Last active Aug 29, 2015
your anagrams are showing doctor
View anagramDetector
/* usage: isAnagram('Elvis','lives'); */
function isAnagram(read,dear){
return read.toLowerCase().split('').sort().join('') === dear.toLowerCase().split('').sort().join('');
jimmont / sumArray-ng-filter.js
Created Aug 13, 2014
Infinity number error handling in Angular filters for pass-thru. Positive stuff!
View sumArray-ng-filter.js
* @ngdoc filter
* @name sumArray
* @description
* return the sum of a list of values (no explicit type coercion)
* @example
`we have {{ [1, 2, 3] | sumArray }} items`
jimmont / ng-expressions.html
Last active Aug 29, 2015
Angular expression collection. Or something like that.
View ng-expressions.html
$scope.j = 4;
$scope.stuff = [3,7,1,0];
$scome.time = new Date
<hr ng-init="ping=[1,2,3]" ng-bind="::once" ng-attr-j="::{{ 1 + jOnce }}" ng-repeat="a in b = (stuff | orderBy: 'toString()' ) track by $index">
<time ng-attr-title="{{ time | date:'EEEE MMMM d, yyyy h:mm:ss a (\'GMT\'Z)' }}">{{time | date:'MM/dd/yy HH:mm:ss'}}</time>
View ng-directives
(function() {
'use strict';
.directive('inputRange', ['$parse', function ngRangeSlider($parse) {
* @ngdoc directive
* @name input-range
* @description
dual-control range inputs
* @example
jimmont / diff
Last active Aug 29, 2015
what changed from the default
View diff
function diff(defaults, customs, diffs){
* @description
compare an object against the default returning an object with the differences
in the customs object separated out in the returned value
when there are no unique values in the customs object undefined is returned
* @returns
diff value, when no differences undefined, when an object returns object with keys and other values
* @example
usr.diff(defaults, custom);
jimmont / extend.js
Created Jan 14, 2015
Extend something, experimental alternative to SomeClass.prototype = AnotherClass() then extend further.
View extend.js
function extend( proto, template ){
var prop;
for(prop in template){
if( typeof(template[prop]) === 'function' ){
// relay arguments, using predefined functions where possible
proto[ prop ] = proto[ prop ] || (function(prop){
return function(){ return this._xhr[ prop ].apply(this._xhr, arguments); };
jimmont / sortable.js
Created Apr 16, 2015
sort it out in angular
View sortable.js
* @ngdoc directive
* @name sortable
* @restrict A
* @description
* setup an object on the scope for handling a list: sorting, filtering, etc
* NOTE that track by statements must go at the end of the expression, after the orderBy statement
* @example
View paginate.js
.directive('paginateThis', function(paginate, $parse, $location){
return {
restrict: 'A',
link: function (scope, elem, attr){
function mapOnToModel(res){
var p = scope.paginate
, _esp = JSON.stringify( res.options.query )
, _sort = JSON.stringify( res.options.sort )
You can’t perform that action at this time.