Grails console autocomplete - grails

In Grails 1.3.7, the console plugin has any autocomplete feature?
This would be particularly interesting to people learning the language as it allows for the exploration of methods injected at runtime.

While the console does not have an autocomplete feature, one thing you can do in the console to explore native and injected methods is use the Inspect * methods from the Script menu.
My personal favorite is Inspect Last. You'd use it like this:
Create a simple program, with a trailing object:
def foo = ""
Run this program (CTRL+R or CMD+R)
Choose Script > Inspect Last
It looks like this:
The reason that GroovyConsole doesn't have code completion is that while you are typing, those commands have not been run. Therefore, there is no practical way to determine the methods on the object at that moment. Even full-blown IDEs like IntelliJ are limited in the kinds of code completion they can offer.

Related

Dart, how to parse user string into functional dart code?

is it possible to parse in a user entered string, say from a text area, and then incorporate it into a dart function which you can then run, without having to post it back to the server? I guess I'm looking for a dart eval equivalent.
There is no notion of eval in Dart, and it is not possible to dynamically build code. You can run code in a different isolate using spawnUri (see http://api.dartlang.org/docs/releases/latest/dart_isolate.html). When not running in the Dartium browser, note that the Dart code needs to be compiled to JavaScript using dart2js. The site http://try.dartlang.org/ does all that.
Some time in the future Dart might get mirror builders which can be used for "programs to extend and modify themselves" (citation from last paragraph in https://www.dartlang.org/articles/reflection-with-mirrors/).

Is there anyway to invoke a Dart REPL on a website, when using Dartium?

I now know that I can't interact with Dart via the console, but I was hoping that there may be another way to invoke a REPL within Dartium.
Basically, what I would like to be able to do is:
1. Go to a website in Dartium
2. Invoke some sort of Dart REPL
3. Mess about with the DOM, CSS etc., using Dart commands, rather than Javascript.
Is this possible at all? Or, is the Dart development model all Edit/Refresh?
Cheers
Andy
Chrome Dev tools in Dartium will now let you do this very nicely.
Dart edit model is Edit/Refresh.
Maybe you are looking for something like http://try.dartlang.org/

Ruby on Rails: Executing JAR

Folks, i'm trying to execute a jar file inside RoR. Thanks to SO, I figured using IO::popen calls to execute a jar file.
Requirements:
- To login to site: To let our company employees login. Its a Java library which does some magic and figures if the username/password is valid. Which I did using,
result = IO::popen("java -cp auth.jar com.name.auth.LDAPLookup " + params[:username] + " " + params[:password]).read
p result
output: ["Authorized", "email", "id"]
No input sanitizing done. This is risky. Anyone could type something up in username/password and that will be executed in the server.
I'm not sure how to do this. One option I want to try is to use fork() or Process APIs to launch "java" and pass arguments. Couldn't figure out however. Any other thoughts?
Aside from the issue you mention, this sounds pretty painful in terms of performance (you're waiting around for the JVM to start up on every request, after all).
Two solutions jump out at me:
Look what the library does, and see if you really need to call out to Java for this; in particular, if it's just a question of making a lookup in an LDAP directory with a set of canned parameters, there are plenty of gems for that
If you must make use of Java classes from Ruby, strongly consider using JRuby, which will let you call the Java class in question directly, with neither the overhead of restarting the JVM on each call, nor the risk which comes with trying to correctly escape your arguments from Ruby to the shell to the JVM, and back.

F# interactive session persistance and other such user questions

Is there any way of persisting my F# session or serializing it into a file? i.e. so I can hand it to a friend and say "run this" and they will be at the same place I was? I know forth had this ability but I can't find any way of doing this.
An alternative would be a log file or something of similar ilk, but ideally it would strip the output and just give me the code I wrote.
On the topic of user questions, is there a config file for F# so I can add some "always includes" or alter the defaults?
There is no way to serialize the F# Interactive session or create some log of commands automatically.
The typical user interaction is that you write all your code in F# Script File (.fsx extension) and evaluate code by selecting lines and sending them to F# Interactive using Alt+Enter. If you work like this, then the F# Script File is a bit like log of your work - and you can easily send it to other people.
The good thing about this approach is that you can edit the file - if you write something wrong, you can correct it and the wrong version will not appear in the log. The bad thing is that you need some additional effort to keep the source file correct.
Regarding automatic inclusions - you can specify options for fsi.exe in Visual Studio Options (F# Tools). The --load command line parameter can be used to load some F# source at startup.

Why is WSCript object not known to my script that's controlled by a custom IScriptControl?

I am using someone else's library that provides its own scripting host instance, it appears.
This lib provides me with functions to define the type of scripting language such as "jscript" and "vbscript", and I can supply it with script code and have that executed, with passing arguments in and back. So, basically, it works.
However, when I try to access the "WScript" object, I get an exception saying that this keyword is undefined.
The developer, not knowing much about this either (he only made this lib for me because I do not want to deal with Windows SDKs right now), told me that he is using "IScriptControl" for this.
Oh, and the lib also provides flags to allow "only safe subset" and "allow UI", which I set to false and true, respectively.
Does that ring a bell with anyone? Do a user of IScriptControl have to take extra steps in order to make a WScript object available? Or, can he use IScriptControl in a way that this is supplied automatically, just as when running the same script from wscript.exe?
Basically, all I need is the WScript.CreateObject function in order to access another app's API via COM.
I don't know why WScript is not known, but I suspect it is because the script host doesn't provide it. Maybe only wscript.exe does this.
If you are using Javascript, to create an object you can use new ActiveXObject(). If you are using VBScript, you can just use CreateObject.
See this article for some background.

Resources