mootools - is it possible to get a useful backtrace? [closed] - mootools

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
SCRIPT16389: Unspecified error.
mootools.core.js, line 273 character 63
Mootools frequently generates errors like these that are useless in identifying the problem. Is there a way to identify how the mootools method that crashed came to be called in the first place, other than by trial-and-error? In other words, to get a backtrace, similar to PHP's debug_backtrace() function.

Yes, it is...
But not when you put your question together like this.
for starters, there are MANY versions of MooTools (major releases were 1.0, 1.11, 1.12, 1.2, 1.2.1, 1.2.2, 1.2.3, 1.2.4, 1.2.5, 1.2.6, 1.3, 1.3.1, 1.3.2, 1.4, 1.4.1, 1.4.2, 1.4.3, 1.4.4, 1.4.5 (latest stable)). then you can use the MooTools builder to create a custom version as well... nobody can say what is on line 273 of whatever minified version it is you use
next: don't know how you are used to developing and debugging but using minified production libraries is NOT the way to go. you should swap to the default non-compressed and minified version of mootools-core first, which will in turn show you a far more meaningful part of the code and offer a clue as to what you do.
next: this is an Internet Explorer specific error. you even fail to state that. it is NOT a MooTools error and if you google for SCRIPT16389: Unspecified error., you will notice all the results are normally related to jQuery, so whatever it is you are doing, it's library agnostic.
next: what are you actually doing? this error is a standard trident 'panic' response. I have seen it happen on DOM manipulation, XHR, iframe/document issues, 'unsafe' DOM changes, CORS violations, all sorts. without actually stepping through your domready hooks and disabling components and parts of components until the problem goes away, you cannot isolate anything. IE - in this state - will seldom let you trace / debug this. your only bet is (if it's IE8 or it happens in IE9) is to run the developer tools of IE9, pick IE8 standards mode and work with the un-minified files, then console.log() the variables around it, if the inspectors/watches are unavailable.
If you post more info, snippets, examples, people will be able to offer some actual help. Good luck, hope this gets you started. W/O supplying more information, this question will likely get closed as it is unanswerable and won't hold any value for future visitors.

Related

Dynamic Content Delivery Network (CDN) in HTML links

Background:
I have a web app that references many CDN's in my HTML front end. Full disclosure, I am a novice dev at best so very likely that the answer is very simple.
At the time of writing (Oct 2020), I am using, among others, the following CDN:
<link href="http://cdn.pydata.org/bokeh/release/bokeh-widgets-2.0.2.min.css">
Question:
Is there a more dynamic way to link this CDN so that I don't have to manually update the version number (2.0.2) if and when it changes?
If your question is:
How can I ask Bokeh itself for the matching CDN links that correspond to the current installed Python package version?
Then this is the simplest way:
In [1]: from bokeh.resources import CDN
In [2]: CDN.js_files
Out[2]:
['https://cdn.bokeh.org/bokeh/release/bokeh-2.2.1.min.js',
'https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.2.1.min.js',
'https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.2.1.min.js']
Note that that just lists all possible resource URLs. If you aren't using widgets or tables then you don't need those files.
Also note:
The official URL changed to cdn.bokeh.org several years ago. The "pydata" links will continue to work, but everyone should prefer the bokeh.org ones in any new code.
There are not any separate CSS files any more in recent versions of Bokeh, on the JS files.
The above assumes you are using Bokeh from Python, where the Python and JS versions need to be matched. If you are using BokehJS directly (not super common, but it happens) then you should just pick whatever version you intend to use, and update it intentionally/manually, as others have suggested.
A very similar question has been asked before on this subject here
Getting the latest version from cdnjs
and it's generally not a good idea to adopt this practice.
Always using the latest version can expose you to bugs, unwanted behaviour. If the version you are using is stable, then its probably best to stick to it.

Recursively search javascript Global Execution Context

I'd like to do this in Chrome Developer Tools, but I'd take anything at this point.
The question
If I know I am looking for a specific object, how can I search the entire JS hierarchy to find it?
The situation
In know from my time on irc://irc.freenode.net/bash that when people reduce their question to what they think they should do, they waste a lot of time.
I use Confluence Cloud and their WYSIWYG is terrible. Because it is TinyMCE, I can get a lot done by editing the DOM in the Chrome Developer Tools. I ought to be able to hack the JS object and get even more through. But, the first step is the find the TinyMCE.settings object.
If you've got a reference to the object's constructor, the queryObjects() API might be able to help you locate the object. You might need to set a breakpoint and pause the code at a point where you know that the object still exists in the heap.
Check what version of Chrome you're using at chrome://version. queryObjects() was introduced in Chrome 62, which should be hitting Stable right about now but you might not have it quite yet.

What is the best way to remove dead code from your application? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I often feel that after iterating over my code for a number of times I am left with functions or classes or other lines of code in general which made sense in the previous revision but are not very useful for the new revision. I know that a profiler can tell you what part of your code was called when you run your test cases? But how does one go about identifying what part of the code never got called to remove it so that whats left is more readable? For example, is there a quick way to know which functions in your code are not being called from anywhere and can be safely removed. It may sound like a trivial question for a small code base, but when your code base grows over the years, this becomes an important and not so trivial question.
To summarize the question, for different languages, what is the best approach to remove dead code? Are there any lanaguage agnostic solutions or strategies for this. Or does each language provide a tool for identifying dead code.
We normally program in Java or Python or Objective-C.
The term you're looking for is "code coverage" and there are various tools that will generate that information. You would have to make sure that you exercise every possible path through your code in order to be able to detect "dead code" with such a tool though, which is only possible with a really extensive set of tests.
Most compilers have some level of dead code detection, but that only detects code that cannot possibly be called, not code that will never be called due to program logic, etc..
edit:
for Python specifically: How can you find unused functions in Python code?
for Java: How to find unused/dead code in java projects, Java: Dead code elimination
for Objective-C: Xcode -- finding dead methods in a project, Cleaning up Objective-C code
For functions, try a global search on the function name, and analyze what you get. Dead code inside a function will usually be findable.
If you suspect a function of being unused, you can remove it, or comment it out, and see if what you've got still compiles.
This only works on functions that are unused because they are no longer called. Functionality that is never used because the control path through the code is no longer active is harder to find, and code analysis tools won't do well at finding it either.
You can use the code coverage report to find out the function which are not used or part of function which is never executed.
Based on the logic, you can treat them as dead code/unused code.
Popular code coverage tools that can be used:
C/C++: gcov & lcov
Python: Coverage.py
Java: JCov
Objective-C: xccov

Choosing an open source license for a standard based on XSD [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 7 years ago.
Improve this question
got a question about an open source project I'm planning to put in place (to be hosted either at Codeplex or Sourceforge).
In short, the project will consist of an XSD file to define a schema for XML files to adhere to, and some C# code to work with those XML files.
But I'm not sure what license I should give it, especially the XSD file. The project will be mostly a class library, so I'm tempted to go with LGPL, so it can be used by both free and proprietary software.
But the one thing is, I don't want the XSD file to be able to be changed, cause I'm trying to put up a standard for data-sharing of a specific problem domain, and imo there's no point in making a standard open source, or is it ?
Or should I release the XSD as a separate project ? Not sure what's the right way to go...
Thanks for any advise on the matter.
Mathieu
I think you are making a big mistake. In fact, I think that the XSD files should be released under a more liberal license.
If someone wants to create a proprietary version of HTML and fork Firefox to work with it they are only creating needless work for themselves. For the most part, it doesn't cause any problems for Mozilla or the W3C because nobody is going to care or use it. Granted, at one time, both Netscape and Microsoft tried to add proprietary HTML extensions. Microsoft eventually realized the value in browser interoperability. Netscape didn't last long enough for it to matter.
If you put a restrictive license on the schema, you will decrease the likelihood that anyone will adopt your standard. Many developers are constrained by the licenses of components they can use in their projects. What is the point of having a standard, unless it is open to all developers?
Keep in mind, and XSD file is not a standard or a schema. It is only a representation of a standard.
For example, if you have an XHTML XSD, changing the XSD does not change the XHTML schema. The XHTML schema is defined by an English document published by the W3C. The only way to change the XHTML schema is to get the W3C to publish and updated version of the document. If you change an XHMTL XSD, you have created a representation of different schema.
By putting the XSD file under a restrictive license doesn't do anything to protect your schema, it only forces someone to code from scratch a new XSD file for their proprietary extensions.
Have you considered that your standard might have flaws, or not cover certain use cases you haven't considered? If your standard can't meet all the needs of a developer they won't use it. You could promise to incorporate improvements in to the standards, but what happens if you get hit by a bus? If you are the only person who can legally change the standard it will eventually stagnate and become irrelevant.

How to highlight source code in HTML? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to highlight C/C++/Java/C# etc source codes in my website.
How can I do this?
Is it a CPU intensive job to highlight the source code?
You can either do this server-side or client-side. It's not very processor intensive, but if you do it client side (using Javascript) there will be a noticeable lag. Most client side solutions revolve around Google Code's syntax highlighting engine. This seems to be the most popular one: SyntaxHighlighter
Server-side solutions tend to be more flexible, especially in the way of defining new languages and configuring how they are highlighted (e.g. colors used). I use GeSHi, which is a PHP solution with a moderately nice plugin for Wordpress. There are also a few libraries built for Java, and even some that are based upon VIM (usually requiring a Perl module to be installed from CPAN).
In short: you have quite a few options, what are your criteria? It's hard to make a solid recommendation without knowing your requirements.
I use GeSHi ("Generic Syntax Highlighter") on pastebin.com
pastebin has high traffic, so I do cache the results of the transformation, which certainly reduces the load.
Personally, I prefer offline tools: I don't see the point of parsing the code (particularly large ones) over and over, for each served page, or even worse, on each browser (for JS libraries), because as pointed above, these libraries often lag (you often see raw source before it is formatted).
There are a number of tools to do this job, some pointed above. I just use the export feature of my favorite editor (SciTE) because it just respects the choices of color I carefully set up... :-) And it can output XML, PDF, RTF and LaTeX too.
Pygment is a good Python library to generate HTML, RTF, ANSI (terminal-style) or LaTeX code. It supports a large range of languages (C, C++, Lua, Erlang, ...) and you can even write your own output formatter.
I use google-code-prettify. It is the simplest to set up and works great with all C-style languages.
If you use jEdit, you might want to use the Code2HTML plugin.
I use SyntaxHighligher on my blog.
Just run it through a tool like: http://www.gnu.org/software/src-highlite/
If you are using PHP, you can use GeSHi to highlight many different languages. I've used it before and it works quite well. A quick googling will also uncover GeSHi plugins for wordpress and drupal.
I wouldn't consider highlighting to be CPU intensive unless you are intending to display megabytes of it all at once. And even then, the CPU load would be minimal and your main problem would be transfer speed for it all.