This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function encodeURIObject(o) { | |
| var a = []; | |
| for (k in o) { | |
| a.push(encodeURIComponent(k) + '=' + encodeURIComponent(o[k])) | |
| } | |
| return a.join('&'); | |
| } | |
| // test: | |
| var uriStringTest = encodeURIObject({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| console.log((new Error('STACK TRACE')).stack); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // right-click any element and choose copy xpath, it will look something like this: | |
| //*[@id="list-results"]/div[2]/div[1]/div/ol/li[5]/div/a | |
| var MY_XPATH = '//*[@id="list-results"]/div[2]/div[1]/div/ol/li[5]/div/a' | |
| // then do this: | |
| $($x(MY_XPATH)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getURLParameter(name) { | |
| return decodeURI( | |
| (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1] | |
| ); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| svc = function allServices(mod, r) { | |
| var inj = angular.element(document).injector().get; | |
| if (!r) r = {}; | |
| angular.forEach(angular.module(mod).requires, function(m) {allServices(m,r)}); | |
| angular.forEach(angular.module(mod)._invokeQueue, function(a) { | |
| try { r[a[2][0]] = inj(a[2][0]); } catch (e) {} | |
| }); | |
| return r; | |
| }(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Track a function attached to an object. | |
| * For example to track: myObject.myFunc() | |
| * trackFn(myObject, 'myFunc'); | |
| * | |
| * You can also track multiple functions at once: | |
| * trackFn(myObject, ['myFunc1','myFunc2','myFunc3']); | |
| * | |
| * optionally set st=true to get a stack trace | |
| * optionally you can supply a msg argument |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function handlePathChange() { | |
| actionCreator.handlePathChange({newPath:location.pathname + location.search}); | |
| } | |
| // setup event listener for back/forward buttons | |
| var eventInfo = window.addEventListener ? ['addEventListener', ''] : ['attachEvent', 'on']; | |
| window[eventInfo[0]](eventInfo[1] + 'popstate', handlePathChange, false); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // ui-router | |
| // | |
| $stateProvider.state('person', { | |
| url: '/person/{personId}', | |
| resolve: ($stateParams, AppObject) => { | |
| return AppObject.getPerson( $stateParams.personId ) | |
| }, | |
| controller() { /* ... */ } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Transit = require('transit-js'), | |
| Imm = require('immutable'); | |
| // gil: It's possible that the following reader/writer configuration is incomplete. | |
| // This is a modified version of: | |
| // https://gist.github.com/Tvaroh/52efbe8f4541ca537908 | |
| // | |
| // ... the original version of this utilized built-in JS (ES6?) types for | |
| // better efficiency+speed. However, it didn't work with nested Map + OrderedMap. | |
| // Improved efficiency+speed can be achieved by re-implementing with some native types. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Transit = require('transit-js'), | |
| Imm = require('immutable'); | |
| // gil: It's possible that the following reader/writer configuration is incomplete. | |
| // This is a modified version of: | |
| // https://gist.github.com/Tvaroh/52efbe8f4541ca537908 | |
| var reader = Transit.reader('json', { | |
| mapBuilder: { | |
| init: function () { return {}; }, |
OlderNewer