This file contains 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
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc | |
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/ | |
// author: Pawel Kozlowski | |
var myApp = angular.module('myApp', []); | |
//service style, probably the simplest one | |
myApp.service('helloWorldFromService', function() { | |
this.sayHello = function() { | |
return "Hello, World!" |
This file contains 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
/** | |
* Creates a hash object of all the URL query string params. | |
* | |
* @returns {{}} | |
*/ | |
function getUrlVars() { | |
var vars = {}; | |
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m, key, value) { | |
vars[key] = value; | |
}); |
This file contains 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
sudo chown -R `whoami` ~/.npm |
This file contains 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
{code:JavaScript} | |
grunt.loadNpmTasks('grunt-contrib-connect'); | |
... | |
connect: { | |
webServer: { | |
options: { | |
port: '<%= ports.webServer %>', | |
base: '<%= buildDir %>', | |
keepalive: false | |
} |
This file contains 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
//////////////////////////////////////////////////////////////////////////////// | |
// NOTE: This specific use case had leverages AngularJS and RequireJS so it's | |
// possible these had something to do with it as well, but it seems that there's | |
// an issue with breakpoints and V8: | |
// | |
// * http://mariuszprzydatek.com/2013/07/21/angularjs-karma-and-debugging-unit-tests-in-webstorm-or-intellij-idea/ | |
// * http://www.andrejkoelewijn.com/blog/2013/05/07/debugging-with-webstorm-and-karma/ | |
// * http://tommytcchan.com/blog/2013/03/18/example-how-to-set-up-debugging-with-karma-formerly-testacular-and-webstorm/ | |
//////////////////////////////////////////////////////////////////////////////// |
This file contains 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 obj1 = { | |
"foo": { | |
"dog": "000" | |
}, | |
"bar": { | |
"bear": "111" | |
}, | |
"tee": { | |
"elephant": "555" | |
} |
This file contains 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
Markdown | Less | Pretty | |
--- | --- | --- | |
*Still* | `renders` | **nicely** | |
1 | 2 | 3 |
This file contains 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
// internal function to generate a random number guid generation | |
var S4 = function() { | |
return (((1+Math.random())*0x10000)|0).toString(16).substring(1); | |
}; | |
// generates a guid for adding items to array | |
var createGUID = function () { | |
return (S4() + S4() + "-" + S4() + "-4" + S4().substr(0,3) + "-" + S4() + "-" + S4() + S4() + S4()).toLowerCase(); | |
}; |
This file contains 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
// grep {searchString} {targetFile} > {outputFile} | |
grep "loadChunk(" mysxm.log > mysxm-load-chunk.log |
This file contains 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
// I've created a simple logger (wraps console.* methods) that provides output similar to say Log4J or other robust | |
// loggers out there for the enterprise, but a huge missing piece (for me) is that you can no longer see the file | |
// reference and line number from the client object using the logger. When you use console.log() OOTB it'll spit out | |
// a clickable link to the file and line number that executed the console.log making it easy to debug; when you wrap | |
// console.log it simply spits out the logger file reference and the line number the console.log was executed, so | |
// all logging shows up as from the logger wrapper (which is technically correct)...bottom line, you lose the context | |
// from which you actually made the logging call and I'd like to get that back. | |
// Aside from blackboxing, is there another way to wrap console.log() such that it binds to the client callee | |
// and ultimately shows the correct file reference and line number of the callee (and not the log wrapper)? |
OlderNewer