dompdf - PDF file corrupt when FE compressionLevel is set - compression

I have an extbase extension where I have a createPdfAction in which I create a PDF from the current view.
looks kinda like this:
$html = $this->view->render();
$dompdf->setPaper('A4', 'portrait');
$dompdf->loadHtml(utf8_decode($html));
$dompdf->render();
$dompdf->stream($this->clearString('filename.pdf');
exit;
Works great, but if i set the FE compressionLevel e.g. to 5 in the install tool - the PDF File which is created is now corrupt and can't be opened.
I even tried to turn off the compression by dompdf itself:
$dompdf->stream($this->clearString('filename.pdf',array("compress" => 0));
But that also didn't work
dompdf 0.8.0
TYPO3 8.7.1
php 7

Thanks to Jost:
Adding header('Content-Encoding: gzip') fixes the problem.

Related

Getting "unmarshal failed" when trying to create first website post in Hugo after installation

I'm following the instructions at Hugo's Quickstart guide (https://gohugo.io/getting-started/quick-start/) but I keep getting this error message when I try to create a post:
unmarshal failed: Near line 1 (last key parsed 'theme'): expected value but found '\\' instead
I've posted some lines of my code below. The error message appears at the bottom. Could anyone help point out what I am doing wrong?
C:\Users\Scott\quickstart\MyHugoBlog\themes>git init
Initialized empty Git repository in C:/Users/Scott/quickstart/MyHugoBlog/themes/.git/
C:\Users\Scott\quickstart\MyHugoBlog\themes>git submodule add https://github.com/dashdashzako/paperback.git
Cloning into 'C:/Users/Scott/quickstart/MyHugoBlog/themes/paperback'...
remote: Enumerating objects: 16, done.
remote: Counting objects: 100% (16/16), done.
remote: Compressing objects: 100% (15/15), done.
remote: Total 194 (delta 3), reused 9 (delta 1), pack-reused 178 eceiving objects: 53% (103/194)
Receiving objects: 100% (194/194), 466.30 KiB | 5.62 MiB/s, done.
Resolving deltas: 100% (93/93), done.
warning: LF will be replaced by CRLF in .gitmodules.
The file will have its original line endings in your working directory
C:\Users\Scott\quickstart\MyHugoBlog\themes>echo theme = \"paperback\" >> config.toml
C:\Users\Scott\quickstart\MyHugoBlog\themes>hugo new posts/my-first-post.md
Error: "C:\Users\Scott\quickstart\MyHugoBlog\themes\config.toml:1:1": unmarshal failed: Near line 1 (last key parsed 'theme'): expected value but found '\\' instead
It looks like you're following instructions meant for Unix-like systems on Windows. This command isn't doing what you want:
echo theme = \"paperback\" >> config.toml
Using Bash on Linux, for example, this appends
theme = "paperback"
to your config.toml file, creating it if necessary. That's what Hugo expects to find in the file.
However, using cmd.exe on Windows I get the backslashes included:
theme = \"paperback\"
And using PowerShell, I get something even stranger:
theme
=
\paperback\
Neither of these looks like valid TOML to me, and both contain extraneous backslashes as referenced in your error message. I suggest you simply edit config.toml using your favourite text editor and add the expected
theme = "paperback"
line manually.
The issue on my end was that the file wasn't created as UTF-8
Delete the config.toml file and recreate it manually on your text editor, then paste the content like: theme = "ananke"
should work

Python Selenium: XPath changes the encoding of my variables

I has this code that searches through text by XPath. The problem is that the searched text may contain Latin characters like ñor í.
I encoded it and when I print it, it shows perfectly, but when I use the XPath the encoding changes, and obviously it can't be found.
The decoded var prints well:
nombre_act = "HOTEL DIEGO DE ALMAGRO SAN PEDRO DE ATACAMA"
nombre_act = nombre_act.decode("utf8")
nombre_contrato = "Campaña Cyber Day, Desayuno Incluído"
nombre_contrato = nombre_contrato.decode("utf8")
print nombre_contrato
xpath = "//select[#name='"+nombre_act+"']/option[text()='"+nombre_contrato+"']"
print xpath
hotel_sel = driver.find_element_by_xpath(xpath).click()
Your code trials were near perfect. However I feel you don't need to change through encoding/decoding unless you want to print the characters to the console as follows:
nombre_act_actual = "HOTEL DIEGO DE ALMAGRO SAN PEDRO DE ATACAMA"
#nombre_act = nombre_act_actual.encode("utf-8")
nombre_contrato_actual = "Campaña Cyber Day, Desayuno Incluído"
nombre_contrato = nombre_contrato_actual.encode("utf-8") #required as you need to print to the console
print nombre_contrato
xpath = "//select[#name='"+nombre_act_actual+"']/option[text()='"+nombre_contrato_actual+"']"
hotel_sel = driver.find_element_by_xpath(xpath).click()
However, your another issue is the incompatibility between the version of the binaries you are using as follows:
You are using chromedriver=2.41
Release Notes of chromedriver=2.41 clearly mentions the following :
Supports Chrome v67-69
You are using chrome=70.0
Release Notes of ChromeDriver v2.44 clearly mentions the following :
Supports Chrome v69-71
So there is a clear mismatch between ChromeDriver v2.41 and the Chrome Browser v70.0
Solution
Upgrade ChromeDriver to current ChromeDriver v2.44 level.
Keep Chrome version between Chrome v69-71 levels. (as per ChromeDriver v2.44 release notes)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
Execute your #Test.

weka: how to generate libsvm training parameter

I am running libsvm through weka. Its output accuracy looks good to me, so I am planning to write a svm model by myself. However, weka didn't generate any training parameter, such as number of support vector. Therefore i cannot do anything. Searching the web, i found somebody said it would generate some parameters like the following:
optimization finished, #iter = 27
nu = 0.058475864943863545
obj = -1.871013102744184, rho = -0.19357337828800944
nSV = 9, nBSV = 0 `enter code here`
Total nSV = 9
but how come i didn't see any of them? any step that i missed? please help me. Thanks a lot.
Weka writes the output you mentioned to stderr.
So if you have started weka.sh or weka.bat from a terminal (or "command window" if you are on Windows), you should see that output appear in your terminal window after clicking "classify"
If you want to have access to this information via scripts, you can
redirect the output to a file and read in that file.
Here is how to edit the startup file weka.sh / weka.bat.
Edit this line (it is probably the last line) in order to write log info to a file instead of the terminal window:
java -cp $CP -Xmx8092m weka.gui.GUIChooser 2>>/opt/weka-stable/weka.log &
You can also add a properties file to your home directory to add more fine-grained behaviour.
https://weka.wikispaces.com/Properties+file
(You probably can also access information via the Weka Java API somehow, but you did not ask for that)

python 2.7 IOError: [Errno 24] Too many open files:

At work I had the bad luck to have fix a badly written url validator script in python done by someone else. It's a really messy code, and trying to fix one of the bugs, I found some behavior that I don't understand.
The script has to process a file with around 10 thousand url's in it, it has to check each url to see if it's valid, not only in it's structure but also check if it exists (using pycurl for this). On one part of the code, this is done:
for li in lineas:
liNew = "http://" + li
parsedUrl = urlparse.urlparse(liNew)
On this case the bug was the addition of "http://" at the beginning of the line as that was being done before on the script. So I changed the code to this:
for li in lineas:
liNew = li
parsedUrl = urlparse.urlparse(liNew)
Now, with the same input file the script fails with the error:
IOError: [Errno 24] Too many open files:/path/to/file/being/written/to.txt
With liNew = "http://" + li, file descriptors don't go over the default limit of 1024, but changing that line to liNew = li will make them go over 8000, why ??
With liNew = "http://" + li, file descriptors don't go over the default limit of 1024, but changing that line to liNew = li will make them go over 8000, why ??
before: broken url - nothing gets downloaded (no files are opened)
after: correct url - urls are saved to files (there are 10K urls)
It probably doesn't make sense to download more that a few hundreds urls concurrently (bandwidth, disk). Make sure that all files (sockets, disk files) are properly disposed after the download (close() method is called in time).
Default limit (1024) is low but don't increase it unless you understand what the code does.

Playing a file from computer through browser

I have a website working locally on xampp on my computer which plays mp3 files and i want to try and get it working straight from my computer example i had it setup as the following, to access a mp3 file on the server.
mp3:"http://example.co.uk/folder/1/INSTRUMENTAL/arsonists - instrumental.mp3"
this works great and my player will play the mp3 through jplayer, what i am trying to do now is set it up to play files from my local folder.
i can access the folder with the following.
'../../../../../../Users/dave/mix tunes/New folder/1/INSTRUMENTAL/'
i am then looping through all the files with this.
if ($handle = opendir('../../../../../../Users/dave/mix tunes/New folder/1/INSTRUMENTAL/')) {
while (false !== ($entry = readdir($handle))) {
$file = "/../../../../../../Users/dave/mix tunes/New folder/1/INSTRUMENTAL/".$entry;
$playlist .= '{
title:"'.substr($tname, 0, -4).'",
mp3:"'.$file.'"
},';
}
closedir($handle);
}
so i end up with the following snippet if i view my source code.
},{
title:"Apollo Four Forty - Lost In Space (Theme)",
mp3:"/../../../../../../Users/dave/mix tunes/New folder/1/INSTRUMENTAL/Apollo Four Forty - Lost In Space (Theme).mp3"
},{
title:"arsonists - instrumental",
mp3:"/../../../../../../Users/dave/mix tunes/New folder/1/INSTRUMENTAL/arsonists - instrumental.mp3"
},{
The player obviously doesn't play the files in the player.
Can anyone help me with this.
Thanks
ok found a way to play the file in the browser.
file:///Users/dave/mix%20tunes/New%20folder/1/INSTRUMENTAL/Busta%20Rhymes%20-%20Turn%20It%20Up%20(remix)-Fire%20It%20Up%20(Instrumental).mp3
but it still wont play through jplayer???
Which browser are you using? Which solution is your jPlayer using, Flash or HTML? If Flash, then be aware:
Attempting to run jPlayer locally on your computer will generate Flash
security violations and you would need to enable the local file access
using the Flash Settings Manager.
Taken from:
http://www.jplayer.org/latest/developer-guide/#jPlayer-flash-security