I am thinking of designing a webbased frontend to a dataanalysis package. This is what I have in mind:
Data-analysis jobs are submitted to a queue.
People can login to the frontend and choose to run a job on the local machine or add a new job to the queue.
Details:
A person logs into the web-application and can either choose to run an exisiting job in the work queue on the local machine or assign a new job to the work queue
If a job is selected to be run on the local machine, the webpage queries the package installed on the local machine : "This is the job I have for you. How long would it take for you to finish this?"
2.1 The package would return a value (based on heuristics) to the webpage
2.2 The webpage can, depending on the value returned, choose to
allocate the job to the current
machine
2.3 If the job is allocated to the current machine, the backend package
goes on its way all the while
keeping the webpage updated with the
progress it is making.
A job can take from a few seconds to
a few hours to finish.
2.4 Any time the webpage can tell the package "You are taking too long -
send me what you have" or perhaps "I have something more important for you -
send me what you have".
The package can send the data it has by connecting to the webapp backend
directly at this point.
This needs to run on Windows and Linux - so I will be using the npapi plugin architecture.
The webpage would do most of the interfacing via Javascript.
My questions are:
How do I make the C++ npapi plugin return a value (a json structure) to the webpage javascript and then have a function in the webpage execute without the webpage asking the plugin to do it (to achieve 2.1). That is - the plugin initiates the interaction instead of the usual "webpage asks the plugin to do something"
Is there a better way to implement 2.3 than setInterval?
How do I make the C++ npapi plugin return a value (a json structure) to the webpage javascript and then have a function in the webpage execute without the webpage asking the plugin to do it (to achieve 2.1). That is - the plugin initiates the interaction instead of the usual "webpage asks the plugin to do something"
Use this example.
Is there a better way to implement 2.3 than setInterval?
setInterval works well enough.
Related
I have been using Clojure, ClojureScript, lein, shadow-cljs, Emacs, and CIDER to work on a Clojure/ClojureScript dynamic web app project.
The UI has a download button. For the purpose of this SO question, let's abstract it as an interface with the database that gets data in the UI and put the data in an Excel Spreadsheet. Not sure if this is relevant, but the database is handled by Firebase.
It is important to highlight that this Download button works in production.
However, this Download button has a weird behavior in localhost depending on the build approach:
1 - If I build the project by executing the command cider-jack-in-cljs in Emacs, choosing shadow-cljs, then shadow for REPL type, and, finally, app for the building option the build is successful. Things work in general in localhost - except for the download button. The application hangs and the download is not executed.
2 - If I build the project with shadow-cljs watch app things work in general in localhost - except for the download button. The application hangs and the download is not executed.
3 - Lastly, but not least, if I build the project with $ shadow-cljs server. Things work in general in localhost, including the download button!
Thus, I would like to ask:
(i) - Why does the behavior of this feature depend on the build process?
(ii) - Why is $shadow-cljs server successful while other approaches are not?
(ii) - Approach 1 uses an interface with Emacs to build and 2 uses a raw terminal. I am not sure if they are exactly the same build process, but I believe they are equivalent. Are they?
I have some scripts I'd like to run each morning at 6am. These scripts produce some pdfs of graphical output into a file: foo.pdf
I'd like my system (let's say Win 7, >= R 2.13) to email me these pdf's once the system has finished running the scripts.
Which is the best package - and most robust way of setting it up - to have these reports emailed to me directly via attachment from R?
Are there any 'cool' extensions to this (like sink() -ing report text output into the body of the email)?
Thanks in advance for any advice.
You can harness the power of a package that can handle emails coupled with a chron job. On Windows 7, I've achieved something akin to this using Windows Task Scheduler. Basically, you set it to run a particular script at a specified time.
I have a script running daily, and had lots of problems to get it to run. Take a look at Roman's link for the attachment and R code first. This is about the non-R part in Windows 7.
I had problems running the R script directly from Windows Task Scheduler, so I scheduled a batch file to run every day as follows:
#echo on
"C:\Rpath\R-2.15.1\bin\i386\Rcmd.exe" BATCH "C:\filepath\filetorun.R"
That's about the simplest you can get, but Quick R was a starting point.
Depending on your computer's settings, you might have to fiddle with the task scheduler. If it's a server type that's always on, then you shouldn't have too many issues (and you know what you're doing). If you have to log off and use a password to login or access a shared drive, you'll have to do some of the following. Also, I don't know if admin rights is a necessity or not.
Open Task Scheduler, make a new task, and open its properties window.
Under General, check the user account and select "Run whether user is logged on or not" and UNcheck "Do not store password." This will allow your script to run if you're logged off (I don't think it works when Locked). When you click Ok, it will ask for your password.
Basic setup: The Trigger is "On a schedule" and Advanced is Enabled. Under Actions, select "Start a program" with the Program/script as the .bat file.
Under Conditions, uncheck "Start the task only if comp is idle" and check "Wake the computer to run this task." Under Settings, check "Allow task to be run on demand," check "If the running task does not end..," and at the bottom, select "Stop the existing instance." These options might be necessary, though I'm not as sure about these.
Another trick is if your company has you switch passwords every once in a while. Open and close the task after changing so that it asks for your password again. Enter the new one or else it can't log in and won't run your script.
I'm new to web development so please, could you help me to understand if I'm working in the right direction?
There will be a webpage intended for our customers (not intranet) from where they can print labels. Some of the larger customers will have special label printers where configuration and printing using COM-port is the only acceptable option. Basically we have very limited knowledge and control over their environment.
The web-page itself will be a pretty simple html-page or more complex AJAX.
After the customer inputs all the data and happens to chose this type of printing we have following tasks:
1) get data about the printers on the customer's system installed to a comport and if possible get printer settings (like paper size and orientation). Ideally would like to be able to adjust the settings, but if it is a pain can just put into requirements that your printer must be installed to COM1 and configured correctly.
2) send commands and read answers and send PCL code to the selected com port
As I understand I'll need to install something on the customer's machine to be able to talk to com port and get any settings. Just HTML+Javascript are not capable of doing that. Right?
I found RXTX library which seems to communicate to com port on most platforms. Can it be called from JavaScript or I still need to do a Java plugin? Are there technologies other than Java plugin that would solve the task?
The web-page will be used in different environment - platforms and web-browsers. We would like to minimize the number of customized solutions. Will Java allow us to do the same plugin for all environments with minimal customization?
If we require the user to install a plugin will the user be prompted with our credentials to confirm the installation? Will our web-site require higher trust settings?
Thanks for you help!
Well, I've had to do this in the past. Here is what I did and the circumstances
1) I knew that our customers were in a windows environment so I wrote win32 software to handle the printing.
2) I created a file format to be read by the win32 software that allowed me to specify print parameters and the label data. XML works ok for things like this.
3) My web app created a file in the format used by the win32 software and returned it to the user when they clicked on the "Print Labels" button. The file extension on the file returned was registered by the installer of the win32 software. That means when their browser looked for a default app handler for that file, it found my win32 software.
Bottom line is that the browser is handing off the printer communications to a native application instead of talking directly to the printer.
Obviously you need to be able to dictate your end user's are using a windows machine (or mac or whatever you can write native code). Associating a file extension with my program and returning that file to the user was the key to making the process work for me.
Whether your native code sends pcl directly to the printer or translates into a print api (like the win32 api as mine does) is another consideration.
Another approach you could consider is instead of sending PCL codes, you could create a PDF of the document. Format the document to the size and orientation of the label printer. The user will still have to hit the print button, but that might work. I have done this for printing to bar code printers and it works fine. Sometimes getting the margin and orientation correct is a little tricky, but that can be figured out.
I am looking for options to download, Install and run a custom plugin/add-on(an exe or an installer) from my Flash Movie similar to how the connectnow does that?
When we initiate the screen sharing for the first time, connectnow prompts us for mandatory add-in by showing the message "To use this application, you need the Adobe ConnectNow Add-in.Would you like to install it now?". Once we agree, it downloads and installs acaddin.exe at the location %USERPROFILE%\Application Data\Macromedia\Flash Player\www.macromedia.com\bin\acaddin on our local machine. Then automatically launches the acaddin.exe and allows the user to close the browser window from where the acaddin.exe was launched.
From the next time onwards, when we login to connectnow, it launches the exe directly.
In this context:
If I were to load my own exe/add-in from flash, How can I acheive that?
How does connectnow application/flash determine whether an add-in was already installed or not?
Connect, and I assume ConnectNow, use hidden, undocumented, private APIs for much of their functionality.
You will not be able to do this.
The best you can hope for is to pass the location of your executable to the browser as a local URL and let the browser handle it. I assume in most cases the browser will reject its' execution. Can you imagine the potential for abuse of such a feature?
Instead of using a browser based app, you may want to investigate using AIR and Native Process.
Can I use Selenium IDE on a Drupal system?
I found http://drupal.org/project/selenium but that involves downloading Core and not using my current machine.
Does anybody know of a way to use the IDE with Drupal, or if not what do you suggest I do?
You can, in the same way that you can use selenium on just about any web page.
From what I can see (though I haven’t' used it) the selenium module seems to be more about using Drupal to store and run selenium tests, which is useful, but will not explicitly test your Drupal site. (edit: this module dosn't look like it is currently maintained)
Drupal comes with it's own testing framework which uses simpletest. This can do a lot of the testing that you will need. It can handle form submissions and check for text in a page. There are two cases that I personally have found that it is not very useful for:
Data integrity, where you would like to check that the content of a particular page is correct where you know what to expect on your system
Two is checking the site layout, where you wish to check your live site that certain elements appear as they should do.
Selenium can be used for both of these, in the simplest case you can record tests against your site and play them back to check it. You can check for an elements existence and style. You can check that elements have the text you would expect. Even a few of these can be useful as a tool for checking the configuration of your site.
It is also possible to integrate selenium with simplest so that while running your simpletests through Drupal it will run selenium tests, however this can get very complicated and confusing.
There's a nice new module that takes Selenium exports (in PHP) and converts them to Drupal SimpleTest suites. http://drupal.org/project/simpletest_selenium
This is nice because you can then do continuous integration testing by using Drush to script the running of your tests.
The question is what do you want to achieve?
testing a Drupal site?
saving / playing back configuration settings (automation through the browser)?
The Firefox & Selenium IDE (FF extension) combination works great with Drupal for functional testing.
It also works great if you want to capture some Drupal configuration settings (that you'd like to play back e.g. in another environment) but there are better ways - Patterns and Strongarm modules - to achieve that.
A couple of tips & tricks:
while capturing clicks be careful with timings (between clicks), sometimes you need to add "pause" lines to your test case,
for HTML form checkboxes Selenium often records the "click" action instead of the much safer "check" or "uncheck" action (this is important if you run your test case several times against the same page / form),
if your page reloads when you click a certain link, use "clickAndWait" instead of the simple "click" action,
use "verifyTextPresent" often, especially if you're running your tests "blindly", using Selenium RC.
I use selenium IDE all the time. It's an awesome tool for productivity and communication.
But Drupal's Simpletest framework has a built in browser for user testing. So you probably won't that module.
See:
http://www.lastcraft.com/web_tester_documentation.php
http://drupal.org/node/265762
http://www.lullabot.com/articles/drupal-module-developer-guide-simpletest
You can test Drupal 7 with SeLite, which extends Selenium IDE. It allows your tests to access (read and write to) a test DB (isolated from the DB of the tested application).
It's especially good for Drupal 7, which can have its data in (separate) SQLite DB. So if your test environment can use SQLite, your test data lifecycle will be very easy. However, you can benefit from SeLite even if your test Drupal instance uses other type of DB.
See https://code.google.com/p/selite/wiki/ProjectHome and https://code.google.com/p/selite/wiki/DrupalTutorial.