Google visualization not working with local file - google-visualization

I'm working with a treemap, but the scale is coming out black. (related question: Google TreeMap fill value set to _ABSTRACT_RENDERER_ID_1). After reading that I was able to track down the problem to the code that google generates. It looks like the definitions are being declared correctly, but then the url to them looks like maybe doesn't work with local files. Perhaps because I'm working with a local file, see below: url(file:///D:/... )
<defs>
<linearGradient gradientUnits="userSpaceOnUse" ... id="_ABSTRACT_RENDERER_ID_2">
...
<linearGradient gradientUnits="userSpaceOnUse" ... id="_ABSTRACT_RENDERER_ID_3">
...
</defs>
...
<rect fill="url(file:///D:/.../Original.html#_ABSTRACT_RENDERER_ID_2)" ... ></rect>
<rect fill="url(file:///D:/.../Original.html#_ABSTRACT_RENDERER_ID_3)" ... ></rect></g>
I've simplified the code by replacing irrelevant bits with .... I hope that doesn't confuse anyone.
Is this a problem due to not running from a server? (edit: I set up IIS on my machine. It's confirmed, the scale renders correctly)
From what I have seen from online examples is that there is no need to specify the file.
<rect fill="url(#_ABSTRACT_RENDERER_ID_2)" ... ></rect>
<rect fill="url(#_ABSTRACT_RENDERER_ID_3)" ... ></rect></g>
Is it possible to get this working from my local file system?

Parentheses and single quotes are not permitted in the path. I.e, ( ) and '.
The other acceptable path characters do not cause a problem for rendering the treemap scale: {}`` &-,.[]^%$##!; (Those are back quotes in there)

Related

papaja: Changing font sizes and faces for code listings and R output

Based on the answer to this question, I was able to get 2-column papaja with listings wrapping (rather than overflowing column width). But the listings package turns off various features that help code listings and R output stand out relative to the main text.
A simple solution would be if I could globally change the font faces and/or sizes selectively for code and R output. Is there a way to do that in papaja? I haven't been able to figure this out from papaja or Rmarkdown documentation. Thank you!
When you use the listings package in a papaja (or bookdown) document, what is technically happening is that all code is wrapped into an lstlisting LaTeX environment that comes with its own capabilities of customizing code appearance. Hence, you don't see the syntax highlighting that you would otherwise see if you would not use the listings package. The documentation of the listings package with instructions how to style your code can be found here.
To make use of this, you can extend the YAML header of your papaja document like this:
documentclass : "apa6"
classoption : "jou"
output :
papaja::apa6_pdf:
pandoc_args: --listings
header-includes:
- \lstset{breaklines=true,language=R,basicstyle=\tiny\ttfamily,frame=trB,commentstyle=\color{darkgray}\textit}
Here, I first specify the code's language, and use a tiny monospace font. With frame, I add a frame around the code block, and with commentstyle I set comments in italic and gray.

wkhtmltopdf breaking line with negative values

I am using wkhtmltopdf on a Ubuntu server. The problem I have been facing is that negative big numbers break lines. I saw this thread: Prevent Breaking of Negative Numbers. My values are read directly from the database, and differently from this guy I don't add a hyphen.
Negative numbers:
Positive:
This is after I upgraded to version wkhtmltopdf 0.12.2.1 (with patched qt). On version 0.9.9, which I had been using I had no problem with PDF generation. I upgraded because in Django, Views which inherited the PDF class from django-wkhtmltopdf would give an error code 1, not generating PDF.
PDFs are generated through command line:
command = 'xvfb-run wkhtmltopdf --footer-right "[page]/[topage]" {s} {o}'.format(
s=html_file.name,
o=target.name
)
I tried to add --zoom 0.5 as a parameter to that command, but only made the PDF worse. Half of the text got cut out off the page and can't be read.
Try with replacing minus sign with − html entity.
I had the same issue. After much time of investigation, I discovered that you can solve the issue if you put min-width (css) in the column (td).
You must be sure that the min-width is enought for the value of td.
After that all work like a charm!
Good Look!
Just create a CSS rule, that says, the text should not wrap.
td.no-wrap {
white-space: nowrap;
}

Why doesn't this XSS attack work?

I want to inject some XSS code into a site. The source code is like this:
<span class="c_red">"aaa"</span>
The word aaa is displayed on the screen.
Then I injected some shellcode into the searchbox. The code I inputed is like this:
</span><img src=* onerror=alert(1) /><span>"
So, the result code is
<span class="c_red">"</span><img src=* onerror=alert(1) /><span>""</span>
Why can't I get the alert box on the screen?
You didn't provide enough informations about the problem, but I think it may be caused by:
The website you are trying to inject uses Str_Replace or different method to replace some characters from your code, rendering it useless.
You placed your image out of span, possibly forcing the server operator to ignore your code.
Try checking the source code of website (CTRL+U), and look if your injected code is in the source code, and if its not highlighted by red color (that means the part is not correctly typed, and will be ignored by some browsers)

How to remove comments when server returns a JSP page?

Which class of tomcat is responsible for converting .jsp file to .class file? I want to see the source code written for the conversion. My aim is to check the logic how scriptlet comments are eliminated and based on that I'll write my own code that will remove HTML comments as well (I've not decided how will I implement it).
I am sure source code should be available as it's open source.
Or is it possible to implement some kind of filter so the each time server returns a JSP page it removes the comments. I can replace all HTML comments into Scriptlet comments. But I want to ensure, if someone use html comments in future, it is not displayed. It's basically for security.
[Added]
As per the suggestion given by JB Nizet, we will be modifying build.xml file to remove comments. I have come up with this to remove HTML comments -
<target name="-trim.html.comments">
<echo message="Inside trim html comments" />
<fileset id="html.fileset" dir="${build.dir}" includes="**/*.jsp, **/*.html" />
<!-- HTML Comments -->
<replaceregexp replace="" flags="g" match="\<![ \r\n\t]*(--([^\-]|[\r\n]|-[^\-])*--[ \r\n\t]*)\>">
<fileset refid="html.fileset"/>
</replaceregexp>
</target>
However, I am not sure how to remove comments that starts with // or /* */. Any suggestion how can I do so? I have searched over internet but didn't get a clue.
We are using ant script for build.
[Added]
To remove single line comment that starts with // I am using below regex. But somehow it's not working. Can anyone please help me what I'm doing wrong? Thanks in advance.
<replaceregexp flags="gs" match="?:^\s*\/\/(?:.*)$" replace="">
Rather than doing it in Tomcat, use Apache directly. It supports modules which do exactly what you need. mod pagespeed is probably closest to what you want; mod deflate may be configurable to do the same thing, though it also compresses the data, which might be overkill.
As a nice side-effect, this allows you to leave your handy comments in and they'll be served to your internal users (developers) who use port 8080, while those using port 80 will see only the minified product.

Is there any performance implication in using one big <cfoutput> tag?

I'm being forced/payed to work on a Legacy ColdFusion project (I'm an usual C# programmer) and one peculiarity with CF is that they have they're own tags that are supposed to blend with HTML (bad bad decision, IMO, since it just confuses the hell out of me even with the "starts with cf rule).
Besides this, they have the # character to indicate the start of CF "territory" much alike <% in ASP.Net or $ in Spark or so many equivalents. But this only gets parsed if inside a tag.
My question is: Is there a problem with opening one tag in the begining of the file and closing it, against using only when i'm going to use the # character?
To illustrate here's some code:
<cfoutput>
Some text #SomeVar# Some text.<br />
Some Images some other things #AnotherVar#
</cfoutput>
Against:
Some text <cfoutput>#SomeVar#</cfoutput> Some text.<br/>
Some Images some other things <cfoutput>#AnotherVar#</cfoutput>
Granted, this is might seem trivial for small content but i'm talking about a whole page.
Depending on the page contents, either is fine. There may be a performance impact (minor) by putting all of your page inside the CFOUTPUT tag, because the CFML engine needs to parse and scan the contents of the tag for executable code. Outside of the CFOUTPUT tag, the CFML engine can ignore the page as static content.
If you have CSS and HTML code that uses pound signs (for example named anchors or Hex color codes), you need to escape all pound signs (by adding a second one like "##") when within a CFOUTPUT. Because of this, I generally only put the CFOUTPUT around code I specifically want the CF engine to run.
That said, the CFML engine pays a bit of a performance penalty for constantly opening and closing the CFOUTPUT. If you're looping over come content, put the CFOUTPUT around the entire loop, rather than opening and closing it in each iteration of the loop.
Also, if you're having trouble knowing what code is CFML and what isn't, you might want to get a better IDE/editor for CFML like CFEclipse. It color codes the tags and lets you see the difference between CFML and HTML tags immediately. It's open source.
One problem you might find is that cfoutput is often used to display queries and they can not be nested inside of other cfoutput tags. So this will cause a 'Invalid tag nesting configuration' error
<cfoutput>
<cfoutput query="qFriends">
<li>#qFriends.fname# #qFriends.lname#</li>
</cfoutput>
</cfoutput>
It should not be a big issue but be careful using hex-valued colors, you'll need to escape those with an extra #. If it was me, I would try to break down those huge chunks of content into smaller pieces. Let HTML, JS, Flash and CSS do their jobs and use CF for the server side.
If you want to put cfoutput at the beginning and end of the page, you have to use double sign ## for colors value.