Powershell GUI displaying text file - forms

I have an app I developed and made a GUI for. In one of the directories I have a log.txt file.
I have a strip menu option meant to display the log file to the user. I'm wondering what would be the best method for displaying this log file?
Right now I'm just using
notepad log.txt
Which technically works but doesn't seem to be the most efficient or professional way.
I'm guessing it is probably just opening another form with a large read only text box but on the off chance someone has something that works even better I'll appreciate the suggestion.
Info displayed in log is:
Version
Description
Date

Related

Running Powershell Script as Scheduled task changes my document conversion. Why?

I have a script that is converting .doc files to .pdf. This is probably a somewhat different process than just your average document conversion process and i'll explain why.
I have document files that use a font family called "Myriad Pro". This has caused an extreme amount of issues but can't be changed unfortunately. The only way to convert this doc to PDF and have the PDF keep the text as SELECTABLE text not a bitmap image AND keep the font is to print as pdf. I ended up selecting a program called Bullzip which acts as pdf printer instead of using the Microsoft PDF printer. I had to do this because bullzip allows you to suppress almost every notification including the save as prompt. That was the main problem with Microsoft PDF printer.
All that works perfectly..When I run in the powershell ISE. Here's the kicker. If i set this as a scheduled task and run with the option selected "Run whether the user is logged in or not". This script runs with the default font. Therein lies my problem. Why is this happening? I can't understand this for the life of me. If I run this as a scheduled task with the option selected "Run only when the user is logged in". Everything works perfectly..
This is a very rare problem to have so I understand not a lot of people have experienced, but if anyone has please help.

Is there any way, any way at all, a Word document could become a PNG? (Probable case of cheating)

I think a student of mine renamed a PNG a Word document and intentionally submitted a corrupted file to buy more time (or something) on an assignment. The student denies everything and claims it was a computer malfunction. Before I submit an honor code violation I want to be sure that there's no explanation that does not involve cheating that I'm somehow overlooking.
Basically, I'm a TA and a student submitted a paper, let's say it was Smith.docx. When I was working on grading and went to open Smith.docx Word wouldn't open it and said that it was corrupted. I eventually had the idea of opening it in a text editor and there it was a massive jumbled file of all sorts of odd characters (total file size: 180kb for what was supposed to be a 5 page paper).
I noticed, though, that the first few characters of the file were:
‰PNG
I renamed the file Smith.png and it opened. Bizarrely, it was an image of the first page of a Word document. More specifically, it looks like a screenshot of a Word doc cropped so as to show just the page. What makes it seem like a screenshot is that the cursor thingy (the vertical bar marking where you're typing) shows up next to the title.
An additional interesting bit of data is that if I scroll further down in the file (opened in notepad) I come to this:
XML:com.adobe.xmp <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 5.4.0">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about=""
xmlns:exif="http://ns.adobe.com/exif/1.0/">
<exif:PixelXDimension>996</exif:PixelXDimension>
<exif:PixelYDimension>1286</exif:PixelYDimension>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
I'm not sure what all that means but 1286x996 are the dimensions of the png image. The rest suggests to me that the file was created in some Adobe program but I'm not sure if that's right and how to figure out more about that.
So, my actual question: Is there any conceivable explanation of any kind for how I would come to have a file called Smith.docx that is a perfectly functioning png of what sure looks like a screenshot of the first page of a Word document other than that the student did it on purpose? The student claimed that their computer was "corrupting" files and that they had to take it into the Apple for service. I find this incredibly implausible (student has also not provided the receipt for this, which I requested).
Additionally, other than the case I laid out here, is there any positive evidence for my theory (that it was a straightforward case of cheating) that I can present to strengthen my case? eg, is the data from the file that I posted above a smoking gun that it was created in an Adobe program or is there any conceivable way that could come out of a Word document or other sort of corrupted file?
Also, is there anything else I can look for in the PNG file that would be a smoking gun?
Thanks in advance for any help you might be able to offer!
just rename the file with .png at the end instead of .docx and if it was a png then it should open just fine as a png
The key is that you see the cursor in the screenshot, there is no way Word would export (somehow) a docx file as a png AND draw the cursor for typing. Also, any tool that could do that would save the file as png not docx, only the user could deliberately change the file extension.
Also, does the screenshot show an empty document? or it looks like the final document your student delivered at the end?
Short answer:
The student is lying and is in fact a cheater (in my opinion).
Also, even if they were telling the truth, it is still their responsibility to have their work done, ready, and fully functional on time. Your computer is corrupting your files? Tough cookies. No one cares. You should have done your work on another computer. In the real world, excuses don't get you anywhere and they shouldn't get you anywhere in school either.
Lastly, it is very easy to re-name an extension of another file type and claim it's corrupt and very unlikely that a computer is just creating corrupted files. If their computer would otherwise create corrupted files, I would imagine it would be nearly impossible to get the computer to boot. In other words, they probably wouldn't have been able to turn on their "corrupted" computer to create "corrupted" files in the first place.

perl excel to pdf

I'm using perl with an excel template to try to make creating invoices for clients somewhat automated. My only issue is that I'd really like to be able to convert this excel file to a PDF when I'm done, but I can't seem to find any perl modules that do anything of the sort. Anyone ever heard of something like this being done? I know it can be done somehow, since word and open office manage to do it!
Simply shell out to unoconv.
There are also Perl bindings to UNO, but last time I looked, they didn't work.
You may have to convert/flatten the Excel file first, and then figure out a way to pipe it in, but this may get you headed in the right direction http://metacpan.org/pod/PDF::Create

How to export data from Chrome developer tool?

Network analysis by Chrome when page loads
I would like to export this data to Microsoft Excel so that I will have a list of similar data when loaded at different times. Loading a page one time doesn't really tell me much especially if I want to compare pages.
if you right click on any of the rows you can export the item or the entire data set as HAR which appears to be a JSON format.
It shouldn't be terribly difficult to script up something to transform that to a csv if you really need it in excel, but if you're already scripting you might as well just use the script to ask your questions of the data.
If anyone knows how to drive the "load page, export data" part of the process from the command line I'd be quite interested in hearing how
from Chrome 76, you have Import/Export buttons.
I was trying to copy the size data measured from Chrome Network and stumbled on this post. I just found an easier way to "export" the data out to excel which is to copy the table and paste to excel.
The trick is click Control + A (select all) and once the entire table will be highlighted, paste it to Microsoft Excel. The only issue is if there are too many fields, not all rows are copied and you might have to copy and paste several times.
UPDATED: I found that copying the data only works when I turn off the filter options (the funnel-looking button above the table). – bendur
Right-click and export as HAR, then view it using Jan Odvarko's HAR Viewer
This helps in visualising the already captured HAR logs.
I came across the same problem, and found that easier way is to undock the developer tool's video to a separate window! (Using the right hand top corner toolbar button of developer tools window)
and in the new window , simply say select all and copy and paste to excel!!
In Chrome, in the Developer Tools, under Network, in the Name column, right-click and select "Save as HAR with content". Then open a new tab, go to https://toolbox.googleapps.com/apps/har_analyzer/ and open the saved HAR file.
Note that &Lt;Copy all as HAR&Gt; does not contain response body.
You can get response body via &Lt;Save as HAR with Content&Gt;, but it breaks if you have any more than a trivial amount of logs (I tried once with only 8k requests and it doesn't work.) To solve this, you can script an output yourself using _request.contentData().
When there's too many logs, even _request.contentData() and &Lt;Copy response&Gt; would fail, hopefully they would fix this problem. Until then, inspecting any more than a trivial amount of network logs cannot be properly done with Chrome Network Inspector and its best to use another tool.
You can use fiddler web debugger to import the HAR and then it is very easy from their on... Ctrl+A (select all) then Ctrl+c (copy summary) then paste in excel and have fun
I don't see an export or save as option.
I filtered out all the unwanted requests using -.css -.js -.woff then right clicked on one of the requests then Copy > Copy all as HAR
Then pasted the content into a text editor and saved it.
I had same issue for which I came here. With some trials, I figured out for copying multiple pages of chrome data as in the question I zoomed out till I got all the data in one page, that is, without scroll, with very small font size. Now copy and paste that in excel which copies all the records and in normal font.
This is good for few pages of data I think.
In more modern versions of Chrome you can just drag a .har file into the network tab of Chrome Dev Tools to load it.
To get this in excel or csv format- right click the folder and select "copy response"- paste to excel and use text to columns.
You can try use Haiphen, which is a chrome extension that allows you to analyze network traffic and what API calls a web application is making.

How can I return a text file and an error log from a webpage separately

I have a perl script which when run from the command line generates a text file of data with a specific format for use by another application. The script also prints informational warning messages on stderr. I'm writing a web front end for this. In an ideal world when the user clicks 'submit' on the associated form, a page would be displayed in the browser containing the informational messages, and simultaneously a pop-up would appear allowing the user to save the text file of data to disk. I would like this to work on browsers without javascript enabled, so I think exactly what I want is probably not possible.
Some sites I have seen deal with this kind of thing by displaying the page with the informational messages, and a link to the file to be downloaded. This would seem to mean having to store the files and sorting out some sort of security so that another user cannot download your file (not that this is a big deal for the application in question).
I'm wondering if there is a more elegant way of dealing with this? e.g Is it possible to use multipart messages to somehow achieve returning both pieces of information in one go? Is it possible to pop-up a second window with the informational messages without using javascript? Apologies if these seem like basic questions - my programming knowledge is in the domain of DNA sequence manipulation algorithms rather than web page generation..
If (and only if) the data is quick and easy to generate, do it once for error messages and a second time for download. The link or button of the error-message page would regenerate the results and prompt for download.
This is a bit of a hack since you need to consider what to do if the underlying data changes before the user hits the download link. Be careful to set the header correctly for file download vs normal webpage, eg,
if($submit) {
print header(-type=>'application/octet-stream',
-Content_disposition=>'attachment; filename=foobar.dat');
Gen_Results();
}
To be honest, I'd just use a little javascript anyway since it's a pretty safe assumption now a days. Otherwise, use a "noscript" tag for some alternative.