I'd like to develop an web-based application that allows user to submit Scala code from their web browser client and compile / execute their code on the server.
I was trying to use the scala.tools.nsc.IMain / ILoop classes to load the client file and then execute the file on the server. How do I do this?
How does using the IMain / ILoop classes compare to forking off an external process to compile and execute the code?
Zeppelin is another opensource project worth to take a look at.
It's got scala interpreter embedded for Apache Spark.
https://github.com/NFLabs/zeppelin
I guess it's worth to take a look at https://github.com/Bridgewater/scala-notebook http://vimeo.com/user18356272/review/66548724/53e2b222c1
Related
I have written some libraries which is in groovy.
My SOAP UI scripts which is currently used for API automation is using these libraries. As there is no debug option in SOAP UI Pro It is very hard to find the failures. Can someone help to debug the groovy script from eclipse. Which is called internally by a SOAP UI Script
Here is the way I get it done:
Instead of writing the logic in a groovy script using soapUI script editor, create groovy/java (user choice) class and its methods for the same logic. Here I assume that the script would have relative lots of lines code than fewer lines.
This has couple of advantages:
Intelli sense (which is not available if you write the same in soapUI tool)
Formatting of code
Easy debug
Maintenance of the code would be simple
Have a groovy/java project in the IDE of your choice (Intellij suits better for groovy projects, personal view only). Have the logic in the form of classes / methods. Compile those classes and create a jar file. Place it under SOAPUI_HOME/bin/ext directory.
Edit the soapui invoking script(SOAPUI_HOME/bin/soapui.sh on unix or .bat on windows) and add the debug parameters in JAVA_OPTS say
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=6006.
In the groovy script, just instantiate the above created class and call the appropriate method. Use arguments to your methods, that are available in groovy script context, log, testRunner etc variables. Even the script is done with fewer lines.
Debugging In Action:
In your IDE, configure remote debugging and add your debug points where it is needed. And start debug.
Now, just run the groovy script. Go to IDE, it should stop at the point where you added the debug point. You should be to do run through it normally like how you do with java projects in your IDE.
This works best for me.
EDIT:
Of course, this requires programming knowledge, know working in IDE (assuming that user knows as per the question) configuring build/class path etc.
Can't be done. SmartBear has been talking about this since at least 2007 (when SoapUI was still owned by Eviware), but still has not delivered. Here is one source: http://community.smartbear.com/t5/SoapUI-NG/Debugging-Groovy-scripts/td-p/33995
Hi Markloggers out there,
I am working now a coupe of months with Marklogic, developping xquery, modules, applications on the ML app server etc etc. I use eclipse a lot, I have XQDT up and running for several marklogic servers. We use the console also.
What I miss is a debug functionality... in Eclispe with XQDT I cannot get the debug function working?
What I need is a nice and clean way to quickly test and develop modelules and functions...
This is my basic lib from the ML example documentation:
xquery version "1.0-ml";
module namespace lib = 'http://www.example.com/lib';
declare function lib:user()
{
xdmp:get-current-user()
};
I have this is my XQDT project in eclipse, I have setup a marklogic XDBC server locally and it works ok.
Now I want to use the above module from a file again in the XQDT project in eclipse. But without going to steps of uploading the module to the db etc etc...:
(: XQuery main module :)
import module namespace lib = 'http://www.example.com/lib' at 'lib.xq';
lib:user()
Gives:
XDMP-MODNOTFOUND: (err:XQST0059) Module /lib.xq not found
Question 1: Is there a way to find the module without putting it in a module root? In the docs it says from a XQDT project I could source a module but I cannot get it to work...
Question 2: I can execute arbitrary xquery to the local Marklogic server but if I set a debug flag anywhere in a xgy file in the XQDT project and press the debug button I get a popup saying "The Debug Engine is not properly configured". Can anyone explain to me if it is possible to use the debug option in eclipse XQDT with Marklogic 7 ?
Regards,
hugo
It's best to limit yourself to one question per SO post. After all you can only accept one answer.
Now I want to use the above module from a file again in the XQDT
project in eclipse. But without going to steps of uploading the module
to the db etc
That's a problem. You can evaluate an ad-hoc query directly. But if it references a library module, that library module needs to be available to the server. You're going to have to copy it to the server sooner or later anyhow, so do it sooner. I don't use an IDE myself, but can't you set it up to do that for you?
Question 1: Is there a way to find the module without putting it in a module root?
Not in the broadest sense of "module root", no. The docs at https://docs.marklogic.com/guide/app-dev/import_modules talk about how this works. Somehow or other, you need to make the library module available to MarkLogic.
I can't address your last question. I don't use an IDE, and even if I did I probably wouldn't use a debugger. Instead I xdmp:log messages to ErrorLog.txt, and occasionally I'll plant an breakpoint-like error() call in my code.
i would like to create a JMeter plugin. I would like to understand how to write and pack my code to extend JMeter with my Sample. More in detail i'm looking for an "adhoc" TCPSampler that implement my protocol.
I tried following an old pdf document from JMeter site but it doesn't work. Where is the mistake?
Can you help me with some examples?
Thank you
RM
There are several options to extend JMeter.
Use JSR223 Sampler (groovy language is recommended to use as it can be compiled into Java code, however you'll need to download groovy-all.jar and drop it to /lib folder of your JMeter installation)
Use Beanshell Sampler - basically the same, but it's built-in. Have lower performance than JSR223 + Groovy
Create your own Java Request. 2 Java Request samplers are shipped with JMeter - JavaTest and SleepTest. You can inspect their source to see how they're implemented.
Create your own Sampler. See ExampleSampler source code for details and how to implement it or even use it as a base for your plugin.
All JMeter Extensions should be packaged as .jar and live under /lib/ext folder of your JMeter installation.
Here is book - How to Write a plugin for JMeter http://jmeter.apache.org/extending/jmeter_tutorial.pdf
I've just picked up CoffeeScript and I'm struggling to understand the deployment workflow. It seems you constantly have to compile the .coffee files before using them. (Yes, I'm aware that you can have it embedded in the browser, but that's not recommended for production applications).
Does one have to constantly (manually) compile the files before deploying? (For example, if using Eclipse, a simple Ctrl+S saves and deploys the .war/.ear on the local machine's server.) Do we have to change the build scripts (for a central, possible CI server) for deploying .coffee files? Is there anyway to have integrated compiling via the IDEs (Eclipse/Netbeans)
Any ideas/pointers/examples on this? How/what have you used in the past?
I call browserify in my Cakefile to pre-compile and package my CoffeeScript for the browser. For an example of how I call browserify as well as coffeedoc and coffeedoctest take a look at the Cakefile for my Lumenize project.
If you are using express or some other node based server, you can have your CoffeeScript compiled at request time, using tools like NibJS or as described in The Little Book on CoffeeScript (Applications chapter), you can use Stitch. BTW, I highly recommend, The Little Book. The "Compiling" chapter has information about Cake and compiling that might help you.
Yes, you should have a build script. Most CoffeeScript projects use a Cakefile for this; see, for example, 37signals' pow. With a Cakefile, you can just run
cake build
from the command line to run the build task in the Cakefile.
You can run the Cakefile on a CI server, assuming that you have Node and CoffeeScript installed on that server.
Don't deploy the coffee files, use something like "coffee -cwj" to constantly watch and compile the .coffee files into javascript (.js) files and deploy those.
The options are c=compile, w=watch and j=join the files.
See the coffee-script web site for details of the options you can pass in.
I developed a simple scala app that uses casbah to query the DB for the command line argument passed to it. For example
$ querydb.scala execution 10
it will run a casbah query to find 10 records matching execution in mongo. Now i have two questions.
1) How do i test this in my local. If i click execute in intellij it is just running the program, i am not able to pass command line arguments to my program.
2) How do i deploy it to run on my server, it is just going to used as console app in my ubuntu server, but im not sure how i should deploy this, which files i should put up on the server and how do i execute it in server, and stuff like that.
Any pointers would be useful for me.
or try to use sbt, IDEA has a plugin with sbt, the wiki of it has an explanation on how to use it.
I usually use sbt directly in Terminal instead of running in IDE.
1) First you need to find "Select Run/Debug Configuration" button at the top of your screen
Click on it and choose edit
Create new one, if you haven't got it yet.
Your program parameters should be written in "Program parameters" field
2) Compile your .scala files with scalac and you'll got .class files.
Then deploy it, as you usually do with java code. Hence you don't need to install scala on target machine - all you need is JDK.