How to detect IE11?

IE11 no longer reports as MSIE, according to this list of changes it’s intentional to avoid mis-detection. What you can do if you really want to know it’s IE is to detect the Trident/ string in the user agent if navigator.appName returns Netscape, something like (the untested); function getInternetExplorerVersion() { var rv = -1; if … Read more

Easier way to debug a Windows service

If I want to quickly debug the service, I just drop in a Debugger.Break() in there. When that line is reached, it will drop me back to VS. Don’t forget to remove that line when you are done. UPDATE: As an alternative to #if DEBUG pragmas, you can also use Conditional(“DEBUG_SERVICE”) attribute. [Conditional(“DEBUG_SERVICE”)] private static … Read more

Showing the stack trace from a running Python application

I have module I use for situations like this – where a process will be running for a long time but gets stuck sometimes for unknown and irreproducible reasons. Its a bit hacky, and only works on unix (requires signals): import code, traceback, signal def debug(sig, frame): “””Interrupt running process, and provide a python prompt … Read more

General suggestions for debugging in R

I’d say that debugging is an art form, so there’s no clear silver bullet. There are good strategies for debugging in any language, and they apply here too (e.g. read this nice article). For instance, the first thing is to reproduce the problem…if you can’t do that, then you need to get more information (e.g. … Read more

How to quickly and conveniently disable all console.log statements in my code?

Redefine the console.log function in your script. console.log = function() {} That’s it, no more messages to console. EDIT: Expanding on Cide’s idea. A custom logger which you can use to toggle logging on/off from your code. From my Firefox console: var logger = function() { var oldConsoleLog = null; var pub = {}; pub.enableLogger … Read more

JavaScript console.log causes error: “Synchronous XMLHttpRequest on the main thread is deprecated…”

This happened to me when I was being lazy and included a script tag as part of the content that was being returned. As such: Partial HTML Content: <div> SOME CONTENT HERE </div> <script src=”https://stackoverflow.com/scripts/script.js”></script> It appears, at least in my case, that if you return HTML content like that via xhr, you will cause … Read more