I am running a reactjs app with gulp/webpack and tried this:
https://github.com/yahoo/strip-loader.
However it does not work( throws errors in my reactjs code). How to get it working or what is another solution?
EDIT
I added this to the loaders section of the webpack.config:
new webpack.optimize.UglifyJsPlugin({
drop_debug: true
})
I have installed the plugin with npm but it does not filter the debugger statements from my reactjs code?
You can use UglifyJsPlugin() and pass the drop_debugger: true property.
To utilize this property you need to pass it to the compress property inside of the options argument.
new webpack.optimize.UglifyJsPlugin(
compressor: {
drop_debugger: true
}
);
This is an UglifyJS specific property and webpack can pass those directly through compress. Ironically looking at the source of the plugin it can also take the property compressor as an alt property.
you can use strip-loader plugin in webpack.
var WebpackStripLoader = require('strip-loader');
WebpackStripLoader.loader('console.log', 'console.error', 'debugger')
Is it possible to replace HTML, JS and CSS files with Tampermonkey?
These files would be hosted on a server and would just replace the files I want like the index.html, a JS files and the main styles CSS.
I could only find how to replace functions of a JS files but not how to replace a file...
This is the only thing i found: (but it's not working)
// ==UserScript==
// #name New Userscript
// #namespace http://tampermonkey.net/
// #version 0.1
// #description try to take over the world!
// #author You
// #match http://xxx.xx/
// #grant none
// ==/UserScript==
for (var i = document.styleSheets.length - 1; i >= 0; i--) {
document.styleSheets[i].disabled = true;
}
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'http://xx.com/xx/x/x.x.x/xxxx.css';
document.getElementsByTagName("head")[0].appendChild(link);
edit: this works for the css file...but the index.html is not linking to it...
Maybe its not possible :)
Thanks for any help.
(http://www.htmlgoodies.com/beyond/javascript/javascript-dynamic-document-creation-in-new-windows.html)
Try looking at the link and check out (in order) the topics "Cross-Writing Variables" and "Cross-Window HTML." If you do that, you'll understand more about what tampermonkey is doing within the script snippet you're using above and also you should be able to see how to set your existing html document to the default html document that loads.
One side note, there's better ways to perform this process if you have access to install serving languages or frameworks to your server.
If you are using Chromium with extension support check out Resource Override. It does what you want. JS, CSS, HTML, also Modifying Response headers. Can redirected to another URL whether it's remote or localhost, or store the code directly in the plugin.
I use html2pdf, which is based on TCPDF, in CakePhp to render Views in PDF.
However, sometimes the generation hangs, I mean the browser freezes and never receives data.
There is a way to debug such a behavior? In apache logs I do not see any kind of error...
$this->set(compact('quotation','company','user'));
$view = new View(null, false);
$view->set(compact('quotation','company','user'));
$view->viewPath = 'Quotations';
$view->layout = 'preventivo';
if ($quotation['Quotation']['quotation_type'] == SERVICE)
{
$content = $view->render('print_s_template');
$this->set(compact('content'));
$this->response->type('pdf');
$this->render('print');
the print.ctp has
App::import('Vendor', 'HTML2PDF', array('file' => 'html2pdf'.DS.'html2pdf.class.php'));
$html2pdf = new HTML2PDF('P','A4','it');
$html2pdf->WriteHTML($content);
$html2pdf->Output('exemple.pdf');
and the html is in print_s_template.ctp.
I found a solution myself. The problem is that I forgot to pass some variables to the View $view. And I suppose cake throw an error which, next, html2pdf cannot "render".
So: double check that all the variables in the view do exist!
If one must load and parse an XML resource from a user/PW-protected URL you cannot just use an MSXML DOM.Load() as far as I can tell. There is no place to specify the credentials.
Yet if you use XMLHTTPRequest to obtain and parse the resource into a DOM (via its .responseXML property) you have nowhere to specify a value for the .resolveExternals property.
This more or less works out when you use MSXML 3, 4, (or even 5) where it defaults to True, however in MSXML 6 it defaults to False:
resolveExternals Property:
In MSXML 3.0, MSXML 4.0, and MSXML 5.0 the default resolveExternals
value is True. In MSXML 6.0, the default setting is False.
If this property is set to False, no external includes and imports
will be resolved.
Is there a way around this that I am not seeing? Normally I need the externals resolved, especially when dealing with XSDs or WSDLs.
Or am I fooling myself, and perhaps .resolveExternals never applies when using XMLHTTPRequest (only DOM.Load() calls)?
Have you tried something like this?
xmlhttp.responseXML.resolveExternals = true;
xmlhttp.responseXML.setProperty("ProhibitDTD", false);
The only thing is the solution may only work with MSXML XMLHTTP ActiveX object.
Edit: here is a concrete sample with IE9:
var xmlhttp = new ActiveXObject("MSXML2.XMLHTTP.6.0");
// var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "sample.xml", false);
xmlhttp.responseXML.async = false;
xmlhttp.responseXML.resolveExternals = true;
xmlhttp.responseXML.validateOnParse = false;
xmlhttp.responseXML.setProperty("ProhibitDTD", false);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readystate == 4 && xmlhttp.status == 200) {
alert(xmlhttp.responseXML.xml);
}
}
xmlhttp.send();
sample.xml
<!DOCTYPE data SYSTEM "sample.dtd"><data>&ent;</data>
sample.dtd
<!ENTITY ent "Hello world!">
If you run the above cod with IE9, you'll successfully get the entity resolved. However, if you switch to the commented out XMLHttpRequest, you will fail.
PS: I thought you were talking about scripting inside IE, and there is a Trident native component called XMLHttpRequest which is quite different from XmlHttp ActiveX component. However, if you are referring to IXMLHttpRequest COM interface residing in MSXML6.DLL, you can translate the above code into C++ with ease.
Using Ext, default Ext.Ajax add to GET-request _dc parameter. For example
GET /ConnViewProcessing/?_dc=1263286227619
How to remove this parameter?
PS: it's necessary to manually cache response to ETag and If-None-Match.
Set disableCaching option to false:
Ext.Ajax.disableCaching = false;
Using Ext JS 4.1, and after adding the following code to app.js, the _dc parameter disappears:
// Disable _dc parameter
Ext.Loader.setConfig({
disableCaching: false
});
// My App
Ext.application({
The proper way to accomplish that with Sencha Cmd 6.x is to set a (global) switch in app.json (because all of those hacks and overrides might interfere unnecessarily with the functionality):
"loader": {
"cache": true
},
Then run sencha app refresh, in order to update the application's bootstrap.json.
Alternatively, one can configure Ext.Loader (at run-time):
Ext.Loader.setConfig({disableCaching: false});
When scrolling upwards and reading the actual question, concerning Ext.Ajax (per request):
Ext.Ajax.request({url: '/ConnViewProcessing', disableCaching: false});
The result: no more _dc parameters on scripted requests.
#see Sencha Cmd 6.x - The Microloader.
Note that the use of Ext.Loader has changed in ExtJS 5.
In ExtJS 5, caching can be disabled:
temporarily by adding "?cache" to the end of the URL
by setting a cookie called 'ext-cache' with the value of 1
or by editing the file .sencha/app/Boot.js and setting the '_config.disableCaching' property to be true (overwriting the dynamic lookup).
I am using ExtJS 4.2, but this should work for Ext JS 4.1 and on. In the proxy there is a property called noCache you should set this to false.
Ext4.define('Server',{
extend: 'Ext4.data.Model',
fields: [
{name: 'id'},
{name: 'key'},
{name: 'value'}
],
proxy: {
type: 'rest',
url : 'yaddayaddayadda',
noCache: false,
reader : {
type: 'json'
}
}
});
The reason my code says Ext4. is because I am using the sandbox mode as I move old Ext JS 3x code into 4.2
This should work with extjs 4.0.7:
Ext.Loader.config.disableCaching = false;
Setting the flag disableCaching to false (double negation - yay!) on the Ext.data.Connection should do the trick.
For more, look at the disableCaching-documentation.
(Please note that quite a few classes in Ext seem to have the option available, so you might have to muck around a bit.)
For those that want to set "disableCaching: false" in Sencha Architect 3+, here is how..:
In the project inspector window, select the top node,
"Application"
Then in the "Config" window below that where you
set the object properties, etc, select "Loader Config".. in my case
I had to click the "+" to the right of this as I hadn't set any
items yet. This will create a new "LoaderXX" object in the "Project
Inspector" window above; Loader25 in my case.
Now either select the new object in the
"Project Inspector" window, or click on the right arrow beside the
new "LoaderXX" (Loader25 in my case). This will take you to the
properties for the object.
Untick the "disableCaching" item.
Save the project and refresh the browser window, and enjoy persistent breakpoints, etc, etc in Chrome.
The only way I was able to disable _dc in ExtJS 4.2.x globally on my project:
Ext.define('Ext.data.Connection', {override:'Ext.data.Connection', disableCaching:false });
Ext.define('Ext.data.proxy.Server', {override:'Ext.data.proxy.Server', noCache:false });
Ext.define('Ext.data.JsonP', {override:'Ext.data.JsonP', disableCaching:false });
This is ugly, but any other ideas?
This is how I did this:
Ext.Ajax.request({
url: url,
disableCaching:false
});
I decided that I wanted the cache to be destroyed client side, but server side I was using my own caching mechanism (PHP's APC).
I left the _dc in the Ext ajax request, but then removed it from the REQUEST_URI, and then use the REQUEST_URI as the basis for the cache key
I found this useful: Regular expression to remove one parameter from query string
If you develop under Sencha CMD you can do like this
http://localhost:1841/?disableCacheBuster
or just
http://localhost:1841/?cache
For all who are looking for a way to disable it in a newer version:
proxy: {
type: 'ajax',
noCace: false
}
I use Ext.NET on top of Ext.JS. It adds some more voodoo to Ext.js...
I tried to get rid of the dc= parameter, but all mentioned configurations did not work. So, this is my uber-effective, uber-dirty solution:
Ext.Date.now = function () { return ""; }
As far as I can see, Ext.Date.now() is only used for the caching logic. So it should be relativity save.