Skip to content

Instantly share code, notes, and snippets.


msacket msacket

View GitHub Profile

Leverage Angular without Starting from Scratch

There are days in a life that emerge as stand outs amongst the rest. Some of those days are expected; a wedding perhaps or the birth of a child. Others happen without fanfare. The day I found Angular was one of those days.

I was in the midst of working on the Arch LMS. It had become laborious. The UI I had envisioned was becoming a mess of ajax calls glued together with jQuery. It worked, but it was fragile. That wasn't really jQuery's fault. I used it for something it wasn't meant to do and tracking all those events was impossible.

Seeking something else, I found myself watching a presentation on Knockout. Not bad. It did lead me to Underscore.js, but for some reason it wasn't clicking for me. Perhaps if I'd given it more time. Still, I thought there had to be a better way. Then I fou

View xg-bootstrap.js
* xg-bootstrap.js
* Injects an Angular module into the DOM asynchronously and returns a promise
* to resolve when the injection is complete.
define(['angular'], function(angular) {
return function(app, appEl, $selector){
var d;
angular.injector(['ng']).invoke(['$q', function($q){
msacket / sort_by_array.php
Last active Jan 14, 2017
PHP Multi-Sort Function - Sorts an array based on positional matches in other arrays.
View sort_by_array.php
* Sorts an array based on matching multiple criteria.
* Given
* $array => ['big cat', 'small dog', 'big dog', 'small cat']
* $criteira =>[['dog','cat'], ['big','small']]
* Results: (biggest to smallest)