When debugging legacy code that is thousand of lines long, I found myself having the issue of trying to know what's the program is doing in very specific parts, so I've been trying to write my own developer tool extension that does what I need specifically; basically I need something that give me access to this or similar (example):
chrome.developer.v8.onFunctionCall = function(context, fn, arguments){
log(context.process);
log(context.id);
log(context.declaration.url);
log(fn.name);
log(arguments);
}
Basically I need something that can do it similarly, it doesn't have to be exactly that; I haven't found anything like it in chrome extensions developer documentation.
Related
I have a system that automatically creates and saves documents as html. For further storage they ought to be pdfs though.
I want to avoid having to do it manually so my preferred solution would be a small executable that I can call via command line, feed it with a source and output path (and ideally further parameters) and then let it do its magic. Something in concept like this:
exampleConverter.exe "C:\source\document1.html" "C:\convertedPDFs\document1.pdf"
No UI whatsoever, no human input, no popping up and closing console.
I looked through several options, but common problems I encountered were
the software not being free for commercial use
It just being a library of code, not a ready-to-go executable / code-base you just need to compile into one
The tool needing to get installed instead of being 'portable'
I'd like to avoid having to implement any modern libraries myself, partially for simple time concearns, partially because internally our code runs in a less than modern IE & VBS context so I for see compatibility problems.
Simply triggering a precompiled executable through a generic command line inerface that I can trigger from vbs seems like the perfect solution here.
Your Windows OS program code is almost there, why not reverse input and output (makes the task easier later), with a switch or two. you can embellish that with your for /? loop to run through the current working folder, just like any other program.
Your pseudo code
exampleConverter.exe --print-to-pdf="C:\convertedPDFs\document1.pdf" --headless "C:\source\document1.html"
Working Windows native code
"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" --print-to-pdf="%CD%\out\document1.pdf" --headless "%CD%\in\document1.html"
Other options are available
learn.microsoft.com suggest this working snippet to run edge with parameters
wscript vbsEdge.vbs
Dim shell
Set shell = WScript.CreateObject("WScript.Shell")
shell.Run "msedge https://www.google.com --hide-scrollbars --content-shell-hide-toolbar"
So just combine the program methods. However, you need to sort out your own arguments.
For greater control then you need to step-up to heavier custom isations https://blogs.windows.com/msedgedev/2015/07/23/bringing-automated-testing-to-microsoft-edge-through-webdriver/ etc.
I installed "Live Templates for Angular" plugin in PhpStorm. I think something is wrong with suggestion (triggered with Ctrl + Space). I have to write whole snippet a-component to get to right suggestion.
Can I improve it somehow in settings?
Here is a gif:
It's because the template name (abbreviation) has a dash - in it ... and when completing IDE treats a and component as separate parts until whole match is found (in case you were doing some subtraction operation with two variables). At very least that's my understanding of this behaviour based on my own usage experience.
You may just change the abbreviation and remove - from there and it will be much better recognized as valid completion item. But that may not be ideal in long run (potentially may have issues when plugin will be updated with new templates etc.)
To bypass it ... just use Live Template specific completion where only Live Templates will be listed. For that invoke shortcut assigned to Code | Insert Live Template... action (Ctrl + J on Windows using Default keymap) at any time when you're typing your Live Template abbreviation.
Please make sure the applicable context yet.
Apply to the specified type of file, or check everywhere.
Like below:
this is one heck of a confusing question to ask so here it goes. Firstly, I'm not asking you to write me any code I just need help going in the right direction for what I'm trying to achieve here. Basically the task is this, I want to scan a select area of a web page's source code for changes and if something does change, I want to report it somewhere (like a console or something). However, I do not want just a notification of change, I also want what the change is/was. I've been looking into things like jsoup but I am still struggling to even find out what this is called.
Any pointers would be insanely appreciated. Thanks, Optimistic.
Here are some steps assuming this is from a node.js project:
Get the URL for the specific script file you're looking for a change in.
Using the request() module, fetch that URL.
Break the data up into lines (probably using .split()).
Find the specific line you are looking for either by counting line numbers of by searching for some representative text in that line.
Using some sort of search in that line (perhaps a regex), find the current value of the exact item in that line you are looking for.
Save the current value.
Then, at some future time, repeat this whole process and compare what you find to the previous value.
If this is being done from a browser instead of node.js, then use an Ajax call to retrieve the file. If the file is on another domain from your web page and that domain does not permit cross-origin requests, then you cannot solve this problem in an automated fashion from a browser in your own web page.
Here is how I would do it with Jsoup:
Document doc = Jsoup.connect(url).get();
String scriptCssQuery = "script"; // Tune this CSS query to find THE script you need.
Element script = doc.select(scriptCssQuery).first();
if (script != null) {
String scriptLines = script.html();
// Store the changing line somewhere and compare it to its previous value...
}
I'm relatively new to batch commands and have been learning steadily. My problem is like this:
I've understood how to kill processes using batch commands using many different methods. However, I've been unable to figure out how to close a single tab in, preferably, chrome.
Any thoughts would be greatly appreciated!
Thanks!
So, I suppose I should state my exact problem.
I'm using notepad++ as my LaTeX compiler and sending the final pdf to chrome. The reason: I usually have ~20 tabs open related to the project I'm working on and it just makes my work much easier to split my screen between notepad++ and chrome.
My current batch file compiles the LaTeX code and sends the compiled document to chrome as a new tab. For obvious reasons, i don't want to close a tab each time I compile, so I thought that closing the current tab at the same time during compiling would solve my problem. But, I just can't find a way to get my batch file to only close the tab with my compiled pdf.
Thanks in advance!
check all running chrome instances/tabs with :
wmic process where "caption='chrome.exe'" get
and see processes properties.Probably the best indicator that you can rely on in this case is CreationDate (other properties are basically the same for all chrome instances) - it always comes in format YYYYMMDDHHmmss.ms and is easy for string comparison.But you'll have to know the time when it was started.
I have always thought that replacing the normal windows desktop icons with an "active desktop" html page which can launch my programs, as well as open directories and files through links. This would be a really cool way to customize one's desktop.
Using the "file://" protocal was my first approach but this does not work correctly. In another SO Post I found this link but its a little over my head. Is this the correct approach?
I can't imagine that I am the first one to consider this; it seems like a good idea (no?). What do you all think?
I like the idea of active desktop for a desktop customization. What you can do is register your own schema
Add a Registry entry.
Here is the first example I worked with.
Add This to a .reg file and Import into the registry.
Change "myschema" and the location of the executable to match your own needs
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\myschema]
#="URL:My Schema Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\myschema\DefaultIcon]
#="C:\\Program Files\\MySchemaProgram\\MySchema.exe,1"
[HKEY_CLASSES_ROOT\myschema\shell]
[HKEY_CLASSES_ROOT\myschema\shell\open]
[HKEY_CLASSES_ROOT\myschema\shell\open\command]
#="\"C:\\Program Files\\MySchemaProgram\\MySchema.exe\" \"%1\""
Now if you create a hyperlink
<a href="myschema://Whatever+i+want" >Click Here</a>
Your computer will open your MySchema Application with the href in the command line.
just be mindful because Ervironment.CommandLine will be UTF Decoded therefore
//This Link
Click Here
//Will Result in This Command Line Execution.
"C:\Program Files\MySchemaProgram\MySchema.exe" myschema://Something Here
You can also use this schema in the ShellExecute commands as well as the Run Dialog.
Here is the example program I used to get started with. You should be able to get the idea pretty quick
using System;
using System.Collections.Generic;
using System.Text;
namespace Alert
{
class Program
{
static string ProcessInput(string s)
{
// TODO Verify and validate the input
// string as appropriate for your application.
return s;
}
static void Main(string[] args)
{
Console.WriteLine("Alert.exe invoked with the following parameters.\r\n");
Console.WriteLine("Raw command-line: \n\t" + Environment.CommandLine);
Console.WriteLine("\n\nArguments:\n");
foreach (string s in args)
{
Console.WriteLine("\t" + ProcessInput(s));
}
Console.WriteLine("\nPress any key to continue...");
Console.ReadKey();
}
}
}
best of luck with your application. I would be eager to see it when it is complete.
EDIT: I am adding some matching strings for this as it is a cool feature and more people may want to use this technique for something they wanted to do.. These are the things i looked for it under, (unsuccessfully) Let me know if anyone thinks of any more.
custom url/uri handler
custom schema program
registry web address program
handle web link
launch app from url
I've looked into what you've asked a while back and never found anything that worked well.
Ultimately if the goal is full customization of your desktop, I think you can get a similar result by researching something like this: http://rainmeter.net/RainCMS/ and http://kaelri.deviantart.com/art/Enigma-103823591 Lifehacker has tons of links/tutorials on how to get it all running. I was able to get a desktop running that far exceeded my goals with using HTML on the desktop.
One way I got some really interesting results (though I haven't tried it for years and can't confirm right now that it still works on a modern OS and modern flash player) was to use an active desktop page running a flash swf file that contained a user interface I had created and (at the time I was using it) could launch programs from within the swf.
I ran a setup in a cyber cafe where each desktop was controlled via active desktop running a flash app. Launching and shutdown operations were handled with a mini webserver written in python. The OS was XP.
My experience was that Active Desktop is unreliable. It leaks memory terribly and regularly crashes. They might have fixed it in later versions but since hardly anyway uses it I doubt much effort has gone into fixing its obvious flakiness.