Is it possible to embedd compiler inside browser - c++

I have in site topcoder.com where we can create and compile code in the browser.
is it possible to code something like that in my browser i can write code in text editor and then i have compile button over there.
Or may be the request is sent to the compiler on server gcc and then get result from there.
How can i achieve something like that

Your latter (send to server) is exactly what sites like codepad.org do. There are of course security problems with openly allowing people to execute compilers and run programs on your server.
The browser only option could include:
NaCl (native client)
Writing a compiler in JS (possible, not suggested for sanity depending on language)
Using a Java applet and writing a compiler
Ditto for Flash
Ditto for SIlverlight
ActiveX control (not suggested)

Sites like TopCoder have the compiler on a back-end server. The code pasted to the site is sent to back-end server where it is compiled and run and the results returned to the user's browser.

Yes. You can send the codes to your compiler by uploading the code to server, compile it and then send back result / console output to browser screen.
For your information, PHP can execute shell commands (which can "order" your compiler to compile the codes).

Related

Embed specific Web Browser in C++ application

my question might be crazy, I know it has to be something like COM, but I need to include and COM a specific version of Web browser in my application no matter what version of the browser the computer currently is using, say to include IE7(dll file or whatever) in the project and COM programming it as a window in C++ application to surf web pages on internet although the default browser in client machine is IE9. And deploy the compiled project with IE7 file(s) to client machines. If IE/COM won't work that way, any other browsers can do the tricks?
Many Thanks!
CanadaYong
No, you cannot "embed" a specific version of Internet Explorer in your application. But you probably don't need to: when you use the IE COM WebBrowser Control in your application, by default it runs in IE7 Compatibility mode. Later modes are only used if you explicitly set the FEATURE_BROWSER_EMULATION registry key listing your executable name.

Installing a Test Application on Amazon EC2

I want to use AWS products to build some application on it. For now, i want to test this -
1) Create a webpage hosted at AWS with a simple text box and a submit button, for checking if a number is prime.
2) Compile a C++ program on EC2 to accept a number and reply if it is prime.
Can someone list the steps involved in doing this?
(The above example mirrors simplistically the actual application that i have in mind, with a http frontend and a c++ backend)
If you use the default Linux AMI, you will gave a standard Apache installation ready to go. It sounds like the invocation style of your app is request-response, so at least to begin with, you could just use CGI to get Apache to run your app.
To achieve this, you would do something like this:
Create a static html page with a form and a submit button which passes the form data to your app via CGI
Install your app into an appropriate directory (see the Apache config for details) to run it via CGI, taking care to ensure the correct permissions are set
Have your app parse the CGI environment variables to gather the input
Perform the processing required
Generate the resulting output as an HTTP response (to get started, just use text/plain).
Please note that there are many security issues to keep in mind here, so it is very important to perform strict validation on all data supplied by the web user for escaping issues, buffer overflows and so on.
If you aren't familiar with the above, you will need to read up on HTML forms, Apache configuration and basic HTTP headers at at minimum. There are plenty of examples out there, and some great books covering the topic.
To this end, various libraries have been developed to facilitate this:
Which C++ Library for CGI Programming?
There are also many other options for interfacing your app with Apache, such as FastCGI.

How to write my own Javascript API (client-side) for a native code library (C/C++)

I must develop a Web App with HTML 5 and Javascript for client side. But i need to use the funcionalities that provides a client's native library (.dll/.so) to process some data on it´s machine with C/C++.
I like to write my own API in Javascript to access native library, like NodeJS's addons define, but those addons only are accessible from NodeJS (server-side).
Also there is a well established NPAPI but seems that Google's PPAPI wants to replace it: I could not decide on any of them.
Is there something similar to NodeJS's addons for client-side that allow me to focus only on C++, Javascript and HTML 5?
Thanks.
Not in any general sense. Addons for node.js are allowed because there is an implicit trust relationship between the author of the code and the person running it. (Indeed, they're usually the same person.) In web browsers, no such trust exists -- by browsing to a web site, you're letting whoever wrote that site run some code on your system. Since you (probably) don't trust them completely, what they can do in Javascript is restricted to a set of known safe actions. Loading DLLs is very much not in that set.
As generalhenry noted in a comment, there are some projects like emscripten to compile native code to Javascript, or Google Native Client to run sandboxed native code in the browser, but these technologies are still restricted in capabilities, and are pretty immature still. Ultimately, you will need to come to terms with the fact that code running in a browser is going to be limited.

Dojo DOH, unit tests with robot actions wont run

When try to run dijit tests from 1.7 version, popup window shows up and test will not progress any further.
Popup says:
DOH has detected that the current web page is attempting to access DOH, but belongs to a different domain than the one you agreed to let DOH automate. If you did not intend to start a new DOH test by visiting this Web page, press Cancel now and leave the Web page
Clicking OK or Cancel doesn't do anything.
Whats going on a how to fix this?
Browser is Firefox 9, java is working (at least test page say so).
It's slightly hard to tell what the problem is, as you've not said whether you're running this from a local filesystem or under a web server, or which URL you're using.
I've had various problems trying to get DOH Robot running from the local filesystem, but good success running them under a web server.
Try it under a web server (any type will do), and try visiting the URL
http://server:port/ROOTDIR/util/doh/runner.html?testModule=dijit.tests.form.module
(where http://server:port/ROOTDIR/ points to the top of your Dojo SDK directory)
That works fine for me with Dojo SDK 1.7.2; sometimes I then get the same prompt you get, but OK enables the test to continue happily.
If that doesn't work, see if you can run a test page directly without the DOH browser runner wrapped around it, e.g.
http://server:port/ROOTDIR/dijit/tests/form/robot/Button_mouse.html
That might prove easier to diagnose.

How does Apache HttpClient's support of cookies work?

Does Apache HttpClient support cookies coded in javascript in a site's html or just those sent by the server through http?
edit:
If not, how would you go about finding the javascript cookies, using wireshark or another sniffer?
You don't really give a lot of context, so it's hard to tell what sort of solution is appropriate to your problem.
If I wanted to find the JavaScript cookies sent by a site I'd probably do it from within a browser. As I mentioned in my comments above, reading the cookies set by JavaScript on the client side (in the general case) requires executing the JavaScript. Doing this "correctly" requires then entire environment that's visible to JavaScript, which is a pretty large fraction of a browser.
If a human operator is ok (eg: if this is for debugging), then you could use something like Firebug or Chrome's Developer Tools to examine the cookies. If you need something more automated, one option might be to write a browser extension.
There are other options that involve more work and/or less precision, but without knowing more about the constraints of your problem it's impossible to know which of those other options would be more appropriate.