Run functionality with Monaco Editor - visual-studio-code

I wanted to use the Monaco Editor for my project and I want to run the server side languages like C# or node in my Monaco editor(https://github.com/Microsoft/monaco-editor/) which is a open source editor from Microsoft.
Here are few examples for that.
https://microsoft.github.io/monaco-editor/playground.html#interacting-with-the-editor-rendering-glyphs-in-the-margin
https://dotnet.microsoft.com/languages
If you see the the above examples you can see they are running c# with run button I wanted to implement same functionality.
I know that I need to install run time for particular language like C# and I have that in my local machine but still I am not able to run it.
Any help will be highly appreciated.

What you see there is not a Monaco feature and is up to you to implement. How you do that, will depend largely on the language you're trying to run.
The first example (and jsFiddle and CodePen and many others) simply displays an iframe to show the result. That iframe loads a file with a unique name that contains the HTML, CSS and JavaScript code entered in the editor. You can confirm that this is what they're doing, using Chrome Dev Tools.
If you're going to run a language like C#, know that you will need full control of your web server. The flow will be something like this:
The user presses the Run button.
You call a web service (that you must develop), passing it the C# code and anything else needed to build a working project (like dependencies).
The web service creates the project from those inputs, invokes the C# compiler, runs the resulting executable, and finally captures the output (both stdout and stderr) into string variables. Those strings are returned by the web service.
Back in the browser, you display the output from the web service.
This is very doable, but getting it to perform well when your volumes pick up will be a special problem.

Related

How to launch vscode debug configuration from the browser?

I have a test case reporting scheme delivered in HTML that is complex in its own right and not easily ported to a VSCode extension. I would like to launch a Debug Configuration for each failing test case from the browser displaying the report. I have already been able to modify the report and have added a copy/paste widget for each test case's associated command. However I would like to do something to the effect of:
Launch a service as a VSCode extension that can handle requests
Formulate those requests in a way that can dynamically create launch configurations
It may be that I am stuck writing a Debug Adapter without the bells and whistles of interacting with the report.
That being said, if this is a solved problem or has a framework for solving with VSCode (and I realize remote execution could be a Very Bad Thing for VSCode to allow), I have not been able to find it through an existing extension.
I welcome your ideas.
This is perhaps not as open ended as it sounds...my question ultimately is: can VSCode operate as a service to be requested by web interfaces? Even if it could be done via Localhost this would be a boon. If it can be done over ssh with authentication, that would also be a bonus.
One way of getting VSCode to handle requests would be by invoking a vscode:// URI. This requires your extension to implement a URI handler. After the mandatory parts of the URI, you could have arbitrary data with whatever information you need.
Something that might or might not be an issue for your use case is that invoking such a URI triggers a popup in VSCode / doesn't work silently:
For dynamically creating launch configurations, you can use the vscode.debug.startDebugging() API.

Get the real-time web design preview from the browser

Assume that I have two monitors assigned to my pc. Now I want to get the preview of a web site while coding it. Is there anyway to do this?
eg:- Do the coding from sublime text from a one monitor and the meantime watch the output from the Firefox web browser.
I have used live.js for this more than once. It can work either as a bookmarklet or embedded on your page, and it works in any browser as it's not an extension. Also requires no other software to work.
The downside is it that it will flood your developer tools with HEAD requests every second or so to determine when to reload things. That's the cost of not having to install external software.
You can use the LiveReload plugin for SublimeText. It listens for changes to your code files and updates them in the browser in real time.
Also, do not forget to add the respective browser extension. That should save you from adding any scripts into your page.
You could use yeoman ( with Grunt or Gulp depends on which generator you want to use ).

Packaging a GWT app to run completely offline NOT installed via a "marketplace"

Theres a few questions similar to this, so I'll try to be clear as possible.
We have an existing, fairly large and complex, GWT webgame I have been asked to make work offline. It has to be offline in pretty much the strictest sense.
Imagine we have been told to make it work off a CD Rom.
So installation is allowed, but we cant expect the users to go to a Chrome/Firefox store and install it from there. It would need to be off the disc.
Likewise, altering of the browsers start-up flags would be unreasonable to expect of users.
Ideally, it would be nice if they just clicked a HTML file for the start page and it opened in their browsers of choice.
We successfully got it working this way in Firefox by adding;
"<add-linker name='xsiframe' />"
To our gwt.xml settings. This seems to solve any security issues FF has with local file access.
However, this does not solve the problem for Chrome.
The main game starts up, but various file requests are blocked due to security issues like these;
XMLHttpRequest cannot load file:///E:/Game%20projects/[Thorn]%20Game/ThornGame/text/messages_en.properties. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.MyApplication-0.js:34053 com_google_gwt_http_client_RequestBuilder_$doSend__Lcom_google_gwt_http_client_RequestBuilder_2Ljava_lang_String_2Lcom_google_gwt_http_client_RequestCallback_2Lcom_google_gwt_http_client_Request_2 MyApplication-0.js:34053
Now I was aware same origin policy issues might popup as during development we often tested locally using flags in chrome to bi-pass them.
Thing is...now I dont know how to get around them when we cant use startup flags.
Obviously in the example given its just the .properties file GWT uses to get some language related text. I could dump that inline in one way or another.
However, its only one of many,many,many files being blocked.
The whole game was made to run off *.txt game scripts on the sever - to allow easy updating by non-coders. Really the actual GWT code is just an "engine" and all the XMLHttpRequested files supply the actual "game".
These files are of various types; csv, txt, ntlist, jam.
The last two being custom extensions for what are really just txt files.
All these files are blocked by chromes security. It seems from what I can make out only images are allowed to be accessed locally.
Having all these files compiled in would just be impossible, as they are not fixed in number (ie, one central .txt file determains various scene .txt files which in turn determain various object files and directory's...).
Putting all this into a bundle would be nightmare to create and maintain.
So in essence I need some way to supply a offline version of a GWT project that can access a large number of various files in its subdirectories without security issues.
So far all I can think of is;
A) Theres something I can tell chrome via html or gwt that allows these files to be read in Chrome like FF can. (I suspect this isn't possible).
An alternative to XMLHttpRequest maybe?
B) I need to somehow package a game+a webbrowser in a executable package that has permission to access files in its directory's. (http://www.appcelerator.com/titanium ? ?? ).
C) I need to package and have the user run a full webserver that can then deliver all these files in a XMLHttp accessible way.
D) Bit of a funny one...we cant tell the user to add flags to browser start up...but Maybe I could write a game installer which just detects if they have Chrome or Firefox. It then opens up the games html in their browser with the correct flags for them? This would open up security issues if they browse elsewhere with that instance though, so Id presumably need other flags to disable the url bar if that's possible.
I am happy to make various changes to our code to achieve any of this - but as mentioned above theres no way to determain all the files needing to be accessed at compile time.
And finally, of course, it all has to be as easy as possible for the end user.
Ideally just clicking a html file, or installing something no more complex then a standard windows program.
Thanks for reading this rather long explanation, any pointers and ideas would be very welcome. I especially will appreciate multiple different options or feedback from anyone that's done this.
========================================
I accepted the suggestion to use Chromiumembedded below.
This works and does what I need (and much much more)
To help others that might want to use it, I specifically made two critical changes to the example project;
Because CEF needs a absolute path to the web apps local html, I wrote a c++ function to get the directory the .exe was launched from. This was a platform specific implementation, so if supporting a few OS's (which CEF does) be sure to write dedicated code for each.
Because my webapp will make use of local files, I enabled the Chrome flag for this by changing the browser settings;
browser_settings.file_access_from_file_urls = STATE_ENABLED;
These two changes were enough to get my app working, but it is obviously the bare minimum to make a application. Hopefully my finding will help others.
I'd suggest going the wrapper route. That is, provide a minimal browser implementation that opens your files directly. Options are Chromium Embedded[1]. If the nature of the application absolutely requires the files to be served as non-file urls then bundle a minimal webserver, have the on-disk executable start the server and open the bundled browser with whatever startup arguments you want.
[1] https://bitbucket.org/chromiumembedded/cef

Want to execute single step in selenium web driver

I am using selenium webdriver to do automation of web application.(I am using eclipse)
In my test, I have written the code to login the page by credential, then click some links and go to a particular page.Now on that page i am filling fields through drop down and all and its not working.
So My question is if i changing my code to work with drop down,then to test this again i need to run test case from starting.Means again it it will login page will load and go through various links and then reach to that page.
So can not directly execute that steps only like we do in selenium IDE???
Again and again executing from starting is really screwing my time...??
Is there any way/shortcut?? Please suggest me.
Thanks
Selenium IDE is in-browser, it's then normal you can run at any step. But if your cookies have expired, you'll have to reauthent. It's not a Selenium problem, it's how websites work.
In your tests, you'll always have to start from scratch if your cases involve athent process, unless you manage to get a fine control over your cookies.
You can always make a quick http call to the website you want to connect to with HTTPClient for example, just to get the cookie back, then use it in webdriver with something like
driver.manage().addCookie(new Cookie("foo", "bar", "www.domain.com", "/", null));
then go to the page you need. Notice that this solution solves the Authent problem only, and does not control the state of the tested web-application (data previously posted, etc...).
At our company, we make an extensive use of selenium, and have a lot of tests relying on it, it's therefore a problem we know something about and we are aware of the frustation it can cause.
We use a pretty different solution to get a productivity boost on tests.
In fact, we're using a Groovy Shell-based solution which allows us to go back and forth while developping the tests and keep our browsers open. Groovy is a JVM scripting language that is really easy for a Java dev (almost all Java code is valid Groovy code) and it's really dynamic.
So you can download groovy, run groovy shell (groovysh is the command), then line by line you can launch and interact with the browser xhile your written code is saved to a buffer. When you've done with your test, export the code and put it in Eclipse. It's faster than restarting every time from scratch. Magic lines for starting with selenium are
groovy.grape.Grape.grab(autoDownload: true, group : 'org.seleniumhq.selenium', module : 'selenium-firefox-driver', version : '2.37.1')
import org.openqa.selenium.*
import org.openqa.selenium.firefox.*
driver = new FirefoxDriver()
driver.get("http://my-website.com")
From this point, the browser window is always open, and you develop right in groovy (or java). It's like a selenium-ide, but in groovy, and can be integrated in your developement workflow (but there is a bit of work to do)
This example works for Firefox (as you've probably guessed ;-)) but you can adapt it as you like. We have from this constructed a bunch of tools to develop our tests quickly and iteratively. We found this to be a great savior.
In the case you described, the tests will always return to step 1, therefore, you need to execute your automation suite from the beginning.
Tip for the future, separate your test cases to shorter ones (as Alexander suggested), so you if you need, you can easily use only the cases that needed and relevant to the module you currently working on.
There is nothing different answer..runs from first step...
And my kind advice is that to use a break point in eclipse at which u r guess of failing...and run the eclipse program in debug mode vth continuously pressing F6 key.
The excecution will be slowed and display will be step by step mode which u can easily trace the exact location at which u r code is breaking...

Can I script FlexBuilder without writing an extension?

I'd like to script FlexBuilder so that I can run debug or profile without having to switch to FlexBuilder and manually clicking the button (or using the key combo). Is this possible without writing an extension?
To be more specific, this is exactly what I want to do: I want to create a TextMate command that talks to FlexBuilder and makes it run the debug target for the currently selected project. TextMate already has support for interacting with Xcode in this way, and it would be great to be able to do the same with FlexBuilder.
When compiling I use Ant and have full control over that from TextMate, what I want is to be able to launch the debugger and the profiler. The command line debugger is unusable and there is no other profiler available than the one in FlexBuilder.
Since FlexBuilder essentially is an extended version of Eclipse, any tools/scripts for doing the same in Eclipse should work for FlexBuilder aswell. I couldn't find any tools like this googling it, have you considered doing away with FlexBuilder completely, there are plenty of guides for using the mxmlc (or fcsh) compilers directly from your editor.
I do not know if there is a plugin like this for Eclipse however if not you can write one as it should be easy.
If the specific command that you want to call shows up in Windows/Preferences - General/Keys, you can create a plugin that takes commands from TextMate (I do not know what protocol TextMate uses, socket or something else) and executed the specific action that is associated with the command that also appears in preferences.